Digital Audio - How Your Computer Interprets Sound
recording and emitting sounds that someone might want to listen to
Overview
Concept
We will take a look at the nature of sound, how it exists in the physical world, and how it is recorded and emitted by contemporary computers.
What Is Sound
Sound is the perceptible sensation that animals have in response to cyclical vibrations of the air or other medium surrounding them.
If a tree falls in a forest and no one is around to hear it, does it make a sound?
-paraphrased from George Berkeley’s Treatise Concerning Human Knowledge, 1710
Good vibrations
The vibration of air (or other transmission medium) radiates outward from the source, creating waves of changes to the pressure and density of air particles.
- The air particles do not travel with the sound… they simply vibrate in place, causing those particles next to them to vibrate, and so on.
Perception
In humans and other tetrapods, the vibrating air waves are channeled into the inner parts of the ear, where they cause a vibration of the eardrum, a.k.a. tympanic membrane, which in turn causes the vibration of the cochlea.
Frequency and pitch
Different parts of the tympanic membrane vibrate in response to different frequencies of air vibration.
-
Vibrations from each part of the tympanic membrane are transduced into electrical signals, and sent along neurons to the brain.
-
The patterns of these signals are interpreted and possibly recognized by the brain, leading to perception of different pitches and other of sound.
-
watch a video explaining how sound is perceived by the inner ear and brain.
The limits of perception
The average human is capable of hearing frequencies betweeen 20Hz and 20,000Hz.
-
Lower frequencies are perceived as lower pitch.
-
Higher frequencies are perceived as higher pitch.
-
Frequencies use the unit, Hertz, which represents how many times per second a waveform oscillates back and forth.
-
When it comes to sound waves, for example, 100Hz would mean that the air density and pressure increase and decrease cyclically 100 times per second.
-
Give yourself a quick-and-dirty hearing test (by no means conclusive) by playing sounds at different frequencies to see what you can perceive.
Analog vs. Digital
Analog
If one were to map the pressure variations in air of a single frequency of sound over time, it might look something like this:
Digital
A computer or other digital device has finite memory and storage, and can only do so many operations per second.
-
For these reasons, a digital device can only record a certain number of samples of the amplitude of the actual physical sound each second.
-
There is endless debate among audiophiles about whether humans can tell the difference between an analog signal and its well-sampled digital equivalent.
ADC and DAC
The conversion of an analog to digital signal is termed ADC, while the reverse is DAC.
Fidelity (lo-fi)
A low sample rate in ADC leads to a poor quality representation of the original waveform.
- draw a line connecting the dots and compare it to the original analog signal
Fidelity (medium-fi)
A medium sample rate leads to an ok, but not great, quality representation of the original waveform.
- draw a line connecting the dots and compare it to the original analog signal
Fidelity (hi-fi)
A high sample rate leads to a good quality representation of the original waveform.
- draw a line connecting the dots and compare it to the original analog signal
Nyquist Shannon Theorum
Engineers named Harry Nyquist and Claude Shannon theorized and proved in 1928 and 1949, respectively, that in order to faithful reproduce a waveform, it had to be sampled at a rate at least twice its frequency.
-
So, for example, a 20Hz wave would need to be sampled no less than 40 times per second.
-
A 20,000Hz wave would need to be sampled no less than 40,000 times per second.
-
If you recall, human hearing falls into the range of 20 - 20kHz.
-
So the max sample rate a sound humans can hear would need would be about 40,000 samples per second.
-
It will therefore not surprise you to learn that 44.1kHz is a common sample rate for digital audio, with 96kHz currently considered very high resolution.
Bit depth
In addition to sample rate, another factor in the faithful reproduction of an analog audio signal is the bit depth.
-
Bit depth refers to how many bits of data are used to represent each sample.
-
For example, a bit depth of 2 bits per sample would allow one of 22 = 4 different values in any given sample.
-
A bit depth of 16 bits per sample would allow one of 216 = 65536 different values in each sample. etc.
-
Today, 32 bits per sample is considered high quality.
Bit depth (continued)
Fitting the amplitude of the analog signal into the available bit depth of a sample is termed quantization.
- Higher bit depths allow a more faithful reproduction of the original analog signal.
Audacity
Audio recording software
Audacity is a free, cross-platform, open source multi-track audio recording software.
- Audacity allows you to record and manipulate audio data down to the level of an individual sample.
The lame MP3 format
While editing audio tracks, Audacity and other multi-track audio tools, will save in their own proprietary “layered” formats.
-
However, most people prefer to share audio tracks in flat MP3 format, which are playable on most computers and devices.
-
In order to export as MP3, a proprietary non-free format, Audacity includes an MP3 encoding tool called LAME.
-
The LAME project has created from scratch a clone of an MP3 encoder much the same way that GNU created from scratch a clone of the UNIX operating system.
-
LAME is a recursive acronym that stands for, “LAME Ain’t an MP3 Encoder”, in clear homage to GNU.
MacOS Catalina (10.15) problems
Audacity currently will not be able to record audio if run on Mac’s Catalina OS (OSX 10.15). Fortunately, there is an easy workaround.
-
Download Audacity and place it into your
Applications
folder. -
Place the following code into a text file named
audacity.command
stored somewhere convenient, such as yourDesktop
.
#!/usr/bin/env bash
# open Audacity from bash... otherwise it doesn't work on Mac Catalina
open /Applications/Audacity.app/Contents/MacOS/Audacity
- Give everyone execute permissions on this file from the command line:
chmod a+x audacity.command
- Whenever you want to launch Audacity, just double click this
audacity.command
file, rather than launching Audacity directly.
Conclusions
We have now seen some of the conceptual details of how audio is stored and manipulated in a contemporary computer.
-
An early 1980’s television show named Bits and Bytes explained many of the concepts of digital audio very well in their episode on Computer Music. While hardware may have evolved since that time, the fundamental concepts behind digital audio have not.
-
There are many Audacity tutorials available online, such as this one.
-
Thank you. Bye.