Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Trying to Use SD Optimization from Teensy Audio Lib

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    19

    Trying to Use SD Optimization from Teensy Audio Lib

    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?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,068
    SD_t3.h is in hardware\teensy\avr\libraries\SD (Arduino 1.8.8 and TD 1.46_b7).

    Pete

  3. #3
    Junior Member
    Join Date
    Mar 2019
    Posts
    19
    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!

  4. #4
    Junior Member
    Join Date
    Mar 2019
    Posts
    19
    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?

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,068
    Which Teensy are you using? And which version of Teensyduino?

    Pete

  6. #6
    Junior Member
    Join Date
    Mar 2019
    Posts
    19
    Quote Originally Posted by el_supremo View Post
    Which Teensy are you using? And which version of Teensyduino?

    Pete
    Teensy Loader 1.44 (is that the Teensyduino version number?)
    Teensy 3.6

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,354
    Quote Originally Posted by grinch View Post
    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.

  8. #8
    Junior Member
    Join Date
    Mar 2019
    Posts
    19
    Quote Originally Posted by defragster View Post
    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. ��*♂️

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,928
    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...5cf2d36dd7cbfc

    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.

  10. #10
    Junior Member
    Join Date
    Mar 2019
    Posts
    19
    Quote Originally Posted by PaulStoffregen View Post
    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...5cf2d36dd7cbfc

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •