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

Status
Not open for further replies.

onionwasabi

New member
Polygon Blueprint3.jpg

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?
 
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
 
PIC.jpg
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?
 

Attachments

  • schematic_audio4.png
    schematic_audio4.png
    20.5 KB · Views: 65
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
 
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.
 
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.
 
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.
 
Status
Not open for further replies.
Back
Top