Ben
Well-known member
Hello,
I am currently trying to explore the new Audio Library and I'm stuck with a problem I can't resolve myself.
I'm using a DC-object to feed a Peak-object (and a I2S-Output, which is currently commented out).
I control the DC over Serial, but when I do peak.read() it returns -1.0, no matter what value I set the DC-Source. In Addition, peak.available() never returns true.
This is the code:
Using Arduino 1.0.6 with Teensyduino 1.20 on Windows 7 and a Teensy 3.1 (from OSH-Park with purple (?) Solder Mask )
Can anyone reproduce the problem or is it me?
Ben
I am currently trying to explore the new Audio Library and I'm stuck with a problem I can't resolve myself.
I'm using a DC-object to feed a Peak-object (and a I2S-Output, which is currently commented out).
I control the DC over Serial, but when I do peak.read() it returns -1.0, no matter what value I set the DC-Source. In Addition, peak.available() never returns true.
This is the code:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioSynthWaveformDc dc1; //xy=354,281
AudioAnalyzePeak peak1; //xy=529,230
//AudioOutputI2S i2s1; //xy=531,283
//AudioConnection patchCord1(dc1, 0, i2s1, 0);
//AudioConnection patchCord2(dc1, 0, i2s1, 1);
AudioConnection patchCord3(dc1, peak1);
// GUItool: end automatically generated code
int serial_int;
float serial_float;
void setup(){
Serial.begin(9600);
Serial.setTimeout(20);
delay(5000); //Time to open Serial Monitor on Windows Systems
Serial.println("Enter any integer between -32768 and 32767.");
Serial.println("First valid integer in string is used. Rest is discarded.");
Serial.println("");
}
void loop(){
if (Serial.available()){
serial_int = Serial.parseInt();
while (Serial.available()) Serial.read();
serial_int = constrain(serial_int, -32768, 32767);
//constrain to 16 bit signed
serial_float = float(serial_int);
serial_float /= 32768.0;
Serial.print("New DC level: ");
Serial.println(serial_float);
dc1.amplitude(serial_float);
//even delay(100); here does not help
if (peak1.available()){
Serial.print("Readback value from peak1: ");
}
else{
Serial.print("peak1 does NOT return available == true and reads: ");
}
Serial.println(peak1.read());
Serial.println("");
}
delay(1);
}
Using Arduino 1.0.6 with Teensyduino 1.20 on Windows 7 and a Teensy 3.1 (from OSH-Park with purple (?) Solder Mask )
Can anyone reproduce the problem or is it me?
Ben