AudioAnalyzeFFT1024.available() returns false

Status
Not open for further replies.

Davidelvig

Well-known member
I've seen this from time to time in my app - and have rearranged code... related to timing and delays...
It has subsequently returned true.

Now it's persistently false, again, and I can't see why.

The code is long, and I could try to simplify, but...
1) What is (available() = false) telling me literally?
2) How are collisions (or overlaps) handled between interrupt-driven-FFT-bin-filling and concommittant calls to AudioAnalyzeFFT1024.read()?

Thanks for your help!

Dave
 
Last edited:
Stripped-down code added...

I need FFT for pitch detection, and I need another analog sensor.

This code demonstrates FFT success and failure, just by moving the declaration of the ADC above or below the Audio... object declarations.

What's the reasoning?
Thanks for any help you can provide!

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

//ADC *adc = new ADC();                    //LOCATION 1 - succeeds when the *adc is declared here

AudioInputAnalog         audioInput(A4); 
AudioAnalyzeFFT1024      myFFT;
AudioConnection          patchCord1(audioInput, 0, myFFT, 0);

ADC *adc = new ADC();                      //LOCATION 2 - fails when the *adc is declared here

void setup() { 
  Serial.begin(115520);
  AudioMemory(12);
  myFFT.windowFunction(AudioWindowHanning1024);
  delay(1000);
}

void loop() {
  if (myFFT.available()) { Serial.println("SUCCESS - FFT available when *adc declared before Audio... objects");           }
  else                   { Serial.println("failure - FFT not available when *adc declared after Audio... objects");}
  delay(1000);
}
 
By the way, my use of the ADC object takes into account that the Audio library heavily uses ADC_0, so when I use the ADC object, I specify ACD_1, as in
Code:
long wind = adc->analogRead(WIND_PIN, ADC_1);
 
I can't say for sure without the code for both libraries in front of me, but I'd guess that the ADC library constructor is changing the settings for both ADC0 and ADC1, which is interfering with the correct operation of the audio library ADC code.

I just took a look at the ADC library code, and it looks like the constructor does change settings for both ADC0 and 1.

I think that the Audio library code is hard-coded to use ADC0, so you can probably get away with defining the ADC library first (ie, "LOCATION 1"), and only using the ADC library for ADC1, and never for ADC0 (it probably won't work because the settings aren't correct for the ADC library).
 
I couldn't get your code to compile. It was complaining that it couldn't find SerialFlash.h. I hadn't installed it but it would appear that the audio library refers to it even though it's not a part of that library.
I installed it and restarted the IDE and it still complained that it couldn't find it. I added an include at the front of the file and then it compiled.

Then I tested the code and it works (SUCCESS etc.) with the ADC declared in either position. I'm using Arduino 1.6.5 with the latest Teensyduino and audio library + SerialFlash libraries.

Pete
 
Struggling a bit...
Downloaded newest Arduino (Version.txt says: 1.6.5-r5)
Downloaded and ran Teensyduino - "Next button" never lights up... saying I do not have a supported version.
Any advice on installation?

Dave
 
I'm getting this in the TeensyDuino installer's "?" dialog
Code:
Directory: /Applications/Arduino/Arduino.app/
  Checking Arduino 1.0.6:
    version: "Contents/Resources/Java/lib/version.txt"  file missing
    Does not match Arduino 1.0.6
  Checking Arduino 1.6.1-j7:
    version: "Contents/Java/lib/version.txt"  wrong version: 1.6.5    Does not match Arduino 1.6.1-j7
  Checking Arduino 1.6.1:
    version: "Contents/Resources/Java/lib/version.txt"  file missing
    Does not match Arduino 1.6.1
  Checking Arduino 1.6.3:
    version: "Contents/Java/lib/version.txt"  wrong version: 1.6.5    Does not match Arduino 1.6.3
  Checking Arduino 1.6.4:
    version: "Contents/Java/lib/version.txt"  wrong version: 1.6.5    Does not match Arduino 1.6.4
  Checking Arduino 1.6.5:
    version: "Contents/Java/lib/version.txt"  version matches
    file: "Contents/MacOS/Arduino"  present
    file: "Contents/Info.plist"  present
    file: "Contents/Java/jssc-2.8.0.jar"  present
    java: "Contents/Java/pde.jar" object: "processing/app/Base.class" checksum match
    java: "Contents/Java/pde.jar" object: "processing/app/Editor.class" checksum match
    java: "Contents/Java/pde.jar" object: "processing/app/Sketch.class" checksum match
    java: "Contents/Java/arduino-core.jar" object: "processing/app/BaseNoGui.class" checksum mismatch, unsupported Arduino version
    Does not match Arduino 1.6.5
 
Fixed with latest Arduino installation (1.6.5) plus the latest beta release of Teensyduino (Aug 28, 2015 datestamp - Teeny Loader says 1.25-beta2).
Back in business.
Of note, the main Teensyduino web page points to the general release V1.24.
I found the reference to the Beta in other forum threads.
 
Whenever Arduino publishes a new release, I usually have a beta version out within a day. I usually allow 2 weeks before finalizing it into a full Teensyduino release.
 
Status
Not open for further replies.
Back
Top