PaulStoffregen / Audio

Teensy Audio Library
http://www.pjrc.com/teensy/td_libs_Audio.html
1.1k stars 408 forks source link

Buffered WAV file recording and playback #483

Open h4yn0nnym0u5e opened 2 months ago

h4yn0nnym0u5e commented 2 months ago

As discussed on forum thread https://forum.pjrc.com/index.php?threads/yet-another-file-player-and-recorder.70963/ Seems to be pretty stable now, so I've added a couple of extra examples and submitted this PR.

Provides 1-, 2-, 4-, 6- and 8- channel playback and recording of WAV files from/to any filesystem, while not interfering with the sketch's ability to access files - all accesses are done via EventResponder so not from within the interrupt handler, which has a tendency to cause all sorts of mayhem.

With reasonably-sized buffers in heap or PSRAM the resilience to other system activities seems pretty good, and playback / recording of multiple files is possible.

Several examples are provided (maybe too many, or too complex?); documentation has been updated.

madskjeldgaard commented 2 months ago

Extremely exciting!!!

salkin-mada commented 2 months ago

yay!

madskjeldgaard commented 2 months ago

I tested this in two different situations today:

And both worked wonderfully. Neither of them could reliably play long wav files without intermittent glitches with the normal sd wav file player but with this it works a charm :)

madskjeldgaard commented 2 months ago

Oh and heads up: The AudioBuffer class clashes with the AudioBuffer in the codecs library.

https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib/blob/master/audiobuffer.h

h4yn0nnym0u5e commented 2 months ago

I'll let Paul adjudicate that one. I'm fairly sure he won't be pulling Frank's library, (a) because there's no PR, and (b) because it's GPL, not MIT-licensed.