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

Thread: 3.6 - Cannot use more than one AudioInputAnalog

  1. #1

    3.6 - Cannot use more than one AudioInputAnalog

    Hello,

    I try to have a simple led heartbeat but it stops working as soon as I use more than one AudioInputAnalog in my sketch

    there are like 20 ADC on the teensy, how can I use them all ? is it not possible ?

    I just found out AudioInputAnalogStereo , but its only 2 channels, what if you want to do an autio mixer with the teensy ? 20 mono channels or 10 stereo channels ?

    regards


    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc2(A5);       
    //AudioInputAnalog         adc1(A4);     // uncommenting this line seem to crash the program  
    AudioMixer4              mixer1;         
    AudioAmplifier           amp1;           
    AudioOutputAnalog        dac0;      
    //AudioConnection          patchCord1(adc2, 0, mixer1, 1);
    //AudioConnection          patchCord2(adc1, 0, mixer1, 0);
    AudioConnection          patchCord3(mixer1, amp1);
    AudioConnection          patchCord4(amp1, dac0);
    // GUItool: end automatically generated code
    //---------------------------------------------------------------------------
    
    #define LED_PIN 13
    
    unsigned long long heartbeat=0;
    
    void setup() {
      pinMode(LED_PIN, OUTPUT);
    }
    
    void loop() {
      
      if(heartbeat==0)
      {
        digitalWrite(LED_PIN, HIGH);   // set the LED on
      }
      else if(heartbeat==480000)
      {
        digitalWrite(LED_PIN, LOW);    // set the LED off
      }
    
      heartbeat++;
      if(heartbeat>=960000)
      {
        heartbeat=0;
      }  
    }

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,997
    There are only 2 ADCs in the Teensy. These have a multiplexer each which allows to “read” different pins, not at the same sime but one after the other.
    The rest is programming technique.
    The AudioInputAnalog object in the Audio library is coded in a way to sample one audio channel from one specific pin.
    The AudioInputAnalogStereo object is coded to make simultaneous use of both ADCs to sample stereo audio (2 channels) from 2 specific pins.
    More audio channels are technically possible, but with restrictions. You’d have to extend the existing AudioInputAnalog objet to sample 2, 3, or 4 channels consecutively, thus working with a 2,3, or 4 times higher sample rate and quick pin switching in-between the sampling.

  3. #3
    ok, but so far, only the first pin is working

    AudioInputAnalogStereo(A4,A5); -> only A4 signal appears in the end on the dac

    AudioInputAnalogStereo(A5,A4); -> only A5 signal appears in the end on the dac

    I think I found a bug...if I inject autio in A3, it gets to the dac output...

    Code:
    AudioInputAnalogStereo   adcs1(A4,A5);          //xy=262,240
    AudioMixer4              mixer1;         //xy=426,253
    AudioAmplifier           amp1;           //xy=572,253
    AudioOutputAnalog        dac1;           //xy=719,253
    AudioConnection          patchCord1(adcs1, 0, mixer1, 0);
    AudioConnection          patchCord2(adcs1, 1, mixer1, 1);
    AudioConnection          patchCord3(mixer1, amp1);
    AudioConnection          patchCord4(amp1, dac1);
    or maybe the issue is in the code (comes from the online designer)

    Code:
    setup()
    {
      AudioMemory(10);
      mixer1.gain(0, 1.0);
      mixer1.gain(1, 1.0);
    }
    Last edited by curtis newton; 11-01-2018 at 11:28 AM.

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,997
    Not every outside pin can be multiplexed to each of both ADCs. There are pins which can be used with ADC0, others with ADC1, and a few even with both. You have to study the processor reference manual in order to choose appropriate pins. The A2 and A3 combination should work.

  5. #5
    arf f... I allready etched the host PCB, ...

    ok then...I guess it's better to have a hardware routed audio instead of software

    thanks

    I'll try to find the cpu datasheet

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,997
    Never etch a PCB without having a working prototype on breadboard or veroboard.

    The reference manual is here: https://www.pjrc.com/teensy/K66P144M180SF5RMV2.pdf

  7. #7
    I thought the library was "software only", not a big deal I'll cut a trace :-)

    just been through the pdf, there is only ADC ratings, nothing much about ADC/DAC combinations

    A2 and A3 seem to work though

    thanks for the tips Mr Theremin :-)

Posting Permissions

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