CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Advice with Sound Generation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arunkishore
Guest







Advice with Sound Generation
PostPosted: Tue Dec 23, 2008 10:00 am     Reply with quote

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!! Laughing 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

View user's profile Send private message

Please Advice
PostPosted: Wed Dec 24, 2008 9:00 am     Reply with quote

I wonder why there isn't any replies until now. Is it not possible or am I wrong with my question???? Sad

Thanks for your time.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Dec 24, 2008 10:32 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 24, 2008 9:25 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Dec 26, 2008 6:49 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group