Trying to Use SD Optimization from Teensy Audio Lib

Status
Not open for further replies.

grinch

Well-known member
Hi, I'm trying to use the SD optimization from the teensy audio library.

In the documentation for playSDWav it says:

An experimental SD library optimization exists, which can remove these SD library restrictions. It also allows reliable playback of more files at the same time. To enable this special code, find and edit the SD_t3.h file within your Arduino folder. See the comments within that file for details.

I found this library, but installation is unclear: https://github.com/PaulStoffregen/SD

I've had a couple problems with this:

1. SD_t3.h does not exist in the teensy audio library.
2. SD_t3.h does not exist in any library on my computer, but playSDWav is working
3. The example for playSDWav includes a file called <SD.h> but this file also does not exist on my computer
4. play_sd_wav.h includes "SD.h" which does not exist in the Teensy Audio lib folder nor elsewhere on my computer. playSDWav runs fine though apparently.
5. Can't figure out how to tell if the optimization worked, what was included / not included etc...

How do I enable this optimization? Is it even a real thing?
 
Are you referring to the hardware folder that lives inside the Arduino application?

So like Arduino>ShowPackageContents: Contents/Java/hardware/teensy/avr/libraries/SD?

If so that would probably be worth adding to the documentation, at least if you want this to be a useful thing for people. I wasn't even aware of these internal libraries prior to this project. I just have an application where I need to play a lot of SD audio tracks and am trying to get it figured out.

Thanks!
 
Also, as soon as I uncomment the line:
#define USE_TEENSY3_OPTIMIZED_CODE

In:
Arduino/Contents/Java/hardware/teensy/avr/libraries/SD/SD_t3.h


I get the following error in compilation:
e_audio.h:39: error: 'BUILTIN_SDCARD' was not declared in this scope
#define SDCARD_CS_PIN BUILTIN_SDCARD


How do I fix this?
 
Also, as soon as I uncomment the line:
#define USE_TEENSY3_OPTIMIZED_CODE

In:
Arduino/Contents/Java/hardware/teensy/avr/libraries/SD/SD_t3.h


I get the following error in compilation:
e_audio.h:39: error: 'BUILTIN_SDCARD' was not declared in this scope
#define SDCARD_CS_PIN BUILTIN_SDCARD


How do I fix this?

Not sure of the exact historical order - but it seems Paul worked up the read only USE_TEENSY3_OPTIMIZED_CODE before the T_3.6 BUILTIN_SDCARD was a thing to be included. In any case the edits made to normal SD.h for read only weren't made for that code path.
 
Not sure of the exact historical order - but it seems Paul worked up the read only USE_TEENSY3_OPTIMIZED_CODE before the T_3.6 BUILTIN_SDCARD was a thing to be included. In any case the edits made to normal SD.h for read only weren't made for that code path.

I found the BUILTIN_SDCARD define in the library. It's defined as 254 so I tried replacing BUILTIN_SDCARD with that in my code, and it compiles but the SD card fails to open.

I'm beginning to think this optimization might be a bit of a myth, haha. If it doesn't work it would be nice if that got removed from the documentation. I'm sure folks are quite busy tho. &#55358;&#56631;*♂️
 
The USE_TEENSY3_OPTIMIZED_CODE code only supports SPI and only works for reading the card, not writing.

It will NOT work with the built in SD socket on Teensy 3.5 & 3.6.

I've added a comment to the code.

https://github.com/PaulStoffregen/SD/commit/137176744380912e57cd6388945cf2d36dd7cbfc

Hopefully in future versions of the software, this will help save some time & frustration for anyone wishing to use this on Teensy 3.5 & 3.6.

Thanks for adding that so quickly! I'm sure that'll be helpful for folks who are trying to use this.
 
Status
Not open for further replies.
Back
Top