4️⃣Representing Sound

Learn how sound is represented as 0s and 1s.

What is Sound?

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.

Watch this for an understanding of sound

Types of Signals

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.

Analogue vs Digital

Conversion between signals

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

Sound in Computers

Computers represent sound as a sequence of samples, where each sample takes a discrete digital value.

How analogue sound is stored into digital computers

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.

Sampling

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.

File Size

Sampling Rate ⸻ Number of samples per second

Sample Resolution ⸻ Number of bits used per sample

File Size = Sample Rate (Hz) * Sample Resolution (bits) * Length (seconds)

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.

Example Question

A 30 second audio track is recorded. The sample rate is set at 44,000 Hertz. The resolution is selected as 16 bits.

44,000 x 16 x 30 = 21,120,000 bits
21,120,000 / 8 = 2,640,000 bytes / 1,000,000 = 2.64MB

For stereo sound, two channels are recorded for left and right, thus doubling the file size.

Nyquist’s Theorem

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.

Sampling a signal at a rate at least twice its highest frequency ensures that there are enough data points to accurately reconstruct the original signal without introducing aliasing artifacts.

Human Ear

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.

MIDI

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

Advantages of MIDI

  1. you can easily manipulate music without loss of quality

  2. The instruments on which notes sound can be changed

  3. Reduces the amount of data transferred

  4. The duration of notes can be altered

  5. MIDI files are often smaller than sampled audio files (and lossless, so no information is lost)

Disadvantages of MIDI

  1. Cannot be used to store speech

  2. Sometimes results in less realistic sounds

Last updated