audioinstruments.panel
An instrument as a control panel sees it.
PanelAdapter(inst) wraps an instrument from audioinstruments.create()
in the adapter a control panel edits through: sixteen macro values on the
MIDI scale, the patch names, bypass, reload, and a callback for changes that
come from somewhere else, such as a MIDI controller. It imports no panel, so
anything with the same attributes can use it.
import audioinstruments.panel as panel
adapter = panel.create(“poly106”, 48000) audio_out.play(adapter.instrument.output) adapter.note_on(60) # dropped while bypassed adapter.note_cc(0, 96) # a controller moved macro 0: listeners hear it adapter.set_patch(1) # what a pad press does
request_reload() builds the instrument again and swaps it in, so play
adapter.instrument.output again after a reload, or register
on_reload(callback) to hear about it.
- audioinstruments.panel.create(name, sample_rate, channel_count=2, transport=None, **options)[source]
Create instrument
nameand wrap it. A reload builds it with the same options.
- class audioinstruments.panel.PanelAdapter(instrument, rebuild=None, name=None)[source]
Bases:
objectWhat a control panel needs from
instrument, and nothing else.rebuildis a callable that returns a new instrument, used byrequest_reload(). Without one, a reload creates the same instrument by name at the same sample rate and channel count, with default options.namereplaces the instrument’s display name on the faceplate.- request_reload()[source]
Build the instrument again and swap it in, keeping the patch and macros.
Returns True when the new instrument is in place. On a failure the old one keeps playing,
engine_erroris 1 andengine_messagesays why.
- on_external_change(callback)[source]
Register
callback(kind, index, value):("macro", i, v)or("patch", i, i).
- on_reload(callback)[source]
Register
callback(new, old), called after a reload swaps instruments.Play
new.outputin place ofold.output. The old instrument is silenced but not deinitialised: deinit it once nothing pulls from it.
- note_cc(index, value)[source]
A controller moved macro
indextovalue(0-127): play it, tell the listeners.