Skip to content

Commit

Permalink
Ensuring stereo PWM on RP2040 is non-blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcombriat committed May 7, 2024
1 parent 33f76f4 commit b89e39f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/MozziGuts_impl_RP2040.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,16 @@ namespace MozziPrivate {
*/
# if (MOZZI_AUDIO_CHANNELS > 1)
PWMAudio pwm(MOZZI_AUDIO_PIN_1,true);
inline bool canBufferAudioOutput() {
return (pwm.availableForWrite()>1); // we will need to transfer 2 samples, for it to be non-blocking we need to ensure there is enough room.
}
# else
PWMAudio pwm(MOZZI_AUDIO_PIN_1);
# endif
inline bool canBufferAudioOutput() {
return (pwm.availableForWrite());
inline bool canBufferAudioOutput() {
return (pwm.availableForWrite());
}
# endif


inline void audioOutput(const AudioOutput f) {
pwm.write(f.l());
Expand Down

0 comments on commit b89e39f

Please sign in to comment.