Teensy 3.2 (with audio shield) PlaySDWav > Notefreq issues

Status
Not open for further replies.

meech

Member
Hi, I am working on a project that will read the output (note frequency) from the pickup of an electric guitar, compare it with the note frequency of a pre-recorded song on the miniSD card, and compare whether the frequencies are close...

My issue is that i am unable to read the note frequency from the SD WAV, but I can hear the song play through the 3.5mm jack on the shield. Am I missing something or is it impossible to read the frequency from a WAV file?

Also for reading the signal from the guitar I read that I need to connect to Pin A2 (adc). I have measured the voltage from the guitar and it ranges from -1V to 1V... Should I build an op-amp to tune the voltage down (I don't want to fry my board), or is this a safe number?

Thanks
-Mitch
Code:
#include <SerialFlash.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//---------------------------------------------------------------------------------------
AudioOutputI2S           audioOutput;
AudioControlSGTL5000     sgtl5000_1;

AudioAnalyzeNoteFrequency notefreq;
AudioOutputAnalog         dac;
AudioPlaySdWav           playSdWav1;
AudioMixer4               mixer;
//---------------------------------------------------------------------------------------
AudioConnection patchCord0(playSdWav1, 0, mixer, 0);
AudioConnection patchCord1(mixer, 0, notefreq, 0);
AudioConnection patchCord2(mixer, 0, dac, 0);
AudioConnection          patchCord3(playSdWav1, 0, audioOutput, 0);
AudioConnection          patchCord4(playSdWav1, 1, audioOutput, 1);


// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14
//------------------------------

void setup() {
  Serial.begin(9600);
  AudioMemory(8);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.45);
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
  pinMode(13, OUTPUT); // LED on pin 13
    notefreq.begin(.15);
    pinMode(LED_BUILTIN, OUTPUT);  
}

void loop() {
    if (playSdWav1.isPlaying() == false) {
      Serial.println("Start playing");
      playSdWav1.play("lowE.WAV");
      delay(10); // wait for library to parse WAV info
      digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
    }
    if (notefreq.available()) {//notefreq is never available
        delay(25);
        float note = notefreq.read();
        float prob = notefreq.probability();
        Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
    }
}
 
Last edited:
Status
Not open for further replies.
Back
Top