#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;
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;
}