Audio library and SdFat Library crash audio

Status
Not open for further replies.

darioconcilio

Well-known member
Hi,
I'm trying to use Audio Library with Accell and Gyro sensor.

Code:
AudioPlaySdWav           EventPlaySdWav; //xy=150,302
AudioPlaySdWav           HumPlaySdWav; //xy=151,232
AudioMixer4              SaberMixer; //xy=476,325
AudioOutputAnalog        OutputDac; //xy=727,295
AudioConnection *patchCord1 = NULL;
AudioConnection *patchCord2 = NULL; 
AudioConnection *patchCord3 = NULL;

[...]

[CODE]

When start program it uses AudioPlaySdWav to play a single WAV of 16 sec, and when wav file finish, teensy 3.2 restarts it.
During this process, when Accell or Gyro send a particular information, it plays AudioPlaySdWav with a specific WAV file.

Sometimes it happens that the teensy 3.2 crashes and produces a fixed and abnormal sound, the whole program crashes.

SD card contains sub folder from which, Audio Library, read both audio files.

What can cause this behavior?

PS: The crashes is not systematic.

Thank you for support
 
Hi,
I'm trying to use Audio Library with Accell and Gyro sensor.

Code:
AudioPlaySdWav           EventPlaySdWav; //xy=150,302
AudioPlaySdWav           HumPlaySdWav; //xy=151,232
AudioMixer4              SaberMixer; //xy=476,325
AudioOutputAnalog        OutputDac; //xy=727,295
AudioConnection *patchCord1 = NULL;
AudioConnection *patchCord2 = NULL; 
AudioConnection *patchCord3 = NULL;

[...]

[CODE]

When start program it uses AudioPlaySdWav to play a single WAV of 16 sec, and when wav file finish, teensy 3.2 restarts it.
During this process, when Accell or Gyro send a particular information, it plays AudioPlaySdWav with a specific WAV file.

Sometimes it happens that the teensy 3.2 crashes and produces a fixed and abnormal sound, the whole program crashes.

SD card contains sub folder from which, Audio Library, read both audio files.

What can cause this behavior?

PS: The crashes is not systematic.

Thank you for support[/QUOTE]

first,
the code snippet you give, is by far insufficient to diagnose your problem.
If the problem is with the Accel/Gyro sensor, I would expect to see the code you are using to communicate with these devices.
What you show is irrelevant.
so much for reminding you about the Forum Rule (in red on top of page)

To your problem: I would investigate first, if the I2C buffers that get variables for the Accel/Gyro values are of sufficient size and foe example declared global, so they do not disappear after receiving the I2C values. (same if you have a SPI device)

My experiences indicate that random crashes are mostly due to errors in memory accesses, overwrites, or variables that are meant to be persistent are placed on the stack.
 
I'm sorry for rules, I did not mean to violate it.
I expressed myself badly, the piece of code was just to show the structure Audio.
In reality, you have already answered my question, in your last line.
 
Ok, now.

I read again PlaySdWav and I see that it could activate the Optimization Mode.

I found a file SD_t3.h

Code:
// This Teensy 3.x optimized version is a work-in-progress.
//
// Uncomment this line to use the Teensy version, which completely replaces
// all of the normal Arduino SD library code.  The optimized version is
// currently read-only.  It CAN NOT WRITE ANYTHING TO YOUR SD CARD.  However,
// it is *much* faster for reading more than 1 file at a time, especially for
// the Teensy Audio Library to play and mix multiple sound files.
//
#define USE_TEENSY3_OPTIMIZED_CODE

But I a try to recompile, it not found SD card "Unable to access SD Card", if I comment again this row, It all ok.
What I have to do?

I would try to use multiple play from same SD card.
 
Status
Not open for further replies.
Back
Top