Hi yall, I'm working on a project implementing a novel approach to MIDI note extraction from mono and polyphonic audio signals (mostly electric guitar). I ordered a Teensy 4.0 with pins and Audio shield and soldered the board to the shield. I uploaded my test script via platformio running on top of vscode. The script is a heavily based on the example code for the Teensy AudioAnalyzeNoteFrequency class found here https://github.com/PaulStoffregen/A...ples/Analysis/NoteFrequency/NoteFrequency.ino (the unmodified example script also fails, but simply produces no output, while my modified version hopefully provides some insight into whats going on)
The script is as follows: main.cpp
I expected to recieve a note output in hz along with a probability from the Audio.h implementation of the YIN algorithm, but it seems that notefreq.available() is always false.
Instead, the program produces the following output:
SERIAL STARTED
NOTE[0]: 8100cbd8
PLAY STATUS: PLAYING
SETUP END
loop started
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
... it then continues the previous line ad-infinitum
The fact that the CPU and Audio processor usage are at 0% causes me to suspect that there is some issue in the communication between the teensy and the audio shield dsp chip but frankly I have no idea whats going on.
Any help would be greatly appreciated
The script is as follows: main.cpp
Code:
#include <SerialFlash.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//---------------------------------------------------------------------------------------
#include "guitar_e2_note.h"
//---------------------------------------------------------------------------------------
AudioAnalyzeNoteFrequency notefreq;
AudioOutputAnalog dac;
AudioPlayMemory wav_note;
AudioMixer4 mixer;
//---------------------------------------------------------------------------------------
AudioConnection patchCord0(wav_note, 0, mixer, 0);
AudioConnection patchCord1(mixer, 0, notefreq, 0);
AudioConnection patchCord2(mixer, 0, dac, 0);
//---------------------------------------------------------------------------------------
IntervalTimer playNoteTimer;
bool playStarted = false;
void playNote(void)
{
if (!wav_note.isPlaying())
{
wav_note.play(guitar_e2_note);
playStarted = true;
digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
}
}
//---------------------------------------------------------------------------------------
void setup()
{
Serial.begin(9600);
Serial.println("SERIAL STARTED");
Serial.print("NOTE[0]:\t");
Serial.printf("%x", guitar_e2_note[0]);
Serial.print("\n");
AudioMemory(30);
/*
* Initialize the yin algorithm's absolute
* threshold, this is good number.
*/
notefreq.begin(.15);
pinMode(LED_BUILTIN, OUTPUT);
// Audio library isr allways gets priority
playNoteTimer.priority(144);
playNoteTimer.begin(playNote, 1000);
Serial.print("PLAY STATUS: "); Serial.print(playStarted?"NOT PLAYING\n":"PLAYING\n");
Serial.println("SETUP END");
}
int c = 0;
void loop()
{
if(c == 0){
Serial.println("loop started");
}
Serial.flush();
c++;
if(c%10000000 == 0){
Serial.print("CPU=");
Serial.print(AudioProcessorUsage());
Serial.print("%, max=");
Serial.print(AudioProcessorUsageMax());
Serial.print("%\n");
}
//read back fundamental frequency
if (notefreq.available())
{
float note = notefreq.read();
float prob = notefreq.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
}
Instead, the program produces the following output:
SERIAL STARTED
NOTE[0]: 8100cbd8
PLAY STATUS: PLAYING
SETUP END
loop started
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
CPU=0.00%, max=0.00%
... it then continues the previous line ad-infinitum
The fact that the CPU and Audio processor usage are at 0% causes me to suspect that there is some issue in the communication between the teensy and the audio shield dsp chip but frankly I have no idea whats going on.
Any help would be greatly appreciated
Last edited by a moderator: