aneeshm
Deity
Today , in computer class , having completed my work , I thought I'd do something trivial and interesting . So I whipped together a simple program to simulate the sound of a siren ( setting the base frequency , variance , delay , and number of repetitions ) .
For the technically oriented ( if you're not interested , skip right to the end ) ( the code is old , I had to make it work on Turbo C++ ) :
So when I ran this thing , with base frequency = 5000 , and variance 5000 , it effectively ran over the frequency range (5000 - 5000 =) 0 to 10000 (= 5000 + 5000) , I could hear a *crrunch* sound at some point .
It seems that the resonance frequency of weither the cabinets or the motherboard of the computer was in this range , and so it was going *crrrunch* when I ran this .
I'd like to ask if this could have damaged the computers seriously , and also if anyone else has such anecdotes to relate .
For the technically oriented ( if you're not interested , skip right to the end ) ( the code is old , I had to make it work on Turbo C++ ) :
Code:
#include<stdlib.h>
#include<dos.h>
//using namespace std;
int base,variance,del,repeat,current;
void ascend(int &,int &,int &); /* The format of the above function is
* acsend(current value of frequency , amount to ascend , delay in
* milliseconds)
*/
void descend(int &,int &,int &);
/* The format remains the same , except that instead of amount to ascend ,
* you give the amount to descend .
*/
int main(int argc , char *argv[])
{
/* The format of the command-line parameters to pass
* to the program is rather simple .
*
* The 1st argument is the base frequency ( representing the
* sine x-axis) .
*
* The 2nd argument is the variance , or the amplitude of the sine
* wave .
*
* The 3rd argument is the delay ( in milliseconds ) , representing
* the delay between frequency change in the ascent and descent
* functions .
*
* The 4th argument is the number of times you want the siren to loop .
*/
int i;
base=atoi(argv[1]);
variance=atoi(argv[2]);
del=atoi(argv[3]);
repeat=atoi(argv[4]);
/* The following for loop asends to the top , descends to the base ,
* then descends to the bottom , and finally ascends to the base .
* To do : convert it into an approximation of a sine function from
* a linear one .*/
for(i=0;i<repeat;i++)
{
current=base;
ascend(current,variance,del);
descend(current,variance,del);
descend(current,variance,del);
ascend(current,variance,del);
}
return 0;
}
void ascend(int ¤t,int &variance,int &del)
{
for(int i=0;i<=variance;i++)
{
if(i)
current++;
/* The preceding code makes sure that even if the loop loops
* (variance+1) times , current is incremented only (variance)
* times . It also makes sure that at least one sound is heard
* at the base frequency ( or that the value starts from and
* returns to the base frequency ) . This same approach is used
* in the descend function . */
sound(current);
delay(del);
}
nosound();
}
void descend(int ¤t,int &variance,int &del)
{
for(int i=variance;i>=0;i--)
{
if(i)
current--;
/* See the previous comment on this topic in the ascend
* function . Here , the value of base is devremented on the
* first run , too , to ensure that top and base values
* are not repeated .
*/
sound(current);
delay(del);
}
nosound();
}
So when I ran this thing , with base frequency = 5000 , and variance 5000 , it effectively ran over the frequency range (5000 - 5000 =) 0 to 10000 (= 5000 + 5000) , I could hear a *crrunch* sound at some point .
It seems that the resonance frequency of weither the cabinets or the motherboard of the computer was in this range , and so it was going *crrrunch* when I ran this .
I'd like to ask if this could have damaged the computers seriously , and also if anyone else has such anecdotes to relate .