From ecfd95ce5a39c7f4c4716b04b55770582e668940 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Mon, 7 Dec 2009 18:51:57 -0800 Subject: [PATCH] Timing is correct now! Forgot to update samples_per_tick when parsing the 0xf effect. --- mod/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mod/main.c b/mod/main.c index 870790f..166765a 100644 --- a/mod/main.c +++ b/mod/main.c @@ -92,11 +92,11 @@ s8 mix(void){ } void process_tick(void){ + tick++; if(tick >= modheader.speed){ tick = 0; process_row(); - }else - tick++; + } } void process_row(void){ @@ -118,9 +118,10 @@ void process_row(void){ if(modheader.patterns[currpatt].pattern_entry[currrow][i].effect == 0xc) mix_channels[i].vol = modheader.patterns[currpatt].pattern_entry[currrow][i].param; if(modheader.patterns[currpatt].pattern_entry[currrow][i].effect == 0xf){ - if(modheader.patterns[currpatt].pattern_entry[currrow][i].param > 0x1f) + if(modheader.patterns[currpatt].pattern_entry[currrow][i].param > 0x1f){ modheader.tempo = modheader.patterns[currpatt].pattern_entry[currrow][i].param; - else + samples_per_tick = FREQ / (2 * modheader.tempo / 5); + }else modheader.speed = modheader.patterns[currpatt].pattern_entry[currrow][i].param; } //else @@ -150,7 +151,7 @@ void callback(void *data, Uint8 *buf, int len){ //LOG(buffer_left, i); //LOG(samples_left, i); } - while((buffer_left > 0) && (samples_left > 0)){ + while((buffer_left >= 0) && (samples_left >= 0)){ //for some reason i dont have to add 128 when i am using unsigned audio anymore ?? out[pos] += mix(); //out[pos] = (get_sample(&mix_channels[2]) * mix_channels[2].vol / volume_levels) + 128; -- 2.11.4.GIT