Read analog input value in Volts

Status
Not open for further replies.

mbneu

New member
Hello all,
I own an Euroshield mounting a Teensy 3.2 that works with Audio libraries. I am fairly new to Teensy programming and I need some help on a very basic task that apparently I can't figure out.

I would like to read the DC value in Volts from the two inputs of the board, ideally I would like to have a float value as when I am doing an analogRead(X) from a knob (but I guess for DC IN it would be between -1 and 1?) . I would like something similar to the following, but instead of using AudioAnalyzeRMS object, I'd like to use a different object that lets me .read() the current value, similarly to this:
Code:
AudioInputI2S            audioInput;
AudioAnalyzeRMS          input_1;
AudioAnalyzeRMS          input_2;
AudioConnection          patchCord1(audioInput, 0, input_1, 0);
AudioConnection          patchCord2(audioInput, 1, input_2, 0);

...

last_input_1 = input_1.read();
last_input_2 = input_2.read();

I would like to perform some modifications on the input value before sending it to output, treating it as a DC value (between -1 and 1) rather than audio level signals. I think this should be as easy as reading a knob value, but I really can't figure it out. Any suggestion or pointer to some reading material would be highly appreciated.

Thanks
 
Ah, those prominent caps must be decouplers then...
I think there is indeed a gap for a DC analysis object, AudioAnalyzePeak takes the absolute value, and of course
RMS cannot be negative.

Probably easy to knock one up, by adding a mean() method to AudioAnalyzePeak perhaps?

[ edit: yes, try the analyze_peak.h from this branch: https://github.com/MarkTillotson/Audio/tree/dc_average
it adds a readDcAverage() method to AudioAnalyzePeak ]

Note tha audio library doesn't deal in volts, its -1.0 to +1.0 full scale always.
 
Ah, those prominent caps must be decouplers then...
I think there is indeed a gap for a DC analysis object, AudioAnalyzePeak takes the absolute value, and of course
RMS cannot be negative.

Probably easy to knock one up, by adding a mean() method to AudioAnalyzePeak perhaps?

[ edit: yes, try the analyze_peak.h from this branch: https://github.com/MarkTillotson/Audio/tree/dc_average
it adds a readDcAverage() method to AudioAnalyzePeak ]

Note tha audio library doesn't deal in volts, its -1.0 to +1.0 full scale always.

Hey man, I can thank you enough for this.

I actually managed to do exactly what I wanted. Basically I read a CV in signal that I alter through some controlled randomness. Here is a pic depicting my output (yellow) compared to the input signal into audioIN2 on Euroshield (blue) while simultaneously altering the scale of noise:
Schermata 2021-03-02 alle 22.18.00.png

EDIT: btw yes, the value is using .readDcAverage() between -1 and 1.


You just fixed something it would have taken me ages to figure out. If I can buy you a beer or something for this, I'd be happy to! :D
 
Status
Not open for further replies.
Back
Top