This Audio Hacker shield project lets you dynamically adjust the audio sampling rate and bit resolution so that you can listen to the effect they have on audio quality. With an Arduino and this simple shield, we can sample audio and manipulate the signal in many different ways.
Sampling rate is how often we measure the input voltage of an audio signal. The more often we measure it, the more faithfully we can reproduce the signal. According to the Nyquist Sampling Theorem, to reproduce a signal with frequency f, we must sample at a rate of 2f. So higher sample rates will allow us to reproduce higher frequencies and have less noise in the signal.
Bit resolution, or audio bit depth, refers to how accurately we measure the input voltage. A resolution of 8 bits means that each measurement has 8 bits of precision, giving us values in the range of 0-255. A resolution of 12 bits is more accurate and gives us values in the range 0-4095.
CD quality audio is 44.1 kHz sample rate with 16 bits of resolution. The Audio Hacker ADC (analog to digital converter) and DAC (digital to analog converter) are only capable of 12-bit resolution.
But how do these parameters affect the quality of audio? You can listen for yourself by connecting two potentiometers to the Arduino+Audio Hacker shield so we can adjust the sample rate and bit resolution while we are listening to an audio signal!
Load the Audio Hacker example sketch File->Examples->Audio Hacker->DynamicSampleRate onto your Arduino. Connect two potentiometers to pins A0 and A1. If you are unsure how to wire it, see analog input tutorial. A0 will control the sample rate and A1 will control the bit resolution. Set the pots both to their highest values and open the Arduino serial monitor (rate=115200) so you can see the output of the program. Play an audio signal into your Audio Hacker (e.g. from an MP3 player or from your music library on your computer). Now adjust the sampling rate downward until you hear the quality start to suffer. At what sample rate does it seem to start introducing noise? What does the noise sound like?
Now use the second potentiometer to adjust the resolution down from 12 bits to 11, then 10, then lower. Can you tell the difference between 12 bit resolution and 10 bit resolution? How about 8 bit resolution? Lowering the bandwidth of the signal is called “bitcrushing”. What happens when you crush it all the way down to 1-bit resolution? You might be surprised at how intelligible speech can be even with one bit of resolution!
This experiment isn’t a perfect test for sampling rate because there is a low pass filter on the input, so you may not hear much difference in audio quality as the sampling rate goes above 30 kHz. This project is good for hearing how things degrade at lower sampling rates and bit resolutions.
Now, which do you think is more important for audio quality: sample rate or bit resolution?
Full info about the Audio Hacker is here.
For lots more great Audio Hacker experiments, see the Audio Hacker project page.
The Audio Hacker is available as a kit or fully assembled in the nootropic design store.