Commit 243c697c authored by Jacob Vosmaer's avatar Jacob Vosmaer

Reset entire data structures during voice_init

parent 166b7503
......@@ -40,8 +40,8 @@
// playing). It is a queue in order to get 'rotating' voice assignment.
#define AVAIL_SIZE (NUM_VOICES + 1)
uint8_t avail[AVAIL_SIZE];
uint8_t avail_head = 0;
uint8_t avail_tail = 0;
uint8_t avail_head;
uint8_t avail_tail;
uint8_t
avail_advance(uint8_t i)
......@@ -90,7 +90,7 @@ avail_dequeue(void)
// and to be able to remove voices from anywhere in the list. A voice may
// only occur once in the list.
uint8_t playing[NUM_VOICES];
uint8_t playing_head = NUM_VOICES;
uint8_t playing_head;
// playing_head is a number between 0 and NUM_VOICES. if playing_head < NUM_VOICES it
// indicates the last voice that started playing. If playing_head == NUM_VOICES,
......@@ -145,9 +145,13 @@ uint8_t notes[NUM_VOICES];
void
voice_init(void)
{
avail_head = 0;
avail_tail = 0;
for (uint8_t i = 0; i < NUM_VOICES; i++) {
avail_enqueue(i);
}
playing_head = NUM_VOICES;
}
// Release the oldest playing voice, regardless of what note it is playing.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment