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

Status
Not open for further replies.

C0d3man

Well-known member
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
 
Last edited:
[fixed]

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-Working-Audio-output-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
 
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).
 
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-A-DX7-(Fm-synthesis)-replacement-with-Dexed-on-a-Teensy

Regards, Holger
 
Status
Not open for further replies.
Back
Top