FrankBoesing / Arduino-Teensy-Codec-lib

MP3/AAC/FLAC Codecs for Teensy 3.x
110 stars 42 forks source link

Remove SD.h dependency from the library so better SD libraries like SdFat can be used #12

Closed jcj83429 closed 3 years ago

jcj83429 commented 4 years ago

Make CodecFile a helper object passed into AudioCodec rather than a base class of AudioCodec and move the implementation to codecfile.h (new file), It has to be in a header file so the SD.h dependency doesn't get compiled into the library. I also created a CodecFileBase interface that is implemented by CodecFile or your own class that implements the CodeFileBase interface. The changes in this PR alone won't allow you to use a different SD library. You also need to remove play_sd_wav.cpp/h and play_sd_raw.cpp/h from the teensy audio library to fully remove all dependencies on SD.h.

The play() interface had to be changed to take a CodecFileBase pointer. It is the user's responsibility to open and close the file if needed. The CodecFileBase interface doesn't manage fopen/fclose.

I updated and tested all the examples.

FrankBoesing commented 4 years ago

Thanks, I'll look at this in a week. Is it still compatible to the audio library?

jcj83429 commented 4 years ago

Yeah...It's a breaking change, but I hope the difference is not too big. It's still compatible with the audio library even if you don't remove play_sd_wav and play_sd_raw, although you won't be able to use a different SD library in that case.

FrankBoesing commented 3 years ago

Teensy uses SDFat as default now. I think we can close this ;)

tompom2 commented 3 years ago

Hello, sorry super noob question (also aware this may not be the correct place to ask, in which case please point me in the right direction): Does this thread mean that there is now a version of this library that one can use with the Teensy Audio Library and the SdFat library? If so, how would I go about obtaining it, or implementing the necessary changes to the existing version of this library?

FrankBoesing commented 3 years ago

Paul Stoffregen is about to replace the old SD.h with SdFat. Please read the forum: forum.pjrc.com.

tompom2 commented 3 years ago

Many thanks, I will wait for Teensyduino 1.54 before trying to implement this library!