Audiolib RMS/PEAK value range

Status
Not open for further replies.

DIYLAB

Well-known member
Hello everyone,

with the AudioLib I get a value range from 0.0 to 1.0 for PEAK and RMS - ok.
But I need the range -1.0 to 1.0.
How do I get this range?

Thanks,
Bruno
 
Hello everyone,

with the AudioLib I get a value range from 0.0 to 1.0 for PEAK and RMS - ok.
But I need the range -1.0 to 1.0.
How do I get this range?

Thanks,
Bruno
RMS is by definition non-negative.

The AudioAnalyzePeak class has read() and readPeakToPeak() methods - however read returns the maximum of
the two polarities of peak, so you can't distinquish a (-0.3..+0.8) signal from a (-0.8..+0.3) signal as they both
return 0.7 peak and 1.1 p2p.

You'd need a modified version of AudioAnalyzePeak for this I think.
 
RMS is by definition non-negative.
You'd need a modified version of AudioAnalyzePeak for this I think.

I think so too.
I need the negative values for a correlation display and a goniometer.
As a desktop version in C# and NAudio it works fine, but the implementation for the Teensy gives me difficulties.

Unfortunately I wouldn't know how to modify or better extend the AudioAnalyzePeak in my project. Because the original should already remain unchanged.
 
I think so too.
I need the negative values for a correlation display and a goniometer.
As a desktop version in C# and NAudio it works fine, but the implementation for the Teensy gives me difficulties.

Unfortunately I wouldn't know how to modify or better extend the AudioAnalyzePeak in my project. Because the original should already remain unchanged.

Well the existing read() method in Audio/analyze_peak.h is:
Code:
	float read(void) {
		__disable_irq();
		int min = min_sample;
		int max = max_sample;
		min_sample = 32767;
		max_sample = -32768;
		__enable_irq();
		min = abs(min);
		max = abs(max);
		if (min > max) max = min;
		return (float)max / 32767.0f;
	}
You could add two similar methods called readMax and readMin I'm sure...
 
Well the existing read() method in Audio/analyze_peak.h is:
You could add two similar methods called readMax and readMin I'm sure...

Of course I can, but then I change the original files and the changes are lost with every Teensyduino update.
How could I implement the additional methods in my own project?
 
Create a pull-request from the Audio lib repo?

I can do this if you like, I'm all setup.
 
Status
Not open for further replies.
Back
Top