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

Sound generation with pic??
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
No_Fear
Guest







Sound generation with pic??
PostPosted: Mon Apr 14, 2003 2:23 pm     Reply with quote

Hi there,

In my project i would like to use polyphonic sound alerts instead of using horrible buzzer.Well maybe you heard alert of cherokee jeeps when its doors are open or when lights are open+key is not located. (like Blimp! Blimp! Blimp!) Can i produce these sounds with a pic, if so how can i write a code in ccs? I can't find any sources for this.

Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13664
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Sound generation with pic??
PostPosted: Mon Apr 14, 2003 3:03 pm     Reply with quote

:=Hi there,
:=
:=In my project i would like to use polyphonic sound alerts instead of using horrible buzzer.Well maybe you heard alert of cherokee jeeps when its doors are open or when lights are open+key is not located. (like Blimp! Blimp! Blimp!) Can i produce these sounds with a pic, if so how can i write a code in ccs? I can't find any sources for this.
:=
:=Thanks.

Start with a square wave about 4Khz for about .5 seconds then switch to square wave about 2Khz for about .5 seconds. Repeat
You can use the PWM hardware to make the square wave.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13665
Mark Lehne
Guest







Re: Sound generation with pic??
PostPosted: Mon Apr 14, 2003 9:20 pm     Reply with quote

What about short MP3 playback? Is there a way to store a low bandwidth MP3, and play it back? This seems like it would give the most flexibility and often be worth the extra eeprom hardware. Has anyone done this?

:=:=Hi there,
:=:=
:=:=In my project i would like to use polyphonic sound alerts instead of using horrible buzzer.Well maybe you heard alert of cherokee jeeps when its doors are open or when lights are open+key is not located. (like Blimp! Blimp! Blimp!) Can i produce these sounds with a pic, if so how can i write a code in ccs? I can't find any sources for this.
:=:=
:=:=Thanks.
:=
:=Start with a square wave about 4Khz for about .5 seconds then switch to square wave about 2Khz for about .5 seconds. Repeat
:=You can use the PWM hardware to make the square wave.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13669
mark r. hahn
Guest







Re: Sound generation with pic??
PostPosted: Tue Apr 15, 2003 6:58 am     Reply with quote

One technique I've used for polyphonic sounds is to have a seperate table for each single frequency tone I want to produce.

For example, a square wave and a triangle wave:

const byte square[] = {
0x64,0x64,0x64,0x64,0x00,0x00,0x00,0x00
};

const byte triangle[] = {
0x00,0x16,0x32,0x48,0x64,0x48,0x32,0x16
}

Cycle thru the tables at the appropriate rates (note you can run thru the two tables at different rates). Add the samples from each table together (watch for overflow) and dump the result to some kind of D to A device. I've had pretty good luck using the PIC's PWM output to make nice sounds this way. The PWM update frequency needs to be about 4 times the highest frequency you are interested in reproducing. The PWM clock frequency needs to be much higher, depending on how many bits of resolution you need. For most "phone" quality applications 4 bits is enough. For FM radio quality sound you need closer to 8 bits.

A good reference on using tables to produce waveforms is Hal Chamberlin's "Musical Applications of Microprocessors".

Happy coding,

Mark

:=Hi there,
:=
:=In my project i would like to use polyphonic sound alerts instead of using horrible buzzer.Well maybe you heard alert of cherokee jeeps when its doors are open or when lights are open+key is not located. (like Blimp! Blimp! Blimp!) Can i produce these sounds with a pic, if so how can i write a code in ccs? I can't find any sources for this.
:=
:=Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13680
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Sound generation with pic??
PostPosted: Tue Apr 15, 2003 9:38 am     Reply with quote

:=What about short MP3 playback? Is there a way to store a low bandwidth MP3, and play it back? This seems like it would give the most flexibility and often be worth the extra eeprom hardware. Has anyone done this?
:=
:=:=:=Hi there,
:=:=:=
:=:=:=In my project i would like to use polyphonic sound alerts instead of using horrible buzzer.Well maybe you heard alert of cherokee jeeps when its doors are open or when lights are open+key is not located. (like Blimp! Blimp! Blimp!) Can i produce these sounds with a pic, if so how can i write a code in ccs? I can't find any sources for this.
:=:=:=
:=:=:=Thanks.
:=:=
:=:=Start with a square wave about 4Khz for about .5 seconds then switch to square wave about 2Khz for about .5 seconds. Repeat
:=:=You can use the PWM hardware to make the square wave.

Yes MP3 playback would be really cool but it's a bit over the top for an alarm. Using the PWM is much easier and requires far less code and processing time and you can play with the duty cycle and period to get some interesting results.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13689
Hans Wedemeyer
Guest







Re: Sound generation with pic??
PostPosted: Tue Apr 15, 2003 12:28 pm     Reply with quote

Somewhere on this site, or the web, there is a design using a bit stream to a single pin. The stream will even playback human speech. I should think it is possible to reporidcue the sound yu need using a bit stream.

