Audio shield crashes when switching songs/files

Status
Not open for further replies.

jimtom

Member
Hello!

I am having trouble with a project I have been working on for a while now. The idea is basically to mimic an analog radio, but instead of tuning to different 'stations', this radio will simply switch between .raw audio files as you 'tune' the radio. There are two audio files playing simultaneously, one static and one is the 'station'. Tuning is controlled with an analog 10-turn potentiometer. As the radio is tuned to a 'station', the matching station's audio file is meant to start, the volume of the 'static' will go down, and the volume of the 'station' will come up. (See me code attached below)

The problem I am having is that the audio often times does not play properly. Sometimes, it crashes completely and you hear a loud, constant buzzing (a video demonstrating this is here: https://drive.google.com/open?id=19DWew2n16YIZARGarVZk1mHLjIPrHxpo) through the speakers that doesn't not stop until you shut down the Teensy. Other times, a 'station' simply will not play when the radio is 'tuned' to that station. This behavior is unpredictable. Sometimes, if you 'tune' to another station and then return to the station that was not working before, it will play. Other times, it won't play no matter what.

As you can see in the code, I've tried adding some delays, which does help somewhat with the crashing/buzzing but does not help at all with the stations not playing when they are supposed to. I have tried this with multiple SD cards (two different SanDisk class 10's, one cheapo off-brand which claims to also be class 10. All are 32 gb).

Anyone have any ideas what the issue might be? Has anyone experienced this crashing/buzzing with audio files before? Is it that I'm trying to send commands to the SD card reader too quickly or something?

Thank you to anyone who can help!
 

Attachments

  • Radio.ino
    11.6 KB · Views: 62
Try editing SD_t3.h to turn on the experimental SD card optimizations.

Also search for "Radio Music Thing Modular", which is an open source modular synth product which does something pretty similar to what you're describing. Maybe looking at their code can give you some ideas?
 
I believe using turning on SD optimization has fixed the issue! At least as far as I can tell so far. Thank you again, Paul!
 
Status
Not open for further replies.
Back
Top