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

Thread: Problem with AudioQueue on Teensy 3.5 and audio shield (SGTL5000)

  1. #1
    Senior Member
    Join Date
    May 2018
    Posts
    127

    Problem with AudioQueue on Teensy 3.5 and audio shield (SGTL5000)

    Hi all,

    Teensy (3.5) with audio shield and Audio library seem to be a abolute nice solution for my project (porting Dexed (open source Yamaha DX7 simulation) to the Teensy). But my problems are starting at a simple point: My small test program for the AudioQueue crashes:

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    
    #define _RATE_ 128
    
    // GUItool: begin automatically generated code
    AudioPlayQueue           queue1;         //xy=764,393
    AudioOutputI2S           i2s1;           //xy=1237,397
    AudioConnection          patchCord1(queue1, 0, i2s1, 0);
    AudioConnection          patchCord2(queue1, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=784,602
    // GUItool: end automatically generated code
    
    void setup() {
      Serial.begin(9600);
    
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.4);
      AudioMemory(8);
    
      Serial.println("START");
    }
    
    void loop() {
      int16_t* audio_buffer;
    
      while (!queue1.available())
      {
        Serial.println("Block");
        return;
      }
    
      audio_buffer = queue1.getBuffer();
      if (audio_buffer == NULL)
      {
        Serial.println("No memory");
        return;
      }
    
      queue1.playBuffer();
    }
    Perhaps I am doing something wrong? It starts, prints sometime that is is blocking and than the Teensy hangs

    I am using the latest Teensy package and the Arduino-1.8.5 IDE... has anybody an idea?

    Thanks a lot, Holger

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,603
    Have you studied the audio tutorial and its many examples?
    https://www.pjrc.com/teensy/td_libs_Audio.html
    also the audio workshop https://www.pjrc.com/store/audio_tutorial_kit.html

    your sketch doesn't appear to have an audio input source?? and you have no audio data in your output buffers??
    Here is a contrived example using audio output queues.
    https://forum.pjrc.com/threads/45788...-queue-example
    memcpy() should use 256.
    Last edited by manitou; 05-09-2018 at 03:01 PM.

  3. #3
    Senior Member
    Join Date
    May 2018
    Posts
    127

    [fixed]

    Quote Originally Posted by manitou View Post
    Have you studied the audio tutorial and its many examples?
    https://www.pjrc.com/teensy/td_libs_Audio.html
    also the audio workshop https://www.pjrc.com/store/audio_tutorial_kit.html

    your sketch doesn't appear to have an audio input source?? and you have no audio data in your output buffers??
    Here is a contrived example using audio output queues.
    https://forum.pjrc.com/threads/45788...-queue-example
    memcpy() should use 256.
    I have taken a deeper look into the audio tutorial and found some very nice and new hints, but nothing for solving my problem. Am am not using an input source and my sketch was only for testing purposes, so I left the buffers empty. The example above was a very good explanation - but I solved my problems very easy: I pressed the "PROGRAM" (Reset?) button on the board several times an reprogrammed the Teensy. Since than my test sketch worked. It seems that I hung up the Teensy before and any try to get new software on the Teensy won't work because there was something jammed...

    Thanks a lot and regards,

    Holger

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,382
    Quote Originally Posted by C0d3man View Post
    It seems that I hung up the Teensy before and any try to get new software on the Teensy won't work because there was something jammed...
    Several things can go wrong. It's always hard to tell which from so little info...

    Sometimes USB (maybe driver state?) gets messed up, especially with Windows. A reboot usually recovers.

    Some USB hubs have trouble when USB devices appear and disconnect too quickly. Usually unplugging the hub (and its power, if powered separately) cures that issue.

    Recent versions of Windows do a power management thing with USB that can cause trouble. Rebooting should work. There's a way in device manager to turn it off.

    Teensy 3.5 and 3.6 have a special feature to fully erase the chip. You need to hold the button for 15 seconds. It actually looks for a press between 13 to 17 seconds, so holding too long won't work, it needs to be 15 seconds. Usually pressing the button should be enough, but this special press will do a full erase (even EEPROM, which isn't normally erased when you upload new code).

  5. #5
    Senior Member
    Join Date
    May 2018
    Posts
    127

    Quote Originally Posted by PaulStoffregen View Post
    Several things can go wrong. It's always hard to tell which from so little info...

    Sometimes USB (maybe driver state?) gets messed up, especially with Windows. A reboot usually recovers.

    Some USB hubs have trouble when USB devices appear and disconnect too quickly. Usually unplugging the hub (and its power, if powered separately) cures that issue.

    Recent versions of Windows do a power management thing with USB that can cause trouble. Rebooting should work. There's a way in device manager to turn it off.

    Teensy 3.5 and 3.6 have a special feature to fully erase the chip. You need to hold the button for 15 seconds. It actually looks for a press between 13 to 17 seconds, so holding too long won't work, it needs to be 15 seconds. Usually pressing the button should be enough, but this special press will do a full erase (even EEPROM, which isn't normally erased when you upload new code).
    Many thanks for your hints! I am new to Teensy (but not to Arduino), so I have to learn about how to solve such problems by myself. First everything looked like a bigger problem in the audio stack until I recognized that the program changes were not written to the Teensy. I am using Linux (hopefully to avoid all USB problems with Windows :-) ).

    Now it seems to work - more about this at https://forum.pjrc.com/threads/52126...ed-on-a-Teensy

    Regards, Holger

  6. #6
    Senior Member
    Join Date
    May 2018
    Posts
    127
    Quote Originally Posted by manitou View Post
    memcpy() should use 256.
    Right... forgot to add a
    Code:
    sizeof(int16_t) *
    .

    Thanks!!!

Posting Permissions

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