ShaBang
Posts: 1
Joined: Mon Jul 10, 2017 9:33 pm

Raspberry pi Zero - Analog audio input

Mon Jul 10, 2017 9:50 pm

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 ?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12418
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Raspberry pi Zero - Analog audio input

Mon Jul 10, 2017 10:09 pm

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.

drgeoff
Posts: 9932
Joined: Wed Jan 25, 2012 6:39 pm

Re: Raspberry pi Zero - Analog audio input

Tue Jul 11, 2017 11:50 am

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.

User avatar
Burngate
Posts: 6101
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Raspberry pi Zero - Analog audio input

Tue Jul 11, 2017 12:05 pm

Given that, according to its datasheet, the MCP3008 can run at 200ksp, it should be capable of sampling audio.

drgeoff
Posts: 9932
Joined: Wed Jan 25, 2012 6:39 pm

Re: Raspberry pi Zero - Analog audio input

Tue Jul 11, 2017 3:25 pm

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.)

User avatar
Burngate
Posts: 6101
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Raspberry pi Zero - Analog audio input

Tue Jul 11, 2017 6:11 pm

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"

User avatar
flatmax
Posts: 336
Joined: Thu May 26, 2016 10:36 pm

Re: Raspberry pi Zero - Analog audio input

Wed Jul 12, 2017 11:32 am

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
Check the Ultra 2 sound card - use our shop instead of Amazon Europe (Amazon USA is live).
Sound card for the Raspberry Pi with inbuilt microphone : www.audioinjector.net
Audio Inector Octo multitrack GPIO sound card

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12418
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Raspberry pi Zero - Analog audio input

Wed Jul 12, 2017 12:11 pm

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.

ghellquist
Posts: 68
Joined: Thu Aug 02, 2012 8:47 am
Location: Stockholm Sweden

Re: Raspberry pi Zero - Analog audio input

Sat Jul 15, 2017 9:24 am

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

User avatar
Burngate
Posts: 6101
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Raspberry pi Zero - Analog audio input

Sun Jul 16, 2017 10:34 am

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.

Return to “Advanced users”