Skip to main content

Compression & Storage Poverty

Considering creativity has no theoretical limit, digital storage needs to become as limitless.

Updated 10 min readMarkdown

Hello folks, I’m Daire Canavan. I am the Principal Engineer of SoundsMint and am here to tell you about the relationship between music and technology. Building the SoundsMint application has given me the chance to combine these passions of mine, and I’d like to share what I’ve learned with you.

SoundsMint is built with the intention to empower creators of every level of experience to capitalise on creative impulse, connecting with others and getting better at articulating themselves with technology. The primary goal is ease the steep technical learning curve for amateurs and novices, reduce costs for aspiring artists that cannot afford big rigs or external physical storage, all while maintaining file integrity.

Independent creators must use a desktop-compatible Digital Audio Workspace (DAW) to produce music, which are often price exclusionary or pirated (see: Ableton, Logic Pro). Others are free to use but provide insufficient quality (see: Audacity). In any case, there is a significant learning curve to overcome to even get to this stage (see SoundsMint survey: Procrastination & Technical Barriers cited as most prominent barriers to project completion).

Taking control of personal artistic data requires storage, which necessitates file compression. Current methods of file sharing are not tailored for musicians that share content privately with a collaborative partner (e.g. band member, production professional). The file must be downloaded or compressed and shared via email or through another file sharing service (e.g. Drive, Dropbox).

Instead, musicians should be able to collaborate through a closed network that allows for rapid and secure file sharing. For the purposes of virtual rehearsal, less storage space means devices can run quicker. Before I get to compression and storage, let me talk to you about sound itself.

What is Music?

Sound is caused by the transfer of energy that causes vibration through a medium. When the average person listens to music, the medium is usually air. The vibrating air distributes sound waves to the eardrum, which then vibrates and is translated by our brain. If the sound waves hit the perfect amplitude and frequency, a powerful emotional response will be triggered. That’s called art. If the sound waves are off, that’s called noise.

Amplitude dictates how loud something is. Frequency describes how often a full period of a wave occurs.

The period of a wave is how long it takes for one full cycle of the wave to complete, and the frequency is a measure of how many periods there are per second, denoted in Hertz (Hz). Think of plucking a guitar string, and how it swings, or oscillates up and down…

Picture 1.png

Source: studylib.net

1Hz means that one period of the wave occurs every second. 20Hz should be audible to a healthy young adult. The most important frequencies for speech and language are between 250 and 8000 Hz. 20,000Hz is the typical biological limit for audible frequencies.

A musical note has three characteristics. Frequency (Pitch); Amplitude (Loudness); Quality (or tone). Quality (or tone) describes the waveform as interpreted by the listener.

Below you can see 2 single notes, C and G, and a combination of the two in red. Source: https://www.youtube.com/watch?v=nSo6WlGk5jw

Picture 2.png

In the western musical scale, all of the notes have their own frequencies and are mathematically related, forming the basis of harmony. The sum of all the harmonics is the waveform and determines the quality (or tone) of the sound.

Picture 3.png

Summing these frequencies together can be done to form chords. Amplitude can be manipulated to form dynamics. Add a bit of rhythm at the right tempo (we’ll get there) and that’s how music is made! So how is this recorded and stored on our devices?

From Air, To Electrons, To Binary / 0’s and 1’s

Recorded music at its core is the same as the relationship between our ears and our brain, with electricity being added as an extra medium for transmitting to the brain. Sound waves are represented in voltage waveform, which should look familiar:

Picture 4.png source: http://www.learningaboutelectronics.com/

Song waveforms can be depicted in several ways (see below) or can create digital soundwave art here:

Picture 5.png Source: wavevisual.com

Sound can be recorded through microphones, pickups, and other hardware devices, which all use the relationship between magnetism and electricity. We won’t go there right now. This process generates electrical signals that can be physically captured, which is the foundation of analog music. Vinyl records and cassette tapes are forms of storage for analog music.

Digital music became popular due to the ability to create, record and store sounds with far less physical space required, which was correspondingly a lot cheaper.

Analog or digital?

You might have encountered the debate on which format has the superior quality. The argument is founded in the trade-off involved in using digital storage means, which must go through a sampling process that results in a loss of information. Ask Isaac Newton about his thermodynamic principles.

Picture 6.png

Source: Multi-resolution Short-time Fourier Transform Implementation of Directional Audio Coding - Tapani Pihlajamäki. Available on researchgate.net

The diagram above shows an example of how waveform data is digitally sampled. The top waveform shows the original wave and the points at which the wave is sampled. It is continuous and doesn’t break, producing an uninterrupted sound for the brain to interpret. The bottom illustrates the points at which the sound was sampled along that continuous line from above. The gaps are clear, and if the sampling rate isn’t sufficient or undersampled, aliasing will present a different version of the sound sampled, as demonstrated below.

Picture 7.png https://www.ni.com/docs/en-US/bundle/labview/page/lvanlsconcepts/aliasing.html

The Nyquist Theorem, the legacy of Bell Laboratories, prevents undersampling by ensuring the sample rate is at least twice that of the frequency being heard or listened to. This is the reason behind the standard CD quality sampling rate being 44.1kHz. Audio waveforms are typically sampled at 44.1 kHz, although sampling rates higher than about 50 kHz to 60 kHz cannot supply more usable information for human listeners.

Nevertheless, higher sampling rates produce a digital representation of the sound that is as close to the raw voltage as possible, and are commonly used on CDs. Professional audio gear will have higher sampling rates.An example of such would be comparing the quality of a phone call, which would hover around 8 kHz, with a podcast or a chart song. Since phone calls are deliberately sampled at a lower rate to save costs on superfluous, high-fidelity audio, this isn't inherently linked with the Nyquist theorem. However, it is a useful way of conceiving the trade off involved in digital storage, in that a higher sampling rate is conducive to higher quality audio because it allows for a broader range of frequencies to be captured.

