pumpuli [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=31121 stat(24) mixed up when having audio channels play at different rates <p>Hi!</p> <p>I seem to have stumbled across a slight bug with mixing audio rates on separate channels while working on a game.</p> <p>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.</p> <p>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. </p> <p>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.</p> <p> <table><tr><td> <a href="/bbs/?pid=85450#p"> <img src="/bbs/thumbs/pico8_music_bug-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=85450#p"> music_bug</a><br><br> by <a href="/bbs/?uid=31121"> pumpuli</a> <br><br><br> <a href="/bbs/?pid=85450#p"> [Click to Play]</a> </td></tr></table> </p> <p>An even shorter way to reproduce:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>--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</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=40820 https://www.lexaloffle.com/bbs/?tid=40820 Tue, 15 Dec 2020 22:50:50 UTC