Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Teensy 4.0 I2S (no Audio Shield) + 4 MEMS microphones - working only 2

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    5

    Teensy 4.0 I2S (no Audio Shield) + 4 MEMS microphones - working only 2

    Hi people,
    I am working on my first project with sound localisation feature (with azimuth and distance calculation) and stuck on peak detection of the I2S2 part of T4 while I2S1 working great (all mics are INMP441).
    When I connected all 4 mics and declare both I2S1 and I2S2 I am receiving no one mic are working with next plotting
    Click image for larger version. 

Name:	5764b0cb9dc80a2aa5bb757a168636a3.png 
Views:	4 
Size:	27.9 KB 
ID:	18658

    As soon as I am removing(commenting) declaring of one of I2S1 or I2S2 audio input I am receiving perfectly working but only for 2 mics, that connected to I2S1 (but no matter which one I am turning off!)
    Click image for larger version. 

Name:	9dca1859eb800e01f16fd62fe52aa2be.png 
Views:	11 
Size:	40.0 KB 
ID:	18659

    What I am doing wrong?
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    /*
     SD -> pin 8 (in1)/pin 5 (in2)
     L/R -> GND/VCC (left/right channel)
     WS -> pin 20 (LRCLK1)/pin 3 (LRCLK2)
     SCK -> pin21 (BCLK1)/pin 4 (BCLK2)
     */
    
    AudioInputI2S            i2s1; 
    AudioInputI2S            i2s2;
    
    AudioAnalyzePeak         peak_L1;
    AudioAnalyzePeak         peak_R1;
    AudioAnalyzePeak         peak_L2;
    AudioAnalyzePeak         peak_R2;
    
    AudioConnection          patchCord1(i2s1, 0, peak_L1, 0); //connect the Left mic to the Left peak detector
    AudioConnection          patchCord2(i2s1, 1, peak_R1, 0); //connect the Right mic to the Right peak detector
    
    
    AudioConnection          patchCord3(i2s2, 0, peak_L2, 0);//connect the Left mic to the Left peak detector
    AudioConnection          patchCord4(i2s2, 1, peak_R2, 0);//connect the Right mic to the Right peak detector
    
    
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(70);
    
    
      
    }
    
    elapsedMillis fps;
    void loop() {
      if (fps > 5) {
          fps = 0;
          float LeftPeak1 = peak_L1.read();//Return is from 0.0 to 1.0.
          float RightPeak1 = peak_R1.read();//Return is from 0.0 to 1.0.
        
          float LeftPeak2 = peak_L2.read();//Return is from 0.0 to 1.0.
          float RightPeak2 = peak_R2.read();//Return is from 0.0 to 1.0.
          
    
      Serial.print("L1: "); Serial.print(LeftPeak1 * 3000.0); Serial.print("  ");
      Serial.print("R1: "); Serial.print(-RightPeak1 * 3000.0); Serial.print("  ");
      Serial.print("L2: "); Serial.print(LeftPeak2 * 3000.0); Serial.print("  ");
      Serial.print("R2: "); Serial.print(-RightPeak2 * 3000.0); Serial.print("  ");
      
      Serial.println("");
    
    
      }
    }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,340
    Are you using 1.48 or the latest beta?

    https://forum.pjrc.com/threads/58817...no-1-49-Beta-4

    Some bugs with I2S2 were recently fixed, so best to use 1.49-beta4 if you're using I2S2.

  3. #3
    Junior Member
    Join Date
    Dec 2019
    Posts
    5
    Quote Originally Posted by PaulStoffregen View Post
    Are you using 1.48 or the latest beta?

    https://forum.pjrc.com/threads/58817...no-1-49-Beta-4

    Some bugs with I2S2 were recently fixed, so best to use 1.49-beta4 if you're using I2S2.
    OMG, I am using 1.48, thank you very much for pointing me on that!
    Just upddated to v1.49 and get same result - working only 2 mics attached to I2S1....

  4. #4
    Quote Originally Posted by GurKin View Post
    Hi people,
    What I am doing wrong?
    Code:
    AudioInputI2S            i2s1; 
    AudioInputI2S            i2s2;
    Is that ok? Shouldn't that be

    Code:
    AudioInputI2S            i2s1; 
    AudioInputI2S2            i2s2;

  5. #5
    I guess you could also use RX_DATA1 pin to input data using only single I2S interface, but then you had to enable the input pin and increase the frame size, and the audio library doesn't know anything about that as it expects only two channels, not four interleaved. Maybe that's what the AudioInputI2SQuad is supposed to do anyway when it's been implemented, and then also AudioInputI2SHex and AudioInputI2SOct variations are possible, though it would maybe be better if there were some generic implementation using some fancy constructor type parameter or plain number parameter giving the number of channels (AudioInputI2S(4) for an example, or AudioInputI2S(8CH) if you are using the types, enums or whatever).

  6. #6
    Junior Member
    Join Date
    Dec 2019
    Posts
    5
    Quote Originally Posted by mhelin View Post
    Code:
    AudioInputI2S            i2s1; 
    AudioInputI2S            i2s2;
    Is that ok? Shouldn't that be

    Code:
    AudioInputI2S            i2s1; 
    AudioInputI2S2            i2s2;
    Thank you so much!
    I got 3 mics working (and that is enough for now!)))


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •