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 support@ccsinfo.com

how to create sound effect with library TONES.C

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



Joined: 04 Sep 2013
Posts: 25

View user's profile Send private message

how to create sound effect with library TONES.C
PostPosted: Mon Mar 16, 2015 10:29 pm     Reply with quote

Hello everyone,

I have a big problems to create sound effect with a PIC, I am using 12F683 and I need to save into this one a laser effect, however, I have the problem that I can't use a wav file because the memory size is so small that I can use it, my idea is to create the same sound effect with tones but I have not idea how to do it?

please, tell me that someone knows how to help me this?

I am desperate!!!!!! HELP please........

thanks
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Mar 17, 2015 3:03 am     Reply with quote

CCS has provided the software (EX_TONES.C).

How do you propose to use the hardware you've not told us about?

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Tue Mar 17, 2015 4:22 am     Reply with quote

You need to also understand a lot about sounds.

The point about 'tones', is it keeps the space for the sounds generated small, by only generating simple single tone 'notes', each for a period of time. So all it has to store is a table of 'note', and 'time' values. Ideal for simple little tunes like 'happy birthday'. So, sequential monophonic tones. Some 'sound effects', can be completely unsuitable to generate this way. A 'simple' 'swoosh' sound, requires a section of effectively a white noise signal, with the actual selected output frequencies of this being changed. A noise like this cannot be generated by tones.c, and would probably require several KB of storage for any practical system...

So the amount of storage needed depends totally on the type of sound required. Since laser's, don't actually make a noise at all, visualising what you want gets hard. The noises used for lasers in most sci-fi type games, are noise based, not difficult for a little chip like this to produce.

Place to look is in the noise effects from the very first generation of electronic games machines. If you look at SpaceWar (one of the earliest games):
<http://scratch.mit.edu/projects/14086159/>
Turn off music, and try the laser, this is a sequence of very short notes, starting high, and dropping to produce the sound, then followed by a longer low note tailing away when the laser button is released. Just try a sequence of notes in tones, making each short (about 1/10th the duration of the shortest in the example), and going down the music scale, and see what it sounds like.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Wed Mar 18, 2015 9:40 pm     Reply with quote

How set are you on the 12F683? If the sound is an integral part of your project, I'd suggest going for something with enough memory.

That said, you should have enough room for a couple of sampled waveforms, at say 8bit 16kHz (or less kHz for less size), use a table to dictate how many times each sample loops and what amplitude it should run at; some math can reduce the volume if feeding directly into PWM, depends on how much of a performance hit you want. Maybe someone knows of a clever way of using bitwise operations to halve / quarter the volume?

You can run two 7bit samples and add them together to get an 8bit mix for a dual-oscillator effect.

But as Ttelmah says, you need to understand a lot about sounds, and sampling, to pull it off. In a way I'm lucky that my first sampling keyboard was an 8bit beast with extremely limited memory, it forced you to really understand the nitty-gritty to get anything usable out of it.
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

Re: how to create sound effect with library TONES.C
PostPosted: Thu Mar 19, 2015 1:35 pm     Reply with quote

rald wrote:
Hello everyone,

I have a big problems to create sound effect with a PIC, I am using 12F683 and I need to save into this one a laser effect, however, I have the problem that I can't use a wav file because the memory size is so small that I can use it, my idea is to create the same sound effect with tones but I have not idea how to do it?

please, tell me that someone knows how to help me this?

I am desperate!!!!!! HELP please........

thanks


1 mbit external eeprom should be enough Smile
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
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