AudioInputAnalogStereo, can it be paused to sample another analog port

Status
Not open for further replies.

Mike85

Member
Hi, I have a project using AudioInputAnalogStereo which is working just fine. However, it would be really useful if I could stop it sampling the ADC cores just long enough to read another analog port. I only need to sample once a minute then return to sampling the audio. It's to monitor a battery. Can this be done?
Thanks.
 
Hi, I have a project using AudioInputAnalogStereo which is working just fine. However, it would be really useful if I could stop it sampling the ADC cores just long enough to read another analog port. I only need to sample once a minute then return to sampling the audio. It's to monitor a battery. Can this be done?
Thanks.

I think I can sort of answer my own question. I use A3 and A6 for the AudioInputAnalogStereo. It would seem (from other threads) that A6 is assigned to ADC0 and A3 can be either ADC0 or ADC1 but by default is assigned to ADC0. I'm using A10 to monitor the battery which can also be ADC0 or ADC1 and it too defaults to ADC0. So, the solutions to my problem are 1. Move my battery monitor to another analog input (A15 - A20) or 2. configure A10 to use ADC1.

Option 1. is relatively easy and I'll try that later today, option 2. probably involves changing a bit in one or more registers somewhere which leads me to the question :-

Does anyone know how to change the assignment of analog inputs that can be either ADC0 or ADC1?

Meanwhile it's off to the K20 manual (I'm using a 3.2 BTW)..

Thanks.
 
...

Does anyone know how to change the assignment of analog inputs that can be either ADC0 or ADC1?

Meanwhile it's off to the K20 manual (I'm using a 3.2 BTW)..

Thanks.

yes it's something like:

AudioInputAnalog adc1(A3);

Are you trying to get around the fact you can't use AnalogRead at the same time as AudioInput?

If I've had this thought, if AudioInputAnalog had a pause or off function, or a bool switch to allow flipping back and fourth between AnalogRead and AudioInputAnalog, that may help the situation.

Then you could do something like this and not crash your program:

adc1.Pause(true);
int intFace = (int)analogRead(readSomething)
adc1.Pause(false);
 
I doubt that this will work. The analogRead function risks to reconfigure the ADC in a way (i.e. averaging, reference voltage, conversion speed) that it could be useless for the audio library after adc1.pause(false). The state of the art solution with much better audio quality would be using an external audio stereo ADC, connected via the Teensy’s I2S input. So, the internal ADCs would be free for administrative tasks.
 
I doubt that this will work. The analogRead function risks to reconfigure the ADC in a way (i.e. averaging, reference voltage, conversion speed) that it could be useless for the audio library after adc1.pause(false). The state of the art solution with much better audio quality would be using an external audio stereo ADC, connected via the Teensy’s I2S input. So, the internal ADCs would be free for administrative tasks.

Ahh thank you sir for you post, that's that idea out of the window!

An external stereo i2c adc chip sounds like a great solution.

Found this 16bit adc: https://www.adafruit.com/product/1085

This may be a dumb question, is there going to be any problem using a 16bit adc and outputting via 12bit dac?
 
Last edited:
That adafruit ADC has an I2C bus, not and I2S bus and will be too slow for digital audio processing. Why not use the audio shield from PJRC which provides 16bit audio inputs and outputs?
 
That adafruit ADC has an I2C bus, not and I2S bus and will be too slow for digital audio processing. Why not use the audio shield from PJRC which provides 16bit audio inputs and outputs?

Ahh thanks for clarifying, must have picked up mis-info from seeing people mention i2c and i2s seemingly interchangeably. Or maybe because the wording seems so similar:

"Integrated Inter-IC Sound Bus" and "Inter-Integrated Circuit"!!

Both made by Phillips, kudos to them!!

I do have (as of today) multiple audio shields, the one I've been using thus far, before getting the 3.6, was stupidly soldered straight to a 3.2, no easy interchange when the .6 arrived. So I'd just explored to see if I can get a jump on the next stage by running the same code on the 3.6 without the audio shield, albeit at a reduced bit rate, but alas I found the hidden perils of trying to read a pot and get an adc listening to an audio stream at the same time!

I'm always keen to find drawbacks and limitations and figuring out how to deal with or work around those limitations.

To the ada adc, I had a suspicion it wouldn't be great for sampling audio after reading it was capable of a whopping 860 samples per second! vs audio's 44.1k might be horrible or might have that super lofi sound everyone's looking for today :D

After a load of reading last night one solution seemed to use this Pedvide ADC library: https://github.com/pedvide/ADC, but having not tested it yet or read more than a few pages of forum posts I'm yet to figure out if it could be a viable solution to the analogRead blocking problem. One post about merging audio lib and Pedvide's seemed optimistic that it's possible.

I tested the code from exactly the same synth on 3.2 with audio shield and 3.6 with no a/s, I actually preferred (and not just me, I did a test with others as well) the 12bit 3.6 sound, seems fatter, more character. I wanted to carry on the experiment and see how the sound of a looper would differ, I predict there would be a similar effect and would similarly crunchify the sound in a pleasant way.
 
so Integrated Inter-IC is actually:

Integrated Inter-Integrated-Circuit vs Inter-Integrated Circuit

Makes loads of sense now :rolleyes:
 
Status
Not open for further replies.
Back
Top