If I find the link I post it, may be someone else remembers where it is...
___________________________
This message was ported from CCS's old forum
Original Post ID: 13692
Hans Wedemeyer
Guest







Here is the link
PostPosted: Tue Apr 15, 2003 12:30 pm     Reply with quote

<a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank">http://centauri.ezy.net.au/~fastvid/picsound.htm</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13693
John Yaron
Guest







Re: Here is the link
PostPosted: Tue Apr 15, 2003 11:58 pm     Reply with quote

:= <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank">http://centauri.ezy.net.au/~fastvid/picsound.htm</a></a>

I can't seem to get encoder.exe to run
It does bad things
___________________________
This message was ported from CCS's old forum
Original Post ID: 13698
Ted
Guest







Re: Here is the link
PostPosted: Wed Apr 16, 2003 7:18 am     Reply with quote

:=:= <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank">http://centauri.ezy.net.au/~fastvid/picsound.htm</a></a></a>
:=
:=I can't seem to get encoder.exe to run
:=It does bad things

As far as I remember it is a DOS program.
After starting it in a DOS- window there are only some colored
stripes on the screen.
You had to modify the MSDOS properties because of the fixed
screen resolution of the program. I didn�t remember the
right ticmark. Please tell us if it could be done successfully.

Hope this helps
Regards TED
___________________________
This message was ported from CCS's old forum
Original Post ID: 13707
John Yaron
Guest







Re: Here is the link
PostPosted: Wed Apr 23, 2003 8:52 pm     Reply with quote

:=:=:= <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank"> <a href="http://centauri.ezy.net.au/~fastvid/picsound.htm" TARGET="_blank">http://centauri.ezy.net.au/~fastvid/picsound.htm</a></a></a></a>
:=:=
:=:=I can't seem to get encoder.exe to run
:=:=It does bad things
:=
:=As far as I remember it is a DOS program.
:=After starting it in a DOS- window there are only some colored
:=stripes on the screen.
:=You had to modify the MSDOS properties because of the fixed
:=screen resolution of the program. I didn�t remember the
:=right ticmark. Please tell us if it could be done successfully.
:=
:=Hope this helps
:=Regards TED

I know it's a DOS program
It hangs
___________________________
This message was ported from CCS's old forum
Original Post ID: 13956
The Boss
Guest







PostPosted: Thu Apr 29, 2004 5:51 pm     Reply with quote

I still dont find a solution for the software, it dont work under windows XP, virtual PC + MSDOS6.22. Can anny one help us to make it work ?
Thanks
lucky



Joined: 12 Sep 2003
Posts: 46
Location: South Coast - England

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

PIC MP3 Playback
PostPosted: Fri Apr 30, 2004 12:49 am     Reply with quote

Hi people,

Goto my site www.mpic3.com. I am (slowly) building an PIC based MP3 player.

My project is built arround the 18F452 & the VS1001k CODEC chip. I will try to update the site weekly with my progress then I will release my CCS code & H/W diagrams.
_________________
Lucky
www.mpic3.com - MPIC3 player project, Forum, Downloads, Online Shop
hunshen
Guest







PIC sound...
PostPosted: Tue Dec 27, 2005 12:00 pm     Reply with quote

hello......

this problem can be solved using MS DOS window 98....
yerpa



Joined: 19 Feb 2004
Posts: 58
Location: Wisconsin

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

PostPosted: Wed Dec 28, 2005 10:41 am     Reply with quote

You can make a R-2R ladder DAC using eight output pins, then read .WAV files from a serial flash chip and write them to the DAC. The highest sample rate I was able to obtain using a 20 Mhz PIC 16F chip was eleven kilohertz. Fortunately, there are plenty of wave files on the internet encoded at this rate. The biggest trick I found was to use a few lines of assembly to de-jitter the PIC's interrupts - there is either a one-cycle or a two-cycle latency to the PIC's interrupt response, depending what instruction was executing when the sample rate interrupt occurs. This trick improved the sound considerably, but it is still far from hi fidelity.

I have code available, if you are interested.
ratgod



Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

PostPosted: Thu Mar 27, 2008 8:40 pm     Reply with quote

Yerpa: I would like a copy of the code if possible? thanks

I have been playing with wav files myself, but with very little success.
I used this code below but I cannot get anything recognizable out of the speaker.

Code:

#define max_buffer 2032 // This completely filled the 4550's RAM
byte buffer[max_buffer];  // this buffer is stuffed full during startup.
int16 a=0;                       // buffer pointer
int16 b=60;                     // uS Delay value between sending bytes to DAC

   while (TRUE)
   {
     output_d(buffer[a]);       // stuff the byte out to the R-2R ladder DAC
     a++;                            // increment buffer pointer
     if (a>max_buffer) a=0;  // if at end of buffer loop back to 0
     delay_us(b);                 // pause between bytes
   }
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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