shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
184 stars 11 forks source link

Undefined / crashy behavior scheduling `reset_osc` #138

Closed bwhitman closed 1 month ago

bwhitman commented 1 month ago

We want to support scheduling reset_osc like all other parameters. A use case is playing a sequence using a schedule, and wanting to clear the voice allocations from presets to a different one. We can do this with

example_voice_chord(0, 0);
// Reset the oscs 
struct event e;
e.reset_osc = 1000;
e.time = 4500;
amy_add_event(e);
example_fm(5000);

However, this causes undefined behavior. One one computer, it crashes with a segfault 50% of the time at the reset. On another, it shows me [4504] chaining osc 0 to osc 0 would cause loop. at the reset time. Something is broken about the way we're scheduling resets. Dan thinks it's something w/ multithreading.

The crasher is:

IMG_6856

You can see the behavior by git checkout crasher; make amy-crasher; ./amy-crasher.

bwhitman commented 1 month ago

This goose chase was my bad; i was not initializing the struct event properly. Fixed by #139