From 4a92d7d61de39e743b71b4aec462b19aa13f7d99 Mon Sep 17 00:00:00 2001 From: slack Date: Mon, 15 Jun 2009 17:42:22 +0200 Subject: [PATCH] small size optimization in play.c --- play.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/play.c b/play.c index 3431837..21acb61 100644 --- a/play.c +++ b/play.c @@ -8,7 +8,7 @@ #define NUM_VOICES 1 -float row_duration=60.0/360.0; // denominator == RPM +float row_duration=60.0f/360.0f; // denominator == RPM Voice voices[NUM_VOICES]; float mix_buf[BUFFER_SIZE]={0}; uint8 last_voice_used=0; @@ -27,15 +27,15 @@ void play(void *s, uint8 *stream, int len) memset(mix_buf, 0, BUFFER_SIZE*sizeof(float)); - if ((current_time - rows_played * row_duration) > row_duration ) { + float time_since_last_row_played = current_time - rows_played * row_duration; + if (time_since_last_row_played > row_duration ) { ++rows_played; - ++cur_row; - int buf_start = ((current_time - rows_played * row_duration)*SAMPLE_RATE)-num_samples; + cur_row = (cur_row+1)%TRACK_LENGTH; + if (!cur_row) ++cur_pos; + + int buf_start = ((time_since_last_row_played+row_duration)*SAMPLE_RATE)-num_samples; + - if (cur_row == TRACK_LENGTH) { // end of track - cur_row=0; - ++cur_pos; - } if (song->playlist[cur_pos]==255) { // loop at end of song cur_pos=0; } -- 2.34.1