Data Fields | |
uint8_t * | values |
pointer to values of sample | |
uint16_t | duration |
duration for playing | |
uint8_t | idx |
index to next value | |
uint8_t | num_values |
number of values in list | |
struct noise_part_s * | next |
pointer to next sample to play | |
volatile uint8_t * | pdone |
struct { | |
uint8_t malloced_struct:1 | |
GC: free() this struct. | |
uint8_t malloced_values:1 | |
GC: free() values list. | |
} | flags |
We build a singly-linked list of samples to play. Each sample has a pointer to a list of values to output to the PWM generator (in a circular way) and a duration.
When the sample has used up its timeslice (as measured by duration), the next sample will get started and the current sample will be put in a list for later garbage collection (we don't want to do the free() in the ISR).