View previous topic :: View next topic |
Author |
Message |
arunkishore Guest
|
Advice with Sound Generation |
Posted: Tue Dec 23, 2008 10:00 am |
|
|
Hi All
Good day everybody. I need some advice from experts around here to generate sound specifically to that of a siren starting from a low volume to a higher volume and repeating the same......
I tried the ex_Tones example and it works fine!! But I'm still unable to figure out the note that I should use to generate the sound that I require with the right duration. I do think that some of you might have already done the same and please guide me to straighten up things. I have tried almost all the possiblities but I still cant manage to get it right. Running the C_note[0],350 and E_note[0],900 produces some sound but I'm quite sure that it is not the thing I want. Please help
Thanks for your time. |
|
|
arunkish
Joined: 23 Dec 2008 Posts: 83
|
Please Advice |
Posted: Wed Dec 24, 2008 9:00 am |
|
|
I wonder why there isn't any replies until now. Is it not possible or am I wrong with my question????
Thanks for your time. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Dec 24, 2008 10:32 am |
|
|
Your question sounds confusing. Your talking of varying a tone volume, but a siren in common understanding has a variable pitch (frequency). So it's unclear, what your actually trying to achieve. |
|
|
arunkish
Joined: 23 Dec 2008 Posts: 83
|
|
Posted: Wed Dec 24, 2008 9:25 pm |
|
|
Thank you for your reply. Just trying to generate a sine wave or something like that. In short trying to generate a siren sound. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Fri Dec 26, 2008 6:49 am |
|
|
A siren (typically having a 'woo woo' sound) has varying frequency of excitation, NOT varying volume (ie intensity). UK police sirens have a very distinct (almost two-tone) siren, while American cops have a more gradual variation. A factory siren, on the other hand, has a fixed frequeny.
To obtain a factory siren-like sound you simply need to output a fixed-frequency PWM signal to a speaker.
To obtain the UK two-tone siren output first one frequency for a short time interval then a different frequency for a short interval. Repeat this.
For the American police siren you need to output a PWM and slowly increase the PWM frequency, and then reduce it.
In all cases the frequency is the important thing to note. Changing the duty cycle of the PWM signal while keeping the frequency unchanged will cause a change in the output volume.
Very simple algorithms for understanding purposes:
Factory siren- Code: | while (true)
{
output high to speaker
delay
output low to speaker
delay
} |
UK siren- Code: | while (true)
{
for (tone1=0; tone1<10; tone1++) //produces tone of high frequency
{
output high to speaker
delay
output low to speaker
delay
}
for (tone2=0; tone2<10; tone2++) //produces tone of low frequency
{
output high to speaker
delay_longer
output low to speaker
delay_longer
}
} |
US siren- Code: | while (true)
{
time=200
for (tone=0; tone<100; tone++) //produces tone of varying frequency
{
output high to speaker
delay(time)
output low to speaker
delay(time)
time--
}
for (tone=0; tone<100; tone++) //produces tone of varying frequency
{
output high to speaker
delay(time)
output low to speaker
delay(time)
time++
}
} |
You will, of course, have to play around with delay values to get the right sound.
Rohit |
|
|
|