kisrael Posted July 13, 2020 Share Posted July 13, 2020 Hi there! I spent the last few weeks making https://alienbill.com/2600/atari-riff-machine/ - a simple browser-based looper/tracker for making Atari music. It generates batari Basic code for the Atari - though I'm worried there's some glitch and the two tracks get out of synch in some circumstances - help appreciated with that. I couldn't reproduce the problem with small tracks, and the number of frames seems right... so either it's a weird page boundary thing? or maybe some glitch like if there's rests at the begining or end? Anyway the engine for the two voices is a hacked up version I made from @Random Terrain's sdata version (his had two voices but assumed they'd be moving indepdently) 6 Quote Link to comment Share on other sites More sharing options...
RevEng Posted August 26, 2020 Share Posted August 26, 2020 Better late than never? The bug appears to be when you have two loops of differing length - say one is 16 beats and the other is 8. The current version of your code skips one frame when an EOF marker is found, so the 8 beat loop will drift 2 frames per song loop, and the 16 beat version will drift 1. Neither actually remains on beat, but the difference in EOFs encountered per song loop is what's causing the drift. Here's a quickly hacked version that immediately grabs new data on EOF. rem ***************************************************** rem * Music Starter using sdata rem * Based on code posted in the Ballblazer thread at AtariAge: rem * http://www.atariage.com/forums/index.php?s=&showtopic=130990&view=findpost&p=1615280 rem * Code adapted by Duane Alan Hahn (Random Terrain) rem * Code further modified by Kirk Israel rem * Explanation: rem * The 256-byte limitation is removed when using sdata. rem * You can fill a whole 4k bank with music if you want. rem ***************************************************** set smartbranching on rem ***************************************************** rem * Create aliases for variables rem ***************************************************** dim duration0=a dim duration1=b dim wastefulInitCheck=c dim datareader0=w ; just a reminder dim datareader1=x ; just a reminder dim datareader2=y ; just a reminder dim datareader3=z ; just a reminder rem * Volume off AUDV0=0 AUDV1=0 rem * Initialize duration and set up music duration0 = 1 gosub MusicSetup0 rem ***************************************************** rem * Main game loop starts here. rem ***************************************************** MainLoop goto GetMusic0 GotMusic0 if wastefulInitCheck = 1 then goto skipCheck wastefulInitCheck = 1 duration1 = 1 gosub MusicSetup1 skipCheck goto GetMusic1 GotMusic1 drawscreen goto MainLoop rem ***************************************************** rem * Music rem ***************************************************** GetMusic0 rem * Check for end of current note duration0 = duration0 - 1 if duration0>0 then GotMusic0 rem * Retrieve channel 0 data ReadMusic0 temp4 = sread(musicData0) temp5 = sread(musicData0) temp6 = sread(musicData0) rem * Check for end of data if temp4=255 then duration0 = 1 : gosub MusicSetup0 : goto ReadMusic0 rem * Play channel 0 AUDV0 = temp4 AUDC0 = temp5 AUDF0 = temp6 rem * Set duration duration0 = sread(musicData0) goto GotMusic0 MusicSetup0 sdata musicData0 = y 8, 4, 21, 15 8, 4, 20, 15 8, 4, 15, 15 8, 4, 18, 15 8, 4, 16, 15 8, 4, 12, 15 8, 4, 15, 15 8, 4, 20, 15 8, 4, 10, 15 8, 4, 9, 15 8, 4, 12, 15 8, 4, 11, 15 255 end return GetMusic1 rem * Check for end of current note duration1 = duration1 - 1 if duration1>0 then GotMusic1 rem * Retrieve channel 1 data ReadMusic1 temp4 = sread(musicData1) temp5 = sread(musicData1) temp6 = sread(musicData1) rem * Check for end of data if temp4=255 then duration1 = 1 : gosub MusicSetup1 : goto ReadMusic1 rem * Play channel 0 AUDV1 = temp4 AUDC1 = temp5 AUDF1 = temp6 rem * Set duration duration1 = sread(musicData1) goto GotMusic1 MusicSetup1 sdata musicData1 = w 15, 4, 27, 2 14, 4, 27, 2 13, 4, 27, 2 12, 4, 27, 2 11, 4, 27, 2 10, 4, 27, 2 9, 4, 27, 2 8, 4, 27, 2 7, 4, 27, 2 6, 4, 27, 2 5, 4, 27, 2 4, 4, 27, 2 3, 4, 27, 2 2, 4, 27, 2 1, 4, 27, 2 0, 0, 0, 60 255 end return Your tool actually served a very good use for me. I slowed down a sound effect 5x in audacity (with time stretch, so the pitches don't shift) and then played it and transcribed the pitches I heard into your tool. The playback in your tool allowed me to A:B compare the pitches to the sample. Then I hand-transcribed the data into the 7800basic sample format. The result was perfection. It's an unintended use for your tool, but an excellent one. So thanks for that, Kirk! This works best when used with musical-like sound effects, no doubt, the kind we've discussed before. [edit - just ran across a nasty bug in riff machine. If you accidentally type 0 into the beats field, the javascript code crashes and the app goes away. If you refresh it doesn't come back. Session data, I guess.] Quote Link to comment Share on other sites More sharing options...
kisrael Posted August 27, 2020 Author Share Posted August 27, 2020 thanks for the assist!!! I will look into updating that and finding the zero beats bug soon 1 Quote Link to comment Share on other sites More sharing options...
kisrael Posted August 29, 2020 Author Share Posted August 29, 2020 Fixed the 0-length bug, now going to look into upgrading the BASIC engine! 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.