1.6 Questions for the reader#
Exercise 1
Bit depth arithmetic. You are designing a recording format that uses 24 bits per sample at a sample rate of 48,000 Hz.
What is the uncompressed bitrate (bits per second) for a single channel?
How large is the set of discrete amplitude levels for each sample?
Reveal solution
\(24 \times 48{,}000 = 1{,}152{,}000\) bits per second.
The set of discrete amplitude levels has size \(2^{24} = 16{,}777{,}216\).
Exercise 2
Sample count. Write a one-line Python expression that computes the number of samples needed to store \(T\) seconds of audio at sample rate \(f_s\). Be explicit about how you handle a non-integer product of \(T\) and \(f_s\).
Reveal solution
int(T * f_s) or round(T * f_s)
Exercise 3
Quantization noise. Write Python code to synthesize a 440 Hz sine wave to \(b = 4\) bits at \(f_s = 44{,}100\) Hz. Next, manually quantize the samples to 4 bits using \(\hat{x}[n] = \lfloor (2^{b-1} - 1) \cdot x[n] \rfloor\). Finally, unquantize the samples back to floating point. Write to a WAV file, and listen. Describe in words how it differs from the un-quantized version, and explain why.
Exercise 4
Open. Pick a sound file and inspect its file data on your operating system (you can download this one if you don’t have one). Write down anything you see about file format, sample rate, bit depth, channels, or other digital-audio parameters. Which terms do you now understand, and which still feel mysterious?