audioeffects.panel_view

An effect as a control panel sees it, and the one call that puts it on screen.

EffectAdapter(effect) wraps an effect from audioeffects.create() in the adapter the panel edits through: up to sixteen macros on the MIDI scale, the patch names, bypass, reload, and a callback for changes that come from somewhere else. It is the effects half of audioinstruments.panel.PanelAdapter, with the same names.

import panel_view

adapter = panel_view.create(“RingMod”, source, 48000) adapter.set_macro(0, 96) # the effect’s macro 0, on the 0-127 scale adapter.set_patch(2) # what a pad press does

build(adapter, screen=...) puts the panel on a screen. The controls come from controls (apps/lib/controlkit) and LVGL, imported inside a guard, so this module loads without them; build() raises ImportError without.

Bypass: an effect has no bypass of its own. Some effects have a Mix macro, and most do not, so set_bypass only records the flag the panel shows. It does not change the sound. A bypass that routes around the effect is a host’s job, and it is not in this file.

audioeffects.panel_view.SHOW_MS = 1500

How long the display shows a value after the last turn, in milliseconds.

class audioeffects.panel_view.Panel(adapter, screen=None, group=None, theme=None, title=None, subtitle=None, on_close=None, two_wheels=False)[source]

Bases: object

The built panel, and the few things that update it.

adapter is what it edits. screen is the object to build on (the active screen by default) and group the input group the encoders join (the default group). theme is a theme name or dict, title replaces the adapter’s name on the faceplate, subtitle the line under it, and on_close, when given, adds an EXIT button that calls it.

two_wheels is for a setup with a second wheel that moves focus between the controls (see display_driver.set_wheel_mapping): the group stays in edit mode, so the other wheel always turns the control that has focus.

refresh_status()[source]

Repaint the engine light and the buttons’ LEDs from the adapter.

set_status(text)[source]

Show text on the display’s second line in place of READY.

For a live readout (a meter, a load figure) that fits the display’s width. An engine error, a restart or BYPASSED still takes its place, and so does a value being shown while a control moves. None puts READY back.

default_value(index)[source]

The value a reset returns macro index to: what the patch set.

edited()[source]

True when an encoder sits away from the value the patch gave it.

choose_patch(index)[source]

Pick patch index as if its pad were pressed.

delete()[source]

Take the panel off the screen and stop its timer.

audioeffects.panel_view.create(name, source, sample_rate, transport=None, **options)[source]

Create effect name and wrap it. A reload builds it with the same options.

audioeffects.panel_view.build(adapter, screen=None, group=None, **options)[source]

Put the control panel for adapter on screen. Options are Panel’s keywords.

adapter is an EffectAdapter, or an effect, which is wrapped first. A name is not accepted: a name needs a source and a sample rate, so use create() for that.

class audioeffects.panel_view.EffectAdapter(effect, rebuild=None, name=None)[source]

Bases: object

What a control panel needs from effect, and nothing else.

rebuild returns a new effect; request_reload() uses it, and without one a reload fails and says so. create() always passes one. name replaces the display name on the faceplate.

set_bypass(enabled)[source]

Record the bypass flag the panel shows. The effect is not told; see the module note.

request_reload()[source]

Build the effect again and swap it in, keeping the patch and macros.

Returns True when the new effect is in place. On a failure the old one keeps running, engine_error is 1 and engine_message says why. The old effect is not deinitialised here: it may still be in a graph that pulls from it, so a reload listener decides when to let it go.

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 effects.

note_macro(index, value)[source]

A host moved macro index to value (0-127): apply it, tell the listeners.

note_program(index)[source]

A program change from outside: apply it, tell the listeners the patch and every macro it moved.