Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Audio playback by pic

Status
Not open for further replies.

display

New Member
I am try to make a function of audio playback by pic16.

I have got the pcm date by software and save it in Flash .

Through reading date form Flash adjust the dutycycle of the pwm.The pic get a value of 128 ,then the dutycycle of the pwm is 50% -e.g.(the pcm is 8bits and the sampling rates is 1oKHZ ) But the output is not satisfying.I have used a LPF but the output sounds like that the affect is not obvious.

I have no idea that whether my method of the pcm-pwm convert is correct.
I need some advice .Thank you .
 
Last edited:
Search this forum, I think this has come up before.

When you say flash, you have external flash I hope.
 
1. You either have to use a PWM freq outside the audible range or use a good lowpass filter to remove the PWM freq. You have a 10KHz square wave here and that's not only audible but very strong.
2. 8 bit sound is not really high quality, but still useful. For spoken word, 16 bits with a 4KHz upper frequency with a 8KHz sampling rate is "full quality".

The dsPIC30F/33F and the Si3000 are the best voiceband audio combo by far. The dsPIC has an audio compression library that allows it to store "full quality" speech at 1kB/sec and can compress or decompress in real time. The Si3000 is a adc/dac with the appropriate filters and a bunch of useful hardware features onboard. However it's not possible to interface it with a PIC16.
 
Not really related to PIC but done with an 8-pin AVR and two resistors and no external memory. Perhaps you can look at the source code and figure out how it is done.

The sound effect is extremely good, for a tune of Fur Elise. Just like a music box, no kidding.

The webpage is here: Wavetable Melody Generator Using 8-Pin AVR

The tune it generated is here: **broken link removed**
 
eblc1388 said:
Not really related to PIC but done with an 8-pin AVR and two resistors and no external memory. Perhaps you can look at the source code and figure out how it is done.

The sound effect is extremely good, for a tune of Fur Elise. Just like a music box, no kidding.

But it's just playing a tune, not playing back a sound sample - it uses high frequency PWM to create the note (as suggested earlier by Oznog) and relies on the speaker for the HF 'filtering'.
 
Oznog said:
1. You either have to use a PWM freq outside the audible range or use a good lowpass filter to remove the PWM freq. You have a 10KHz square wave here and that's not only audible but very strong.
2. 8 bit sound is not really high quality, but still useful. For spoken word, 16 bits with a 4KHz upper frequency with a 8KHz sampling rate is "full quality".

The dsPIC30F/33F and the Si3000 are the best voiceband audio combo by far. The dsPIC has an audio compression library that allows it to store "full quality" speech at 1kB/sec and can compress or decompress in real time. The Si3000 is a adc/dac with the appropriate filters and a bunch of useful hardware features onboard. However it's not possible to interface it with a PIC16.


Thank you .I have used a Low pass filter ,and the cut-off frequencies of the filter is 6KHZ.But it didn't get more improve on the output.

Because i must achieve more assignment by pic not only audio playback, I have no choice but pic.
 
Nigel Goodwin said:
EPE did a project for doing this, it used an external EEPROM and an R2R D2A to play the audio - you used a PC to get the audio in the EEPROM.

How about use a DAC IC connect to the output? I had done this,the output souds so impotence that i could not hear it clearly. At the same time the cost of this...... :(

Useing R2R D2A to play the audio souds like a good idea,but there is not enough place on my PCB for so many resistances.
 
eblc1388 said:
Not really related to PIC but done with an 8-pin AVR and two resistors and no external memory. Perhaps you can look at the source code and figure out how it is done.

The sound effect is extremely good, for a tune of Fur Elise. Just like a music box, no kidding.

The webpage is here: Wavetable Melody Generator Using 8-Pin AVR

The tune it generated is here: **broken link removed**

Thank you ,but I have no choice but PIC .
 
Nigel Goodwin said:
But it's just playing a tune, not playing back a sound sample - it uses high frequency PWM to create the note (as suggested earlier by Oznog) and relies on the speaker for the HF 'filtering'.

By the way , i am so curious about your image.what's the meaning of it ?
 
Last edited:
Use a higher PWM rate. Set your PWM rate to say 30Khz and then play back your 10Khz sample rate sound but only update the PWM setting every 3rd cycle of the PWM. Then you can use a LPF with a higher cutoff frequency or do away with it entirely.
Also check that the PCM WAV file sounds OK on your PC and that it is mono and NOT sterio. It's not going to get any better out of a PIC. ;)
 
Last edited:
Some of the notes of the ring-a-ding music box aren't even in tune!
The wind-up ones sound much better.
 
As long as it's linear PCM data that's pretty much it, there is no 'converting'
 
What kind of LPF? Generally like a 2-pole active filter is a good idea. A simple RC filter is too gradual a cutoff.

How was this sound recorded? Are you sure it's quality sampling?
How is this driving a speaker? Do you have an amplifier with enough current and voltage to avoid clipping or other distortion?

Basic prob is that 8-bit sound is going to be crappy any way you cut it. You probably don't have mem space for it, but more bits per sample will make far better quality. However the PWM can also only handle so many bits also. It's possible to use an R-2R ladder to increase the effective number of bits.

Note that LOTS of people have wanted to do audio on a PIC, but you don't see many projects. That's because there are real problems keeping you from getting decent quality and/or recording time.

You say you must use PIC. dsPIC30F or dsPIC33F are PICs! Or are you saying you have to use a PIC16?
 
Oznog said:
What kind of LPF? Generally like a 2-pole active filter is a good idea. A simple RC filter is too gradual a cutoff.

How was this sound recorded? Are you sure it's quality sampling?
How is this driving a speaker? Do you have an amplifier with enough current and voltage to avoid clipping or other distortion?

Basic prob is that 8-bit sound is going to be crappy any way you cut it. You probably don't have mem space for it, but more bits per sample will make far better quality. However the PWM can also only handle so many bits also. It's possible to use an R-2R ladder to increase the effective number of bits.

Note that LOTS of people have wanted to do audio on a PIC, but you don't see many projects. That's because there are real problems keeping you from getting decent quality and/or recording time.

You say you must use PIC. dsPIC30F or dsPIC33F are PICs! Or are you saying you have to use a PIC16?

Yes,the LPF I used was just a 2-pole active filter .The sampling of the wav files I adopted had been proved was viable by somebody in other way.The amplifier worked well when the input was other signal for example the radio signal.

I have tried to use a DAC IC to instead of an R-2R ladder ,but the output souds impotent and not clearly .Because the left pin I have not used of the PIC16F were not enough for me to use an R-2R ladder :( , I have to increase the cost , the result is not satisfaction still.

I doubt whether the problem came from the process i read the date from the external flash ? Is the method I used was viable? And then ,where were they come from?:confused:

At last,thank you very much Oznog, the other work I did was based on pic16.So i have no choice except pic16......
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top