Is there a way to convert PCM data to PWM impulsion so that I can send it a basic stamp microcontroler in order to play audio on a external speaker ?
(without using an IC)
|
Is there a way to convert PCM data to PWM impulsion so that I can send it a basic stamp microcontroler in order to play audio on a external speaker ? (without using an IC) |
|||
|
|
|
Convert your sound file to a WAV file:
Make an unsigned mono 8bit version at the desired sample rate:
Convert the samples to a C header file (get wav2c):
(For your BASIC Stamp, you'll need to convert this array into some other format). Then, in your application you need to read one sample from the array each time the sample rate duration expires and transmit it out of your PWM pin. |
|||
|
To generate RAW samples from an audio file you could use mplayer
This outputs raw 16 bit little-endian samples to |
|||
|
|
|
I've tried to do such procedure before (I read Enide! - PIC sound player (PCM to PWM converter)), but I didn't regonize the original sound. I called the statement: PWM pin, duty, cycles, which "converts a digital value to analog output via pulse-width modulation, where Cycles is a variable/constant (0-65535) specifying an approximate number of milliseconds of PWM output." This means I can send only one sample per millisecond. So my sample rate should be 1000 Hz. Is it true? I'm wondering why I didn't recognize the sound. Maybe it comes from the way I converted the WAV file on my computer. |
|||||||
|