I am having an issue with reading the frequency of two different inputs in my code.
(live guitar input into adc1, recorded guitar track input from the usb)
When I initiate my code, the notefreq2 item will read my guitars note with great accuracy. However, when I play the guitar track from my computer through USB the teensy3.2 won't read it, and stops reading my guitar as well .
It doesn't matter whether I have played the guitar before the usb input or not, once the usb recieves a signal my code dies.
If i comment out one of the notefreq.begin(.15)'s then the other analyzer works perfectly how I want it to work. This goes for the usb notefreq analyzer, and the guitar notefreq analyzer.
It is only when both notefreq variables have been "Begun" that I encounter issues.
If anybody could help me with reading both frequencies at the same time it would be very appreciated.
(this is the diagram of how everything is wired up)
(live guitar input into adc1, recorded guitar track input from the usb)
When I initiate my code, the notefreq2 item will read my guitars note with great accuracy. However, when I play the guitar track from my computer through USB the teensy3.2 won't read it, and stops reading my guitar as well .
It doesn't matter whether I have played the guitar before the usb input or not, once the usb recieves a signal my code dies.
If i comment out one of the notefreq.begin(.15)'s then the other analyzer works perfectly how I want it to work. This goes for the usb notefreq analyzer, and the guitar notefreq analyzer.
It is only when both notefreq variables have been "Begun" that I encounter issues.
If anybody could help me with reading both frequencies at the same time it would be very appreciated.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputUSB usb1; //xy=116,100
AudioInputAnalog adc1; //xy=239,220
AudioMixer4 mixer1; //xy=267,115
AudioMixer4 mixer2; //xy=414,210
AudioAnalyzeNoteFrequency notefreq2; //xy=416,265
AudioAnalyzeNoteFrequency notefreq1; //xy=419,64
AudioOutputAnalog dac1; //xy=585,210
AudioConnection patchCord1(usb1, 0, mixer1, 0);
AudioConnection patchCord2(usb1, 1, mixer1, 1);
AudioConnection patchCord3(adc1, notefreq2);
AudioConnection patchCord4(adc1, 0, mixer2, 1);
AudioConnection patchCord5(mixer1, notefreq1);
AudioConnection patchCord6(mixer1, 0, mixer2, 0);
AudioConnection patchCord7(mixer2, dac1);
// GUItool: end automatically generated code
void setup() {
// put your setup code here, to run once:
AudioMemory(30);
notefreq1.begin(.15);//---If one of these two are commented out
notefreq2.begin(.15);//---The other one works fine
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (notefreq1.available()) {
float note = notefreq1.read();
float prob = notefreq1.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
if (notefreq2.available()) {
float note = notefreq2.read();
float prob = notefreq2.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
}
(this is the diagram of how everything is wired up)