I was discussing with a friend how to deal with complex music arrangements (all 4 channels) alongside sound effects. He alleged that the GameBoy used all its channels for music at times but would cancel one of its channels (perhaps the percussive one) to play sound effects, then resume when sound effects had elapsed.
Current PICO-8 configuration, as far as I understand, is to have music channel masks take precedence over sound effects. This is good in theory but can be bad if you want to do something like the above. A possible solution could be to allow music channel mask modification mid-playback - is this doable? It would require some way to save or lookup a currently playing track (not yet in the API as far as I know), and then we pass that track's value to a function that could reset the channel mask to fewer channels, before playing a sound effect. Then we would do it again with the previous channel mask and expect the muted track component to come back.
I'm not familiar with the tech powering sound playback for PICO-8 and I don't know if this is the sort of thing that could have a simple implementation, or if trying to be able to modify variables for already-playing songs is totally out of the question. I can begin to imagine why it would be complicated or non-performant, but I'm not sure, so I thought I'd ask.
Thanks!
It won't be possible to change the mask, but I've rewritten the mixer to be much more friendly in 0.1.6:
- music always resumes after playing a sfx on the same channel
- a set mask bit now means: 'protect this channel' from being automatically selected by sfx() when a channel index is not specified
- the mask defaults to 0x0 instead of 0xf
- when automatically selecting a channel, first empty channels are preferred, then music channels that are currently not playing something, then the shortest playing sound.
So in the majority of cases, you'll be able to just play music and sounds without caring/knowing about the mask or the channels.
On a related note, I also took the opportunity to fix another thing that has been bugging me for a long time: every change in instrument/pitch/volume causes a tiny pop because of the discontinuity. I added Pro-Tracker style volume ramping to improve this: every tick, the previous tick's note and parameters is continued to be mixed for a small number of samples and cross faded with the beginning of the current note.
[Please log in to post a comment]