Hi!
I seem to have stumbled across a slight bug with mixing audio rates on separate channels while working on a game.
Basically, I have channels 2,3 and 4 set at half rate, while channel 1 is at the normal rate, to get a bit higher range for the sfx in game. I have only channel 4 reserved for music by calling music(0,0,0b0001) in _init(), and since that's one of my half rate channels, I'd want stat(24) to accurately provide the pattern its playing currently. However, it seems this only works some of the time, and it can get out of sync pretty easily.
In the cart here, I've separated the music things from my game and made some easier to interpret statistics, but the bug still happens. Here I've made all the music patterns different, every pattern has a different note, and groups of 4 patterns use different instruments, so you can hear where in the sequence the song is. And just to make sure: The audio plays back correctly, the thing that's not working is what stat(24) reports as the current pattern.
There's some further testing I did with setting loop-points dynamically, it was how I found out about the issue but seemingly doesn't really matter in the end. While left-key is pressed on pad 1, the loop-bits are in a secondary setup, and the tune plays and loops correctly with all that.
An even shorter way to reproduce:
--have something in the song in a half-rate channel, at least for two patterns function _init() poke(0x5f40,0b1110) --anything that's not 0b0000 or 0b1111 music(0,0,0b0001) --obviously start the song from where you have it in the patterns/song end function _draw() print(stat(24),0,0,7) print(stat(25),0,8,7) --observe how stat(24) changes while stat(25) is at 128 (the middle of pattern) end |
PICO-8's sound card seems to break in a lot of ways when some channels are set to half clock speed and some aren't - the impression I have is that it calculates how many music ticks each channel needs to play for each pattern and then each channel plays that many music ticks, even if some of the music ticks are twice as long because half speed.
It's a different problem than you're observing but possibly related?
[Please log in to post a comment]