Commit b551dcbc authored by Jacob Vosmaer's avatar Jacob Vosmaer

Replace queue with list

parent 1f93a103
#include "voice.h"
#include "queue.h"
#include "list.h"
// The voice assigner moves voices between the 'avail' (available) queue
......@@ -41,28 +40,30 @@
// pointers. It is used to track which voices are available (i.e. not
// playing). It is a queue in order to get 'rotating' voice assignment.
uint8_t avail_array[NUM_VOICES + 1];
struct queue avail = {
uint8_t avail_array[NUM_VOICES];
struct list avail = {
.array = avail_array,
.size = NUM_VOICES,
.sup = NUM_VOICES,
};
void
avail_enqueue(uint8_t v)
{
q_enqueue(&avail, v);
l_push(&avail, v);
}
uint8_t
avail_is_empty(void)
{
return q_empty(&avail);
return l_empty(&avail);
}
uint8_t
avail_dequeue(void)
{
return q_dequeue(&avail);
uint8_t v = l_last(&avail);
l_delete(&avail, v);
return v;
}
// playing is an ordered set implemented as a sort of bounded singly linked
......@@ -115,7 +116,7 @@ uint8_t notes[NUM_VOICES];
void
voice_init(void)
{
q_flush(&avail);
l_flush(&avail);
for (uint8_t i = 0; i < NUM_VOICES; i++) {
avail_enqueue(i);
}
......
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