Minimal Config and Code Audio Board+Teensy 3.1+Microphone input for FFT


New member

I want to have led strings (driven by a modified OctoWS2811) react to sound coming from an Electret Microphone. I'd be using the Audio board to process the audio and so far I don't seem to be able to get it to work.
1) Can I connect an electret microphone directly to the Mic input (and gnd) of the audio board? Do I need a preamp?
2) What are the pins that I must absolutely connect to the teensy? I was thinking of connecting 3.3V, GND, and pins 18,19 (the I2C connection). If I only want to get the FFT results from the MIC input, do I need to connect other pins (like the 5 pins I2S bus which would run into conflict with pins used by OctoWS2811)?
3) Is it possible to have an automatic gain on the mic input?


1) pending type of electret mic answer is yes.

2) If you want to perform FFT you need to connect all but one of the I2S bus pins - you could leave the I2S data from Teensy to Audio Adapter unconnected but I2S data from Audio Adapter to Teensy will be required so Teensy can get data to perform FFT against; the other three pins in the I2S bus are clocks and without each and every one of them there is no I2S bus.

3) Yes.

I am working from memory, been doing lots of other stuff so unrelated lately, so I could be wrong about #1 and #3 (tho I doubt it) but I am pretty sure about #2 there.
Thank you!

1) I have confirmed that an electret microphone directly connected to the audio adaptor board does work. Used on of the example sketches to confirm that.
2) Confirmed also. Once I connected the I2S bus it worked.
3) I have not found how to do automatic gain on the microphone yet.

Since the I2S bus conflicts with the pins used for led strips 5-8 in the Octows2811, it seems impossible to use audio input and octows at the same time. That seems to be also true even when using the latest octows library which seemed to have been modified to make it work. But couldn't make it work. (I only have 4 led strips so not using 5-8 would have been ok for me).

I stopped using the octows library and rewrote my sketch to use FastLed instead (with 4 strips, still using the Octows2811 hardware) and the audio input and that does work, I can receive audio from the microphone and do FFT on it.

One thing I don't understand is that even though I only need audio input and to connect it to FFT, it seems that if I remove the declarations (and connections) for audio output, the input no longer works.

That is, if my declarations are like this:
AudioInputI2S audioInput; // audio shield: mic or line-in
AudioAnalyzeFFT256 myFFT(20);
AudioOutputI2S audioOutput; // audio shield: headphones & line-out

// Create Audio connections between the components
AudioConnection c1(audioInput, 0, audioOutput, 0);
AudioConnection c2(audioInput, 0, myFFT, 0);
AudioConnection c3(audioInput, 1, audioOutput, 1);

... Every thing works.

If they are like that:
AudioInputI2S audioInput; // audio shield: mic or line-in
AudioAnalyzeFFT256 myFFT(20);

// Create Audio connections between the components
AudioConnection c2(audioInput, 0, myFFT, 0);

the FFT always returns all zeros. I don't understand why.

The output object(s) do everything required for I2S and the input object(s) don't - to the best of my memory, sorry I am not looking through the code right now and haven't touched much to do with any of it for a while now; tho I remember some calls to the output objects from the input objects I seem to recall that not enough is done for inputs alone to work. I guess it is a reasonable expectation of most projects that where an input will be called for an output is usually going to be required as well.

Take a look through and find "unsigned short AudioControlSGTL5000::autoVolumeControl(uint8_t maxGain, uint8_t lbiResponse, uint8_t hardLimit, float threshold, float attack, float decay)" - there is information above that line as to how it works, you may need to find 'route(..);' in there and make sure that the data is being routed in an appropriate order to have the effect of autoVolumeControl applied before transmission of audio data from Audio Adapter to Teensy. Probably worth your while (or poss even necessary) to look at the file as well.

Taking a quick squiz at it and thinking about you using the microphone makes me think I should revisit it and add some more controls for the microphone input - without anybody prompting me to do so sooner that could be a while.