Page 1 of 1

Raspberry pi Zero - Analog audio input

Posted: Mon Jul 10, 2017 9:50 pm
by ShaBang
Hey everyone !

I have an analog microphone and i would like to record audio from it with my raspi Zero ...
I searched on google and i found that : https://www.adafruit.com/product/856 the MCP3008 can convert analog signal to digital signal :D

But I've heard that the MCP3008 is not fast enough to record audio ... And apparently there is no way to record audio directly from GPIOs :?

Am i obliged to use an external usb sound card ?

Re: Raspberry pi Zero - Analog audio input

Posted: Mon Jul 10, 2017 10:09 pm
by mahjongg
An ADC isn't suitable for recording sound, as the sampling must happen at very regular intervals, you need a codec instead.
Happily all PI's have a codec (I2S, or "Inter IC Sound") interface, to which you can connect an audio codec.
google for "I2S Raspberry PI" for more info.
So NO you are NOT obliged to use an USB sound card or Microphone.

Re: Raspberry pi Zero - Analog audio input

Posted: Tue Jul 11, 2017 11:50 am
by drgeoff
mahjongg wrote:An ADC isn't suitable for recording sound, as the sampling must happen at very regular intervals, you need a codec instead.
That is rather loose technical writing on two scores

1. The MCP3008 may not be suitable but an audio ADC is.

2. Codec is a contraction of 'coder-decoder' and does not mean that it includes an ADC and/or DAC.

Re: Raspberry pi Zero - Analog audio input

Posted: Tue Jul 11, 2017 12:05 pm
by Burngate
Given that, according to its datasheet, the MCP3008 can run at 200ksp, it should be capable of sampling audio.

Re: Raspberry pi Zero - Analog audio input

Posted: Tue Jul 11, 2017 3:25 pm
by drgeoff
Burngate wrote:Given that, according to its datasheet, the MCP3008 can run at 200ksp, it should be capable of sampling audio.
The sample rate is adequate but 10 bit/sample is a bit on the mean side for audio. (Yes, telephony uses 8 bit/sample but those 8 don't represent equal step sizes.)

Re: Raspberry pi Zero - Analog audio input

Posted: Tue Jul 11, 2017 6:11 pm
by Burngate
If my memory serves me well, Philips wanted CDs to use 14 bits, but Sony insisted on 16
But, yes, 10 is a bit "digital"

Re: Raspberry pi Zero - Analog audio input

Posted: Wed Jul 12, 2017 11:32 am
by flatmax
The dynamic range of 10 bits is very small :) The noise floor would be high.

If you consider that people have extremely acute hearing, with our ability to hear between 120 dB SPL and 0 dB SPL very well. We can hear on a scale of 1:1 000 000 ! 20 uPa to 20 Pa if that link is correct.
If you look at that in terms of bits : b = log2(10e5) = 19.93 bits.

The threshold of pain varies between people and some people may have a very high threshold. You could use this calculator to find more accurate estimates of Pa for different thresholds. It quickly converges on 24 bits.

For this reason, high quality audio requires 24 bits.

If however you want amazingly good recordings, then why not go to 32 bits ?!? Just get an amazing piece of hardware with incredibly low noise floor from somewhere :)

Matt

Re: Raspberry pi Zero - Analog audio input

Posted: Wed Jul 12, 2017 12:11 pm
by mahjongg
drgeoff wrote:
mahjongg wrote:An ADC isn't suitable for recording sound, as the sampling must happen at very regular intervals, you need a codec instead.
That is rather loose technical writing on two scores

1. The MCP3008 may not be suitable but an audio ADC is.

2. Codec is a contraction of 'coder-decoder' and does not mean that it includes an ADC and/or DAC.
any audio transmitter/receiver chip connected to the Inter IC sound bus is generally called a codec.
https://en.wikipedia.org/wiki/I%C2%B2S

I still stand by my position that a generic ADC is badly suited for recording audio, and as any PI has an I2S port that one is the best choice for interfacing to audio devices. its why it was developed, and why all serious digital audio generating/recording equipment use it.

most "audio ADC's" either support I2S, or a specific DSP interface, only a few of them support SPI, none that I know of uses I2C.

Re: Raspberry pi Zero - Analog audio input

Posted: Sat Jul 15, 2017 9:24 am
by ghellquist
A bit off topic. But a bit of facts. Admittedly a bit simplified.

Signal to noise rate is approximately 6 db per digital bit. The S/N then is the difference between the maximum signal and the "floor" of noise.
CD-s are 16 bits, giving approximately 96db of S/N.

There are no commercial audio converters available to buy (none, absolutely zero) giving more than 130 dB S/N. This will fit in less than 24 bits. So no need for 32 bits in the converter.

It is perfectly good to make recordings with a S/N of about 70 dB. After all, that is what old typ analog tape recorders gave, and there are a lot of LP-s from old times that we still like to listen to.

/Gunnar

Re: Raspberry pi Zero - Analog audio input

Posted: Sun Jul 16, 2017 10:34 am
by Burngate
flatmax wrote: ... The threshold of pain varies between people and some people may have a very high threshold.
For this reason, high quality audio requires 24 bits.
Matt
I'm not sure why the threshold of pain should be used as the top level.
Also, the perception of pain occurs after the sound has been converted to neural signals, and a lot of processing has happened in the route from the ear to the brain.

Deepest, darkest Berkshire, an owl hoots, and another answers from across the wood. I can hear both, so they're above my noise floor.
A Boeing 737 goes overhead on route to Heathrow. While that's happening, I can't hear either owl.
That's because, somewhere in my brain, there's an automatic level control operating.
I take that to mean I don't need 32, 24, or even 16 bits.

But then, I'm not sure why I enjoyed listening to Cream in their hay-day, or why that has anything to do with the tinnitus that means my noise floor is higher than average.