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

Thread: Audio adapter input all -1

  1. #1
    Junior Member
    Join Date
    Jan 2016
    Posts
    14

    Audio adapter input all -1

    Feeding a 1V pp 1 KHz square wave into LineIn. All I get is -1. Any ideas?

    -----------------------------------------------------------------------------------------

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>

    AudioInputI2S i2s2;
    AudioRecordQueue queue1;
    AudioConnection patchCord1(i2s2, 0, queue1, 0);
    AudioControlSGTL5000 sgtl5000_1;

    const int myInput = AUDIO_INPUT_LINEIN;

    int mode = 0; // 1=stopped, 0=recording

    int Count = 0;

    int Time = 10;
    int NRecords = (Time*AUDIO_SAMPLE_RATE_EXACT*4)/256;

    int led = 13;

    File frec;

    void setup() {

    pinMode(led, OUTPUT);
    Serial.begin(57600);

    AudioMemory(60);

    sgtl5000_1.enable();
    sgtl5000_1.inputSelect(myInput);
    sgtl5000_1.volume(0.5);

    // Initialize the SD card
    SPI.setMOSI(7);
    SPI.setSCK(14);
    if (!(SD.begin(10))) {
    while (1) {
    Serial.println("Unable to access the SD card");
    delay(500);
    }
    }

    startRecording();
    Count = 0;
    }

    ////////////////////////////////////////////////////////////////////////

    void startRecording() {
    Serial.println("startRecording");
    if (SD.exists("RECORD2.RAW")) {.
    SD.remove("RECORD2.RAW");
    }
    frec = SD.open("RECORD2.RAW", FILE_WRITE);
    if (frec) {
    queue1.begin();
    }
    }

    //////////////////////////////////////////////////////////////////////////////

    void flushRecording() {
    Serial.println("flushRecording");
    queue1.end();
    while (queue1.available() > 0) {
    queue1.freeBuffer();
    }
    frec.close();
    }

    ///////////////////////////////////////////////////////////////////////////

    void loop() {

    byte *b;

    if (mode == 1)
    return;

    while (queue1.available() > 0) {
    Count++;
    b = (byte*)queue1.readBuffer();
    if (Count%100 == 0) {
    Serial.print("record ");
    Serial.println(Count);
    };
    frec.write(b, 256);

    queue1.freeBuffer();
    if (Count >= NRecords) {
    flushRecording();
    mode = 1;
    }
    }
    }

  2. #2
    Junior Member
    Join Date
    Jan 2016
    Posts
    14
    Zeroing the buffers when I release them and still I get -1.

    Checked all the solder connections.

    The ground lines are all tied, so that's not it.

    Is there some API setting I'm missing.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,354
    Which Teensy are you using and what clock speed is it set at?

    Pete

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,354
    Found it.
    Code:
    pinMode(led, OUTPUT);
    You can't use pin 13 as the led output because it is used by the audio board as an input.

    Pete

  5. #5
    Junior Member
    Join Date
    Jan 2016
    Posts
    14
    Wahoo!

    Thanks a bunch.

    Just verified it.

    p.s. Teensy 3.1 @ 96 MHz.

    Loren

Posting Permissions

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