Bit-Depth / Digital Storage

Information can be stored digitally using binary data, consisting of 0s and 1s. Digital samples are stored using a collection of binary bits, which is best illustrated by the table below.

Examples

Screenshot 2022-10-06 at 12.30.04.png

It’s clear that a richer sample requires more bits. Typical samples are 8-bit (1 byte), 16-bit (2 bytes). Using a 16-bit sample size gives 65,536 values to represent the voltage reading. Now it’s time to visualise the effect on the soundwave. Below is a 3-bit example.

Picture 8.png

Adding just 1-bit to the depth doubles the resolution of the soundwave, improving the quality interpreted by the listener.

Picture 9.png

Using a 16-bit depth produces 65,536 possible readings, exponentially increasing the accuracy of the sample. Adding more bits per sample when recording increases the likelihood of high fidelity audio, however, inherently takes up more memory. Lowering the bit-depth when recording audio will have a correspondingly negative effect on the sound quality.

An example of how this can effect the sound quality is shown in here: 16 bit audio vs 8 bit audio There is a noticeable distortion in the lower bit-rate sound clip in this video.

Effects On Storage Requirements

Take a standard CD, sampled at 44.1kHz with 32-bit depth. This means that 4 bytes of information are stored 44,100 times every second. A standard 3 minute song adds up to 31,752,000 bytes, otherwise denoted as 31.752 Megabytes (MB). Formatting it as a stereo track doubles the storage needs, ramping up the file size to 63.5 MB. As we move up the scale, the amount of storage space required does not produce a correlated increase in quality, and if it does, it would only be audible to a highly trained ear.

Compression

The average listener’s consumption of music today is owed to the art of optimising digital storage by reducing the size of audio and video files, known as compression. Compression is essential to maximise the amount of data that can be stored in a device while mitigating losses in quality as much as possible. ZIP is a typical example of a compressed file format.

For audio files, there is lossy and lossless compression. As the naming suggests, lossless compression means no information is lost between compression and decompression, while lossy leads to loss of the original data.

Lossless Compression : (y = mx + c)

Lossless compression can reduce file size or bandwidth requirements for streaming, while also providing an exact duplicate of the original raw audio data upon decoding. The most widely supported lossless compression algorithm is Free Lossless Audio Codec (FLAC). This involves an algorithmic conversion of data into a linear equation that is far less intensive than storing each datum. There are three stages to this:

Blocking: Dividing the data into sections. The graph below shows how this may be done. A block of data is represented by the space between the blue lines below.

Picture 10.png

Curve-fitting / linear prediction: The algorithm looks at the data in each block and produces an estimate of the line equation. Below is an enhancement of the previous graph between 1.5-2.4 milliseconds (m/s). The markers are the actual samples and the green line is a trendline formed from the data. Storing the equation of the green line is much more efficient than storing each individual marker, of which there could be thousands.

Picture 11.png

Residual Coding: To determine whether the line equation has produced an accurate estimate or not, the freshly encoded data within each section (between the blue lines) is then decoded and compared against the original. Any discrepancies between the original data in the block and the data decoded using the predicted equation from step 2 are added here to ensure a 100% replication of the original file.

Other lossless algorithms work in similar ways, mainly depending on curve-fitting / linear predictive coding as shown here with FLAC. As the algorithm will not predict the curve correctly 100% of the time, residual coding adds a bit of overhead, so FLAC and other lossless algorithms don’t have as high of a compression ratio as lossy compression algorithms do.

FLAC encoding provides a compression ratio of approximately 2:1, meaning that the standard 44.1kHz stereo audio file mentioned above of 63.5MB could be reduced to 31.75MB. However, when decompressed for playing, the decoded file from FLAC / lossless compression will contain an exact replica of the original data. This replica maintains 100% quality.

Lossy Compression

The most common lossy compression format is Moving Picture Experts Group (MPEG), which covers visual data, and the MPEG Layer 3 (MP3) format that covers audio data. The algorithm involved in these formats prioritises the audio data in terms of perceived importance, cancelling out frequencies based on their amplitude, or loudness. Another method involves audio data analysis, determining the frequencies present and removing those that are inaudible to the human ear or those affected by interference.

Removing frequencies that are inaudible for the human ear is called psychoacoustic modelling, which is used routinely in compression algorithms. In psychoacoustic modelling, a human ear is simulated to distinguish between sounds that cannot be heard and sounds that can be heard. The algorithm removes sounds that it predicts will be inaudible, allowing for a reduction in the file size.

Using the MP3 compression format for music provides a dramatic bandwidth reduction that is optimal for streaming. For example, araw 16-bit audio at a sample rate of 44.1kHz with stereo audio (left and right) requires - (44100 2 channels 16)/(1000 bits per kbit) = 1,411.2 kbit/s bandwidth. A bit-rate of 128 kbit/s is used quite often when streaming MP3 audio, straight away this offers a compression ratio of 1411.2/128 = 11:1. That can save quite a bit on your data plan!

Taking the 63.5 MB stereo file example, this reduces the raw audio to just 5.77MB, much more compact and hard-drive friendly. While it is convenient to label the removed audio as unnecessary, it does produce a noticeable difference in audio quality. Ask your local sound engineer. They will also tell you that MP3 files are not optimal for editing or mixing, and that compression formats are optimised for the consumer.

Creators require as close to ‘real thing’ as possible when editing or recording audio, which is quite intensive on a hard drive if streaming as it involves storing high-fidelity, multi-track audio. Therefore either raw uncompressed files or lossless compressed files are required, and must be made accessible at a large scale to support the global economy of independent music makers.

No comments yet. Be the first to comment.