Audio on PIC

Thread Starter

powzoom

Joined Jan 18, 2009
41
I'm trying to build a digital metronome using a PIC, speaker, and lcd display. How can I get the PIC to play audio? like the sound of a drum or symbol crash to keep the beat. I think I'll have to use an external eprom to hold the data. Let's say I have the sounds in wav. or mp3. format on my computer, how do I get it on to the PIC and how can I make it play the sound?
 
...a lot of stuff...
forget the mp3...

use the wav format is easy to use (search for the format).
Store it on the EEPROM or embed it within the flash memory.
Convert the bytes to sound using a PWM generator as DAC or a simple R/2R DAC structure.

It's a lot of stuff...it's possible and they make it.
...you will probably enjoy the project.

...by the way, I would recommend at the beginning to play just a beep using a buzzer.

Ciao,

Mauro
 

THE_RB

Joined Feb 11, 2008
5,438
I'm trying to build a digital metronome using a PIC, speaker, and lcd display. How can I get the PIC to play audio? like the sound of a drum or symbol crash to keep the beat. I think I'll have to use an external eprom to hold the data. Let's say I have the sounds in wav. or mp3. format on my computer, how do I get it on to the PIC and how can I make it play the sound?
Hi there is free windows software here;
http://www.romanblack.com/picsound.htm
that lets you turn .WAV files into 1bit format which can then be played on a PIC with no external hardware (ie no DAC needed). For short sounds of lowish quality you can store the sound in the PIC rom, but if you want longer sounds or better quality then you need to put the sound in an external eeprom, fortunately they are pretty cheap.
 
I have checked the project.
The one bit "conversion" is basically what it would have been done by the PWM....giving the WAV info directly to the hardware (or software).

The DAC in basically there. As mentioned one DAC can be realized using a PWM. What I did not mentioned is about the low pass filter you have to add.
...if you speak Italian you can find a nice PWM tutorial on my web page... :)

By the way, the pointed project can make your life easier.

Regards,

Mauro
 

Thread Starter

powzoom

Joined Jan 18, 2009
41
Thanks for the replies. I'll use that 1 bit conversion technique but I've never worked with an external eeprom before. Do I need a separate programmer to get the data on to it? I have the PicKit2 but I'm not sure if it does that.
 
Hello,

no you do not need a different programmer the PIC can handle it (you can also use a programmer if you want).
On my web page you can find a free library for C18 that can handle EEPROM 24LCxxx. Go to C18 Step by Step. Unfortunately the tutorial is still not translated in English...but if you speak Italian...

By the way an external memory could be not required if the sound that you have to reproduce is a short one. After all a drum sound could be just made out of simple "bum" sound. Just repeat it to get "bum bum" and put the delay you need depending of your timing.
The bum could be recorded within the flash memory.

Ciao,

Mauro
 

Thread Starter

powzoom

Joined Jan 18, 2009
41
Mauro, thanks for tip. My Italian is real rusty but maybe I can plug it into Google translator or something. While the sound would be short, I don't have much room at all on the pic so I ordered a 512k eeprom. This way maybe I can make it fancy with different sounds. For now, I just oscillate a port connected to a transistor that drives a speaker at 440Hz to make a decent sound. It works for now.
 

THE_RB

Joined Feb 11, 2008
5,438
I have checked the project.
The one bit "conversion" is basically what it would have been done by the PWM....giving the WAV info directly to the hardware (or software).

The DAC in basically there. As mentioned one DAC can be realized using a PWM.
Yes, but 1bit system has a much higher sample rate than a PWM DAC so the noise artifacts are at a higher frequency and much easier to filter out, and also the 1bit sound uses 8 times less memory for the same sample rate.

I do agree that both systems have their strengths and weaknesses.


...if you speak Italian you can find a nice PWM tutorial on my web page... :)

By the way, the pointed project can make your life easier.

Regards,

Mauro
It's cool I don't need a PWM tutorial. Your web page has some good projects and I like your style keeping everything simple with minimalist hardware.

If I could make one suggestion it would be to make the schematics available as images so it is not necessary to download a .PDF for every project to have a look at what it is.
 
Top