Representing Sound
Learn how sound is represented as 0s and 1s.
Last updated
Learn how sound is represented as 0s and 1s.
Last updated
Sound is a result of changes in the air pressure. These pressure fluctuations cause our eardrums to vibrate, and this stimulates the brain so that we can perceive that vibration as sound.
There are two types of signals: digital & analogue.
Analogue signals are the natural continuous signals that vary by any amount over time. On the other side, digital signals are a construct of analogue signals that use discrete values. Here is more information about the signals:
Digital Signals
Consist of discrete electrical pulses that represent binary numbers (0s and 1s).
Have specific levels representing high (1) and low (0) states.
Are less susceptible to noise and distortion.
Easier to process and compress without losing quality.
Used in computers, CDs, DVDs, and other modern electronic devices.
Analogue Signals
Vary continuously over time.
Can represent an infinite number of states, not just 0s and 1s.
More susceptible to noise and degradation over distances.
True representation of natural sounds and images.
Used in older technologies like vinyl records and analogue radios.
Signals can be converted from one form to another very easily with certain devices. Here are the devices involved:
Analogue-to-digital-converter (ADC) ⸻ Self explanatory name, e.g. a microphone
Digital-to-analogue-converter (DAC) ⸻ Self explanatory name, e.g. a speaker
Computers represent sound as a sequence of samples, where each sample takes a discrete digital value.
Analogue sound samples are recorded via an amplifier. Then each of the sample is quantised to measure it wave-height and it is translated into an integer value. Then the integer value is converted and stored digitally as binary. To output the sound, the reverse happens.
In essence, sampling is just the act of capturing and recording a brief snippet or segment of sound from a source at regular intervals. The number of samples captured per second is called sampling rate, which is expressed in Hertz.
The number of bits allocated to each sample is called the sample resolution/bit depth. Increasing the sample resolution can result in a better sound quality, however it also increases the file size.
Sampling Rate ⸻ Number of samples per second
Sample Resolution ⸻ Number of bits used per sample
Using the formula above will give you the file size in bits, divide it by 8 in order to calculated the file size in bytes.
A 30 second audio track is recorded. The sample rate is set at 44,000 Hertz. The resolution is selected as 16 bits.
For stereo sound, two channels are recorded for left and right, thus doubling the file size.
The Nyquist theorem states that the sampling rate of a digital audio file must be at least twice the frequency of the sound. If the sampling rate is below this, the sound may not be accurately represented.
Humans can hear frequencies of between 20Hz and 22kHz, and this reduces as we age.
Fun Fact: CDs are sampled at 44.1kHz, which is twice the top of human hearing range. This is good as it provides reproduction of the sounds that humans can hear.
Musical instrument digital interface (MIDI) is used for electronic musical instruments which can be connected to computers. Rather than storing samples of sound, MIDI stores sound as a series of event messages, each of which represents an event in a piece of music. These can be thought of as a series of instructions which could be used to recreate a piece of music.
Event Messages contain information such as:
Duration of a note
Instrument on which the note is being played on
The volume of the instrument
If the note should be sustained or not
you can easily manipulate music without loss of quality
The instruments on which notes sound can be changed
Reduces the amount of data transferred
The duration of notes can be altered
MIDI files are often smaller than sampled audio files (and lossless, so no information is lost)
Cannot be used to store speech
Sometimes results in less realistic sounds