PDA

View Full Version : Audio library and SdFat Library crash audio



darioconcilio
05-07-2016, 06:25 PM
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

WMXZ
05-08-2016, 08:20 PM
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

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.

darioconcilio
05-09-2016, 09:36 AM
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.

WMXZ
05-09-2016, 10:02 AM
In reality, you have already answered my question, in your last line.
Perfetto .

darioconcilio
05-11-2016, 08:50 PM
Ok, now.

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

I found a file SD_t3.h


// 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.