The document discusses audio signal representation and processing. It covers topics like:
- Sound is oscillation of atmospheric pressure detectable by human ears within a range of 20-20,000 Hz.
- Analog to digital conversion samples an audio signal over time and stores the values. Digital to analog conversion converts these values back to amplitudes.
- Common audio data formats include WAV, FLAC for uncompressed time-domain formats, and MP3, Ogg Vorbis for compressed frequency-domain formats.
- Multi-channel audio configurations have multiple speakers like stereo, 5.1 surround sound, 7.1, etc. Playback involves a sample pump that converts digital audio to analog for output.
2. Technical remark: I drew a number of sketches on the whiteboard. These
were not archived in this deck of slides. Sorry about that, I’ll keep it in mind
next time!
3. Acoustics 101
Sound is oscillation of atmospheric pressure, detectable by ears.
20 Hz – 20,000 Hz
4. • Amplitude of anything over time
• A/D
• Sampling frequency
• Bit depth resolution
• D/A
• Time domain
• Frequency domain
Signal Processing 101
5. • Periodic measurement of the input signal
• Storing the values in a sequence
A/D Converter
0.000
0.383
0.707
0.924
1.000
0.924
0.707
0.383
0.000
– 0.383
– 0.707
– 0.924
– 1.000
– 0.924
– 0.707
– 0.383
0.000
t
6. D/A Converter (DAC)
• Processing a sequence of values
• Conversion of each value to amplitude
0.000
0.383
0.707
0.924
1.000
0.924
0.707
0.383
0.000
– 0.383
– 0.707
– 0.924
– 1.000
– 0.924
– 0.707
– 0.383
0.000
t
7. Audio Data Formats
Time domain-based formats
• Pulse Code Modulation
• WAV
• FLAC
• ...
Frequency domain-based formats
• MP3
• Ogg Vorbis
• ...
8. (Musical Instrument Digital Interface, MIDI)
Mentioned for sake of completeness
Events and their placement in time
19. A low level audio output API
// Main thread
audioAPI_set_callback(&prepare_buffer);
audioAPI_play();
// … some time after (or never):
audioAPI_stop();
// Callback function
static cursor = 0;
void prepare_buffer(
signed_8bit_number *dest_buff,
int length)
{
for (int a=0; a<length; a++) {
cursor ++;
double time = cursor / 48000;
dest_buff[a] = 127*sin(time);
}
}
20. Buffering
PLAY BUFFER 1PREPARE BUFFER 2
PLAY BUFFER 2
PLAY BUFFER 3
PLAY BUFFER 4
PLAY BUFFER 5
PREPARE BUFFER 3
PREPARE BUFFER 4
PREPARE BUFFER 5
PREPARE BUFFER 1
PREPARE BUFFER 6
PLAY BUFFER 6PREPARE BUFFER 7
PLAY BUFFER 7
time
– dropout
CALLBACKS SOUND HW ACTIVITY
21. Buffering
• Shorter, fewer buffers:
– E.g.: 1 buffer, 256 samples @48,000 Hz
• 5.33 ms
• Almost good for the real-time music performances
• Zero margin for errors and delays
22. Buffering
• Longer, more buffers
– E.g.: 10 buffers, 1024 samples each @48000 Hz
• 213 ms
• Safer
• Probably OK for phone calls
– Internet radios – 1~60 seconds of buffer
• Unsuitable for interactive tasks
23. Playback Errors
• Data transmission errors
– Omission
– Pause
– Repetition
• Wrong sample rate
– Different playback speed
– Gradual drop of synchronicity