How does audio translate into bits in a computer file?

2.98K views

How audio is so unique but when you open an audio file in a hex editor, the audio is comprised of bits. How is that possible?

In: Technology

4 Answers

Anonymous 0 Comments

Pretty much every week ELI5 has some question about how this or that can possibly be stored in binary. The answer is the same in every case.

Binary is just a number system. Rather than having 10 digits like we have in our decimal system, binary has 2 digits, which we represent as 0 and 1. Any decimal number you can think of, can be represented in binary. Computers use binary because they’re electronic devices, and it’s easier for them to understand two different electrical voltage levels (on/off, high/low etc) than it is to try and measure a range of different values with varying voltage. “Bits” and “Bytes” are just word we use for computers working with individual binary digits (eg. an 8-bit number, aka a Byte, is just a binary number with 8 digits (10101101), just like “47” is a 2-digit number). “Bit” is actually shorthand for “Binary digit”.

Computer instructions can be represented by numbers. CPUs are built with a list of instructions they can perform, where each instruction is indicated by a number, which then also tells the CPU to expect more numbers as parameters for that instruction. So you could build a CPU where 0110 is the instruction for “Add”, which will the add the 2 4-digit numbers that are sent next. So you send 0110 0001 0101 to “Add 1 and 5” and get 0110 (6) as output. x86 is one such standard instruction set for CPUs.

But data can also be represented as numbers. Text can be represented as numbers, with each character being represented by an 8-bit number. This is the ASCII standard, but other standards have been developed (eg. Unicode) so we can use non-English characters and other stuff like Emoji too.

Images can be represented as numbers. At the basic level all you have to do is specify the amount of Red, Green and Blue for each pixel in order from left to right, top to bottom. Add stuff like compression, transparency, metadata etc and that becomes the specification for a file format like JPEG or GIF.

Sound can be represented as numbers. Sound is just a wave of pressure changing over time from high pressure (compression) to low pressure (expansion). Measure the amount of pressure, say, 44100 times per second, and you can recreate the pressure wave. Store those measurements as a list of numbers, and now you have essentially a WAV file. Add compression and metadata, now you have an MP3.

So in answer to your question, sound isn’t unique. It can be measured, and represented as numbers (not to an infinite level of detail, but enough to more or less resemble the original) just like most other information can, and anything that can be represented as a set of numbers can be stored in binary on a computer. And as long as you store those numbers in a specific known format, people can write software that can understand it and possibly use the machine’s output devices (monitor, speakers, printer etc) to recreate it.

You are viewing 1 out of 4 answers, click here to view all answers.