synth
synth copied to clipboard
API design ideas.
It looks like the Tonic library has some great API design ideas for constructing controllers, generators and processors.
I like the idea that you can use operators to combine them.
Another idea might be allowing arbitrary types from pitch_calc to be used for note_on and note_off messages.
@filmor thanks for the suggestion! I originally considered this also, but thought it might be safer/simpler to keep the design simple for now as each of the pitch_calc makes it easy to convert to hz anyway. i.e.
let c_1 = LetterOctave(Letter::C, 1);
synth.note_on(c_1.hz(), 1.0);
I'm open to the idea of adding a ToHz trait though and implementing it for each of the pitch_calc types, and then having the note_on and note_off methods take T: ToHz instead :)
That was my idea, yes. If you want I can prepare a PR for this. If used synth in a simple midi player example, that's where it came up (see https://github.com/filmor/midi-rs/blob/master/examples/play.rs).