0

I am trying to play wav file using arduino and speaker I saw few examples (ex. http://playground.arduino.cc/Code/PCMAudio). But I don't understand few things and at least one of them is fundamental for succeding in that task.

I understand that having x bit audio at y sample means:

  1. I must play x samples per second.
  2. Each sample should be played for 1/y seconds.

I manged to convert my audio to 8 bit 8000 Hz byte array. I don't understand what are those 8 bit values. (I know they are sample values but what does they mean). What am I supposed to do with them to play sample? Are they max voltage % or something?

1 Answer 1

1

The link you give is for playing audio out a pin with PWM = Pulse Width Modulation. PWM mimics changing the output voltage by toggling the pin from 0 to Vcc for a portion of the time in each cycle that is proportional to the sample value. A value of 0 means the pin remains at 0 for the whole cycle. A value of 256 means the pin stays high. A value of 128 means the pin is high for half the cycle and off for the rest.

To record audio, a device sample the voltage from a microphone at a certain rate. The higher the rate, the better. As well, the voltage sample can have more or less precision. Higher is better.

8-bit audio means that the voltage recorded in an interval is one of 256 values. 12-bit audio has 4096 values.

A sample rate of 8000 Hz means that the samples are taken 8000 times per second, or once every 125 us.

Sign up to request clarification or add additional context in comments.

2 Comments

I know all of this. But what is the meaning of those 8 bit voltage recorded values.
A microphone reacts to changes in air pressure to induce a current in a wire. The voltage difference between the ends of the wire is the analog audio signal. The signal varies from positive to negative rapidly. The digital values are an approximation to this signal, with 0 being the most negative and 255 the most positive. When the voltage signal is delivered to a speaker over a pin, the speaker coil converts the induced current into movement, reproducing the original sound.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.