web synth docs

2021-03-27

MAIN GOAL: Plan out how to implement MIDI input learning for the [fm-synth] and other places as well

So we've got a MIDI controller with a lot of generic control inputs and we want to be able to route them to arbitrary value inputs for the [fm-synth] like modulation indices and effect parameters. It would also be good to expose a way for those values to be used in the patch network.

I think that this can be decomposed into two steps. First, we just expose callbacks for the control value changes. We already have the backend part built, and the frontend part will be trivial. We can use that directly with the patch network to implement a mapping from control indicies to param sources. We add one additional param source type which is MIDI control, we expose a MIDI learn feature which looks for the index of the most recently used control and listens for control changes and sets the values.

Yeah, the [patch-network] piece can be handled with a dedicated shim that builds CSNs dynamically and exposes them as patch network inputs. For both of these, we will need scale and shift functionality but that's no big deal.

I think there's enough here to go off of; let's build it.


Running into an issue here. We have a lot of the MIDI plumbing in place, but there is a roadblock handling when those values actually change. We need to be able to dynamically register callback-like things to indicate our interest in value changes for particular MIDI control indices, trigger those values to actually be updated on the [fm-synth] backend after scaling + shifting, and displaying that in the UI.

We have our MIDI control value cache which holds the last values, and we subscribe to value changes for that. We can easily add an interface to add/remove callbacks to the MIDI control value cache, but we need to make sure that we un-subscribe them when we change values away.

What I'm thinking is that we wrap the onChange handler in ConfigureParamSource in one that checks if we're switching to/from MIDI control inputs and handle un/subscribing those callbacks. We can store the callback in the state for the param so we have referential equality for that. Yeah, I like that; it's clean and handles everything I think. Let's see if it works or if we're missing something.

2021-03-27