PDA

View Full Version : peak and rms Audio Objects



Davidelvig
01-26-2016, 03:21 AM
I've added these to my project, and am getting some strange behavior.

"peak" works, and returns appropriate available() and read(), but the compiler chokes on readPeakToPeak().
"rms" causes a compiler failure on declaration of the AudioAnalyzeRMS object.
I have Arduino 1.6.6 and Teensyduino 1.27
I updated from 1.26 to 1.27 to try to address this.

See attached code:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S Mic; //xy=79,135
AudioAnalyzePeak PEAK; //xy=236,154
AudioAnalyzeRMS RMS; //xy=239,191
AudioConnection patchCord1(Mic, 0, PEAK, 0);
AudioConnection patchCord2(Mic, 0, RMS, 0);
AudioControlSGTL5000 TeensyCodec; //xy=100,80
// GUItool: end automatically generated code


void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

if (PEAK.available()) {
float p = PEAK.read();
p = PEAK.readPeakToPeak();
}
if (RMS.available()) {
float r = RMS.read();
}
}

Compile of the above gets: 'RMS' was not declared in this scope
Removing the RMS-related code gets
'class AudioAnalyzePeak' has no member named readPeakToPeak

Any ideas?

PaulStoffregen
01-26-2016, 07:09 AM
The AudioAnalyzeRMS object was added recently, after 1.27. You'll need to use the very latest Audio lib from github.

fms1961
01-26-2016, 10:42 AM
I'm afraid we must re-organize our comunication concerning the Audio Library and try to react ASAP, even there is a lack of time. As I like to contribute some work on the GUI, we have to be sure that the underlying base is always synchronized. But as I had posed some questions and proposed some points to discuss, I'm a little astonished that new nodes are defined and functions are added/changed without a remarkeable hint. Perhaps I missed the GitHub notifications, so this is my own fault (and please don't misunderstand my posting - I'm not complaining!) but it would be nice, that, when questions are asked, one receives an answer on that in a reasonable time. Maybe this problem occurs because here in the forum there is no OT policy, so the threads are bouncing between several themes/points and bacause of this there's a lot of "noise", and some posed questions will scroll into nowhere ... So again: this is no complaint, but a proposal to tighten the conversation on development topics in dedicated threads, where - if possible - OT posts will bie moved to an appropriate thread. For my point of view, I've lost the clear view over the big picture, and I'm waiting for responses after I coded a tool which pulls the node definitions out of the cpp files ... no idea if this is wished, helpful or just unuseable.

PaulStoffregen
01-26-2016, 05:12 PM
Yeah, more objects/nodes are going to be added on a pretty regular basis, for at least the next year or two. The general idea is for only index.html to get edits, as the library grows. The rest of the javascript code isn't supposed to change as we add to the library.

Davidelvig
01-27-2016, 05:27 AM
It makes sense. So the GUI design tool is in synch with the latest Github version of the Audio library, but that code has not reached the Teensyduino build.
I'll download the audio lib from github and do my best to install it... Using the library manager functions within the Arduino IDE, I presume.
Thanks for the responses. I'm looking forward to trying out these objects.
If there's a way I can help with 'the process' let me know.

PaulStoffregen
01-27-2016, 01:05 PM
So the GUI design tool is in synch with the latest Github version of the Audio library, but that code has not reached the Teensyduino build.


Correct.

I try to release a new version of Teensyduino on a 3-4 month schedule. Since 1.27 was released on Jan 5, that means we're due for 1.28 around April to May.

However, I'm considering an early 1.28 release, if I get MTP working before April....



I'll download the audio lib from github and do my best to install it...
If there's a way I can help with 'the process' let me know.

The simplest way is to put it into Documents/Arduino/libraries. Make sure the folder name is "Audio". Delete the "-master" suffix if you download and extract the zip file from Github.

When you put a library in Documents/Arduino/libraries, it will always override any other libs. That's both blessing and a curse. It lets you get the results you want quickly. But in months or years from now, after you've installed newer versions of Teensyduino, this copy will still override whatever comes with the newer versions. Arduino will print a message about multiple copies of libraries, saying which one it used and which one it ignored. That's meant to remind you 2 copies exist.

Davidelvig
01-28-2016, 10:51 PM
Added the GitHub version of the Audio Library to my to .../Documents/Arduino/libraries
Change my Arduino Preferences\Sketchbook location to .../Documents/Arduino

All is well... after I cleaned up by moving another library there that I had placed in a non-standard location.

Compiling and code-highlighting works.
Thanks, Paul!