PaulStoffregen / Audio

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

Play_raw Play_wav to any FS #451

Closed KurtE closed 1 month ago

KurtE commented 1 year ago

@PaulStoffregen @mjs513 @h4yn0nnym0u5e

This is an alternate implementation of

419

As mentioned in the forum thread: https://forum.pjrc.com/threads/71716-recording-playing-back-audio-on-multiple-SD-cards

It simply adds optional parameter at the end of the play method for the FS which defaults to SD

The other PR, makes a copy of the play method and adds the FS as the first parameter.

Either way works for me.

h4yn0nnym0u5e commented 1 year ago

Any reason this is using FS* as the parameter rather than FS& ? The latter would seem to be safer, as there's then no need for a NULL pointer check (which you don't make...)

KurtE commented 1 year ago

Could go either way, my first version did use references.  My first usage was with array with pointers, so had to dereference them passed in.  Actually both classes do test for null pointer Sent from my iPadOn Dec 31, 2022, at 2:41 PM, Jonathan Oakley @.**> wrote: Any reason this is using FS as the parameter rather than FS& ? The latter would seem to be safer, as there's then no need for a NULL pointer check (which you don't make...)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

h4yn0nnym0u5e commented 1 year ago

Could go either way, my first version did use references.  My first usage was with array with pointers, so had to dereference them passed in.  Actually both classes do test for null pointer Sent from my iPad

Mea culpa, I didn't inspect your code properly - indeed you do have a check for NULL pointers. As an "old school C programmer" I'm not sure if there's a "preferred C++ way" ... but moving it from a run-time to a compile-time check feels better to me, as you won't get unexpected silence from a NULL pointer, or weird crashes if you somehow manage to pass an invalid pointer (a skill I seem to have mastered...).

KurtE commented 1 month ago

Closing out detritus