A control panel
audioinstruments.panel wraps an instrument in the adapter a control panel
edits through: sixteen knobs on the MIDI scale, the patch list, bypass and
reload. It imports no panel, so any panel or app that reads these attributes
can drive an instrument.
import audioinstruments.panel as panel
adapter = panel.create("poly106", 48000, voices=4)
audio_out.play(adapter.instrument.output)
adapter.set_patch(1) # what a patch pad does
adapter.set_macro(0, 96) # what an encoder does
adapter.note_on(60) # notes through the adapter respect bypass
panel.create(name, sample_rate, channel_count=2, transport=None, **options)
takes what audioinstruments.create() takes and remembers it for a reload.
panel.PanelAdapter(inst, rebuild=None, name=None) wraps an instrument you
already have; rebuild is a callable that returns a new one. Without it a
reload creates the same instrument by name with the default options.
What it has
|
The instrument it edits. A reload replaces it |
|
The instrument’s display name, such as |
|
The instrument’s macro names (up to 16) and how many there are |
|
A list of 16 ints, 0 to 127, read back from the instrument |
|
The patch names in index order (up to 128) and the last one chosen |
|
True while bypassed: the instrument is silenced and |
|
False during a reload; 1 and the reason after a failed one |
|
Turn macro |
|
Bypass on or off. On sends every note off |
|
Build the instrument again with the same patch and macros. True when the new one is in place; on a failure the old one keeps playing |
|
|
|
|
|
A controller moved macro |
|
A program change from outside: the instrument follows, and the listeners hear the patch and every macro it moved |
|
The instrument’s, with |
note_cc takes a macro index, not a controller number: which controller
moves which macro is the host’s choice. A change made through set_macro or
set_patch is not reported to the listeners, since the panel made it. The
adapter’s own code allocates nothing on a note.