Curious Audio Library Behavior

Status
Not open for further replies.

tenkai

Well-known member
so this is not quite a problem, but more of a curiosity...
when I run the code below, it works fine, and will print out what frequency is being analyzed.

The curiosity is when I delete the AudioOutputAnaloc dac; line, it no longer prints out the frequencies (noteFreq.available() is never true)...

Is this a bug, or expected behavior?

Code:
#include <Audio.h>
#include <SPI.h>
#include <Wire.h>


AudioOutputAnalog             dac;
AudioSynthWaveformSine        sine;
AudioAnalyzeNoteFrequency     notefreq;
AudioConnection               patchCord1(sine, 0, notefreq, 0);


void setup() {
  AudioMemory(30);
  sine.amplitude(1.0);
  sine.frequency(2000);
  notefreq.begin(.15);

  Serial.begin(9600);

  pinMode(13, OUTPUT);

}

void loop() {
  digitalWrite(13, HIGH);
  delay(100);
  digitalWrite(13, LOW);
  delay(100);
  Serial.println(String( millis() ) + "\t");

  if (notefreq.available()) {
    float note = notefreq.read();
    float prob = notefreq.probability();
    Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
  }

}
 
not a bug per se, you need at least one object that calls the update_all function. This uses the PDB interrupt for setting up the sampling usually for hardware peripherals, all the other objects you have don't setup the pdb so nothing is happening. I'm sure there is more to it than that with all the dma stuff but thats how i see it.

I think it would be nice to have a generic pdb object when you just want to use the Audio library analysis objects when no hardware is needed.
 
Ah that makes total sense. I need to dive into those audio headers and get to know em a bit better.
 
Status
Not open for further replies.
Back
Top