Log In  

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!

P#19585 2016-04-04 09:57 ( Edited 2016-04-06 13:13)

1

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.

P#19609 2016-04-05 16:37 ( Edited 2016-04-05 20:37)

Oh man, that's great news!

P#19610 2016-04-05 18:16 ( Edited 2016-04-05 22:16)

Wow all that sounds great. Thanks!

P#19617 2016-04-06 09:13 ( Edited 2016-04-06 13:13)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 14:14:13 | 0.005s | Q:11