You hear that? Yes? That is probably the music or video you are watching in the background. But what had to happen that youre able to listen to audio on your computer?
1.Capturing Audio #
The first thing we have to do to be able to listen something is capturing it. As you know sound travels as waves through the air. When recording audio the diaphragm in a microphone creating an alternating current which represents the sound wave as an analog signal. This signal is usually so weak that it will be amplified by a so colled Preamplifier (Preamp) directly in the microphone and therefore be usable for further processing or transmission.
2.Analog-to-Digital Conversion (ADC) #
The Preamp provides us with a useable analog signal which represents what the microphone "hears" but our computer can not work with that as it only knows two values on and off. So we have to transform our analog signal to a digital one which we do in a process called Sampling. We do this by "making a note" of the current value of the signal at regular intervals. The frequency of how often we do this is called the Sample Rate and the most common Sample Rate used is 44.1 kHz, so 44,100 "notes" per second.
The second important parameter when turning an analog signal into a digital one is besides the Sample Rate is the Bit Depth. The Bit Depth determents how big the number for every Sample we make is. A higher Bit Depth increases the possible values each Sample can have and therefore makes it possible for finer details between Samples. For Example a 16-Bit Depth provides 65,536 possible values a 24-Bit Depth provides 16,777,216 possible values.
To summerize the Sample Rate says how often a tone can change in our digital signal and the Bit Depth determents how big or small the difference between two tones next to each other is.
3.Audio Processing #
Now that we have our digital signal our computer can finally work with it. This is now the step most of the actual processing happens to our audio as we have only amplified and transformed our signal beforehand. What now actually happens with our audio depends on what system were running and what we want to do with it, wether its just passing it through to play it on our headphones, record or edit it. But one important thing stays usually the same. The computer wont process each Sample individually but collect them together in so called Buffers. The size of these Buffers vary depending on the underlying application but examples would be sizes of 64, 128 or 256. A Buffer will always be then processed once its full which already shows us the difference between small and large Buffers. With small Buffers we have less "wait time" until the Buffer is full and therefore lesss latency but the load on the CPU is higher and (especially with networking in betwenn) small Buffers can lead to dropout or clicking noises when one Buffer is processed before the next one is ready. Large Buffers come with a more stable playback and CPU-efficent processing but have higher latency.
As in actual processing for our audio there are endless possibilities like running it through an Equalizer, adding Effects etc. One thing we probably use the most is usually handled by the operating system you are using is the Routing and Mixing. In this step the audio from different sources is combined or directly distributed to the right output channels.
4.Digital-to-Analog Conversion (DAC) #
After processing our audio we naturally also want to listen to it therefore we have to play it over speaker or headphones. We could nearly say we are already well acquainted with this step as this is the opposit of what we did in step 2. The values from our Samples are now arranged in a "staircase" curve and a Reconstruction Filter is used to smooth out our digital signal to create a new analog signal.
After transmitting our newly created analog signal to our speaker or headphones this signal is used to make the build in diaphragm to vibrate back and forth creating sound waves which we (or our microphone) are able to pick up.
And that is the full loop how audio is being processed by computers.
Writeup by Darkfinst Post id - dfnst51719