View previous topic :: View next topic |
Author |
Message |
No_Fear Guest
|
Sound generation with pic?? |
Posted: Mon Apr 14, 2003 2:23 pm |
|
|
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
|
Re: Sound generation with pic?? |
Posted: Mon Apr 14, 2003 3:03 pm |
|
|
:=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?? |
Posted: Mon Apr 14, 2003 9:20 pm |
|
|
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?? |
Posted: Tue Apr 15, 2003 6:58 am |
|
|
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
|
Re: Sound generation with pic?? |
Posted: Tue Apr 15, 2003 9:38 am |
|
|
:=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?? |
Posted: Tue Apr 15, 2003 12:28 pm |
|
|
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 |
Posted: Tue Apr 15, 2003 12:30 pm |
|
|
<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 |
Posted: Tue Apr 15, 2003 11:58 pm |
|
|
:= <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 |
Posted: Wed Apr 16, 2003 7:18 am |
|
|
:=:= <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 |
Posted: Wed Apr 23, 2003 8:52 pm |
|
|
:=:=:= <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
|
|
Posted: Thu Apr 29, 2004 5:51 pm |
|
|
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
|
PIC MP3 Playback |
Posted: Fri Apr 30, 2004 12:49 am |
|
|
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... |
Posted: Tue Dec 27, 2005 12:00 pm |
|
|
hello......
this problem can be solved using MS DOS window 98.... |
|
|
yerpa
Joined: 19 Feb 2004 Posts: 58 Location: Wisconsin
|
|
Posted: Wed Dec 28, 2005 10:41 am |
|
|
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
|
|
Posted: Thu Mar 27, 2008 8:40 pm |
|
|
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
}
|
|
|
|
|