I was successfully able to output stereo audio from the C API using
playdate->sound->addSource(). Use of headphones confirms that both output channels are receiving distinct streams. However, when outputting exclusively to the right audio (writing zeroes to the
left buffer in the callback), it works on the headphones as expected, but the built-in speaker does not play any sound. It is, for all intents and purposes, an output for the left stream only.
A headphone connection can be polled through
playdate->sound->getHeadphoneState(), which can be used as a workaround to merge the stereo streams in software when sending to the speaker. It's a good idea in general to code distinct output profiles for both monaural and stereo. Nonetheless, having the streams automatically merged barring any other intervention would be appreciated--not to mention more accommodating to the broader developer scene.
Thanks for the report. Yes, I agree that mixing both channels would be the preferred (and expected) behavior, but I fear there may be a hardware limitation. We'll look into it.
Thanks for the insight! Totally fine if it isn't practical to automate it:
getHeadphoneState() is sufficient for working it out. I didn't see mention of it in Inside Playdate with C (though I may have overlooked it), but a simple description of the situation in the manual should be all that's needed.
I can't believe we never noticed that. I'd assumed it was mixing to mono because we have the MONO setting enabled on the audio driver chip, but it turns out that's for using the left and right drivers together on a single speaker so you can output more power, it's still just sending one channel unmixed.
I found the actual mix control on the chip and I now have it switching to left+right if the speaker is active, back to separate left/right if not. It is possible to have both headphones and speaker enabled (see
playdate.sound.setOutputsActive()) and in that case it'll be mono on the headphones, too--we don't have a way to mix separately for the different outputs. But that's very much an edge case..
This has been corrected in 1.13.1.
The internal speaker now produces sound when writing to only the right channel.