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

Thread: read analog input from 3.5mm jack? with audio board ( with fun images!)

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    4

    read analog input from 3.5mm jack? with audio board ( with fun images!)

    Click image for larger version. 

Name:	Polygon Blueprint3.jpg 
Views:	26 
Size:	269.7 KB 
ID:	22596

    Hi I think the image explains it all.
    My goal is to do FFT and play music at the same time through 3.5mm cable.

    I uploaded examples > Audio > Analysis > FFT but there is no sign of voltage.

    What should I do?

  2. #2
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    132
    The "line in" is not that 3.5mm, that is the lineout
    Search for teensy audio board line in. An if you are trying to mix the two signals (both from teensy and Bluetooth receiver) you should use two resistors

  3. #3
    Junior Member
    Join Date
    Oct 2020
    Posts
    4
    Click image for larger version. 

Name:	PIC.jpg 
Views:	9 
Size:	125.2 KB 
ID:	22598
    So I found line in, hooked left, right and ground. Then ran FFT example but I am not seeing any results on serial monitor.

    What should I try next?
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	schematic_audio4.png 
Views:	9 
Size:	20.5 KB 
ID:	22597  

  4. #4
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    132
    I tried it myself, using USB audio signal in (don't have official audio board with input) and PT8211 on the output

    like you said no signal, but then I remembered , if there is no output nothing happens (read it somewhere), because the whole audio library depends on that output to run (it's that output that makes the interrupt that calls all the update functions)
    hopefully Paul can verify this.

    so if you make two extra AudioConnections to audioOutput:
    AudioConnection pcOutL(audioInput, 0, audioOutput, 0);
    AudioConnection pcOutR(audioInput, 0, audioOutput, 1);
    it should work

  5. #5
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    132
    maybe it's some bug (I run the "old" teensyduino ver @ Arduino 1.8.13)

    also USB audio I/O don't can take "control" responsibility for calling update_all()
    found in the source:
    // update_responsibility = update_setup();
    // TODO: update responsibility is tough, partly because the USB
    // interrupts aren't sychronous to the audio library block size,
    // but also because the PC may stop transmitting data, which
    // means we no longer get receive callbacks from usb_dev.

  6. #6
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    132
    sometimes this teensy driving me crazy

    I have this code:

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // Audio Processing Nodes
    AudioInputUSB                    audioInput;     //xy=175,110
    AudioSynthWaveformSine           sinewave; //xy=155,230
    AudioMixer4                      mixer;       //xy=490,190
    AudioAnalyzeFFT1024              myFFT;          //xy=685,215
    AudioOutputPT8211_2              audioOutput;    //xy=735,130
    
    // Audio Connections (all connections (aka wires or links))
    AudioConnection          patchCord1(audioInput, 0, mixer, 0);
    AudioConnection          patchCord2(audioInput, 1, mixer, 1);
    AudioConnection          patchCord3(sinewave, 0, mixer, 2); // did not work before when having this line uncommented
    AudioConnection          patchCord4(mixer, 0, myFFT, 0);
    AudioConnection          patchCord5(mixer, 0, audioOutput, 0);
    AudioConnection          patchCord6(mixer, 0, audioOutput, 1);
    
    void blinkLedTask(void); // forward declaration
    
    void setup() {
        // Audio connections require memory to work.  For more
        // detailed information, see the MemoryAndCpuUsage example
        AudioMemory(90);
        myFFT.windowFunction(AudioWindowHanning1024);
        //myFFT.windowFunction(NULL);
        mixer.gain(0, 1.0f);
        mixer.gain(1, 1.0f);
        mixer.gain(2, 1.0f);
        // Create a synthetic sine wave, for testing
        // To use this, edit the connections above
        //audioMain.sinewave.amplitude(0.3f);
        //audioMain.sinewave.frequency(1000.0f);
        
        Serial.println("Hello World");
    }
    
    void loop() {
        float n;
        int i;
        blinkLedTask();
        if (myFFT.available()) {
            // each time new FFT data is available
            // print it all to the Arduino Serial Monitor
            Serial.print("FFT: ");
            for (i=0; i<40; i++) {
                n = myFFT.read(i);
                if (n >= 0.01) {
                    Serial.print(n);
                    Serial.print(" ");
                } else {
                    Serial.print("  -  "); // don't print "0.00"
                }
            }
            Serial.println();
        }
    }
    
    void blinkLedTask(void) // minimized led blinker (long off short on)
    {
        const int lp=13;
        static int lds=0;//current ledState
        static unsigned long pms=0,cms=0,civ=0;// prev Ms, current Ms, current intervall
        static unsigned long boni=100,bofi=2000;// BlinkOnInterval,BlinkOffInterval
        cms=millis();civ=cms-pms;
        if(lds==0){if(civ>bofi){pms=cms;lds=1;digitalWrite(lp,1);}}
        else{if(civ>boni){pms=cms;lds=0;digitalWrite(lp,0);}}
    }
    it stop making any sound when having this line:
    AudioConnection patchCord3(sinewave, 0, mixer, 2); // did not work before when having this line uncommented

    but now suddenly it's just working with that line,
    very very strange.

  7. #7
    Senior Member
    Join Date
    Jul 2020
    Posts
    533
    Quote Originally Posted by manicksan View Post
    it stop making any sound when having this line:
    AudioConnection patchCord3(sinewave, 0, mixer, 2); // did not work before when having this line uncommented

    but now suddenly it's just working with that line,
    very very strange.
    I think this is because otherwise you've got an audio stream component that's never been connected, so the program
    crashes on a null pointer when its update() is called on it - could be wrong, its been a while since I looked at the audio
    library internals. I wouldn't be surprized if some components aren't fully robust to missing connections (which they are
    supposed to be I think).

    The way update() works is that (if there's some component that has update responsibility) it will iterate through every
    component in the order they were declared calling update(), irrespective of how they are connected.

  8. #8
    Junior Member
    Join Date
    Oct 2020
    Posts
    4
    Problem solved:

    1. Using Line-in(3.5mm jack is OUTPUT only!)
    2. Soldering is required(Teensy 4.1 & Audio Board)

Posting Permissions

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