# Understanding Digital Audio - “From Audio Device” in Matlab

I understand that digital audio has both a sample rate (time "discretization") and a bit depth ("amplitude" discretization). Also, it can have multiple channels (stereo would be 2 channels).

But things that I can't find readily in the internet:

1. What is the range that is discretized in the bit depth? My experience is in motions, so I know if I have an accelerometer with a range of +-10 g's, and I discretize it in 8bit, well I would have a resolution of 20g/256. What would be the equivalence in audio?
2. Matlab's Simulink has a block for reading audio. It's output has the dimensions of MxN(xTime), where M is the number of "consecutive samples" and N the number of channels. What is "consecutive samples" (also called in the same help file as "Frame Size (samples)"). If I set this value to one, I would get what I would expect from a Mono sound, just a time history of amplitudes. But if I set it to two, it's almost as if they are both the same with minor differences in fast transitions. Is this meant for to get a average of the signals to be somewhat more "true to sound"?

Here is the link for Simulink's block: http://www.mathworks.com/help/dsp/ref/fromaudiodevice.html

## 2 Answers

1) The microphone converts the audio signal to an electrical signal, and then that electrical signal often goes through an amplifier and then to the ADC. The ADC usually samples the voltage of the electrical signal, which is directly analogous to the pressure of the audio signal.

If you want to think of it in audio terms, probably the most useful way to think of it is that your microphone/amp/something saturates at a certain dB level. Let's call that "X" dB. That is where your signal maxes out. If you have 16-bit sampling then you can span a decibel range of $20log_{10}(2^{16})$ = 96 dB. That means that, in an ideal world, you could cover audio signals from "X" dB to "X" - 96 dB. Since the world is not ideal you would probably not get that entire range, but you would probably get pretty close.

2) "Consecutive samples" just means the number of samples. They throw "consecutive" in there just to say that they are not skipping samples. If you set that value to 1 you will only get one sample per channel, which is probably not what you want to do. The number of channels refers to the number of audio sources. For mono you would set that to 1. For stereo you would set it to 2.

Normally, audio samples are measured every unit of time discretization (every about 22.676 uS at a 44100 samples-oer-second sample rate, consecutive means that this is done without skipping any of those discrete time units), and analyzed in blocks, so as to amortize any fixed per block overhead (interrupt latency, subroutine call overhead, etc.). For instance, one might use a block size of M = 4096 so as to process audio samples using an FFT of that length, with O(MLogM) efficiency.. Since the samples in a block are taken consecutively, they all each don't need to be individually time stamped, as relative time can be inferred from each samples position in the block array, and the sample rate.

Unless there is high frequency content in the audio, two adjacent consecutive samples won't have time to change much. That might be why they look similar in value when you look at 2 in a row.

The amplitude units are arbitrary, depending on the gain of the microphone, pre-amp, AGC and ADC, etc., they could be almost anything unless you calibrate against some known source. Usually one tries not to fiddle with the gain after it has previously been set so that values will not be too small or too large for the amplitude quantization and number size (16 bits, etc.) in use.