audio input on Teensy 4.1

dragoncat

New member
I have a very basic question. I want to start by taking audio input and simply directing it to the audio output. I'm going to do more with it later but that's my starting point. I know that the output works. I have my speaker connected to pin 10 on the Teensy 4.1 and I am using this sample program to generate tonesweeps, etc: https://github.com/TeensyUser/doc/wiki/Audio-Example-using-MQS-on-Teensy-4.0-or-4.1

What I did was to define adc1 on https://www.pjrc.com/teensy/gui/index.html and then attach a patch cord to the mixer and the mixer is defined and connected to the output in the same way as the first example. Then I added that code to the first example, renumbering things to avoid duplications and to make sure it compiles.

My problem is that:

1. I don't know which pin to use for the audio input
2. If I connect adc1 directly to print, nothing happens (shouldn't that give me some serial output, even if nothing is connected to adc1 and the input is all zeros?).

I have searched online for the Teensy 4.1 pinout and I get all sorts of conflicting information.

My questions are:

Can someone please tell me which pin on the Teensy 4.1 to use for audio input?

Is it possible for anyone to provide a very simple example of audio input combined with print or any of the other tools in the "analyse" section (none of them seem to work for me)?

Please assume that I am new to this and I don't know anything about the Teensy (though I am somewhat experienced with coding in C and in real time programming), so no big words or complicated theory, please. Just an example or two to get me started would be super helpful, and please tell me which pin I can use for the audio input.

Thanks.
 
Thanks for your reply. I have now tried that pin but no luck. Reading the info, I think that might just be for Teensy 4 not 4.1. The two are very different so it is unlikely that it would happen to be the same pin.

I would like to know how to test it, so if anyone has some code with which I can do that, I could try all the possible pins for audio input and see which one works.

Thanks again.
 
The first thing is to condition the audio signal so that information about its behavior is not lost. This circuit to condition the audio signal on pin A2 of your teensy is a good start.

u4QxCso.png


Try this code:
Code:
#include <Audio.h>

AudioInputAnalog         adc1;   //    A2 pin teensy 4.1 
AudioAnalyzeFFT1024      fft1024_2;
AudioOutputI2S           i2s1;
AudioConnection          patchCord3(adc1, fft1024_2);

//#include <GDSTx.h>    //for testing with the TFT NHD FT813 5"

#define NUM_BINS 380
double Datos[NUM_BINS];

void setup()
{
  Serial.begin(9600);
  //GD.begin();            //for testing with the TFT NHD FT813 5"

  analogReadAveraging(4);
  AudioMemory(30);
  fft1024_2.windowFunction(AudioWindowWelch1024);
 
}

void loop()
{
  if (fft1024_2.available())
  {
    for (int i=0; i < NUM_BINS; i=i+1)
    {
      Datos[i] = fft1024_2.read(i)*10000;
      if (Datos[i]<=0){Datos[i]=0;}
      Serial.println(Datos[i]);
    }

  }
}
 
Back
Top