Component rendering and widget gallery¶

Submediant renders equipment panels to images and movie frames. A component declares its ports, children, and displays; a skin supplies measurements and painting. This guide shows the actual renderers, with reproducible Python examples and PNG specimens for every named built-in skin.

These are offline, read-only visualizations. A painted knob does not handle mouse input or change DSP. Change an owning equipment definition or parameter binding, construct a new session, and render again to change a performance. See Generate PCM from Python for that audio path.

From the repository root, install the dependencies and reproduce the images:

python -m pip install -e '.[docs]'
python docs/sphinx/examples/render_components.py

Images are generated under build/docs/components/. The documentation checker regenerates them before Sphinx and verifies that they reach the published site. Pillow is included in the docs extra; FFmpeg and an audio render are unnecessary. Download the complete runnable example. The downloaded script also works with an installed Submediant package; output is relative to the current working directory, under build/docs/components/.

Declare settings and signal displays¶

Import the declaration types from submediant.component_model. The example uses these definitions for every skin, changing only the selected painter:


def make_elements():
    gain = FixedRange(0, 1, 2, 3).bind('.65')
    fader = FixedRange(0, 1, 2, 3).bind('.35')
    frequency = RangedInteger(440, 20, 999, unit='Hz')

    def numeric(id_, label, value, control):
        display = NumericDisplay(value, control)
        return DisplayElement(id_, label, DisplayKind.SETTING,
                              value=display.text, numeric=display)

    signal = SignalRef(('demo',), 'out')
    return (
        numeric('gain', 'GAIN', gain, NumericControlKind.KNOB),
        numeric('fader', 'FADER', fader, NumericControlKind.SLIDER),
        numeric('frequency', 'FREQUENCY', frequency, NumericControlKind.READOUT),
        DisplayElement('status', 'STATUS', DisplayKind.SETTING, value='DEMO / ON'),
        DisplayElement('wave', 'WAVEFORM', DisplayKind.WAVEFORM, signal=signal),
        DisplayElement('meter', 'METER', DisplayKind.METER, signal=signal),
        DisplayElement('led', 'LED STRIP', DisplayKind.LED_STRIP, signal=signal),
        DisplayElement('vertical-led', 'OUT', DisplayKind.LED_STRIP,
                       signal=signal, orientation=DisplayOrientation.VERTICAL),
        StereoLevelDisplay('stereo-level', 'L/R', signal=signal,right_signal=SignalRef(('demo',),'right')),
    )

NumericDisplay requires an exact ranged value plus a NumericControlKind. DisplayElement.value must equal numeric.text. A setting has no signal reference; a waveform, meter, or LED strip must have one and has no static value. ComponentPanel holds the elements under a title; element IDs must be unique within that panel.

For an adjustable parameter, use the range declared by the owning model rather than inventing a display-only range. FixedRange.bind accepts display units; from_dsp converts with the range’s base_scale. NumericParameter binds a range and control kind once and exposes display(value) for a setting. The gallery’s synthetic controls deliberately use demonstration ranges.

Skin gallery¶

Every image below is a tabletop-style component panel with the same declarations and signal. Numeric values are gain .65, fader .35, and frequency 440 Hz. The signal is a 440 Hz sine at .32 amplitude, sampled at 24 kHz, with a synthetic history ramp. These are widget specimens, not measurements from a song.

There are nine named themes backed by eight renderer families. Navy uses the Amp renderer with its own palette. A numeric KNOB/SLIDER declaration is a semantic request: the selected skin and presentation decide whether it appears as physical hardware or a textual setting. The gallery does not substitute one skin’s knob painter into another.

Atomcore¶

Import ATOMCORE from submediant.skin_model. It uses the analog material and Atomcore renderer. In tabletop mode, numeric settings use the base text presentation; the compound signal view adds the analog VU visualization.

Atomcore tabletop panel with text settings, waveform, meter, and LED strips.

Atomcore, tabletop presentation, shared synthetic signal.¶

LED City¶

Use LED_CITY for the digital chassis and palette. Its tabletop numeric settings also use text rather than Guitar-style physical controls.

LED City digital chassis with numeric text and signal displays.

LED City, tabletop presentation, shared synthetic signal.¶

Guitar¶

GUITAR draws glossy wood, physical knobs/sliders, and geometric seven-segment readouts. Its renderer is also the basis of several hardware-oriented families.

Glossy Guitar panel with knob, horizontal slider, numeric display, and signals.

Guitar, tabletop presentation, shared synthetic signal.¶

Diagnostic¶

DIAGNOSTIC uses the explicit plain diagram renderer. Its base numeric settings are textual, keeping the presentation focused on declared data.

Plain Diagnostic component panel with text settings and measured signal widgets.

Diagnostic, tabletop presentation, shared synthetic signal.¶

Amplifier¶

AMP uses textured black hardware, amplifier knobs, and an analog VU display with a small scope for signal observations in tabletop mode.

Black amplifier panel with knobs, slider, VU faces, and LED strips.

Amp, tabletop presentation, shared synthetic signal.¶

Mixer¶

MIXER uses its dedicated tabletop vertical fader and segmented level meter. Its compound-layout controls use the inherited painting path instead.

Mixer panel with vertical fader, segmented meter, and amplifier-style controls.

Mixer, tabletop presentation, shared synthetic signal.¶

Drum machine¶

DRUM_MACHINE paints a horizontal LED_STRIP as an illuminated pad with a level bar. It is driven by signal amplitude and is not an input button.

Drum-machine panel showing an illuminated signal pad and other controls.

Drum machine, tabletop presentation, shared synthetic signal.¶

Bass¶

BASS uses a white resin body and the Guitar-family control geometry.

White resin Bass panel with knob, slider, readout, and signal displays.

Bass, tabletop presentation, shared synthetic signal.¶

Navy¶

NAVY is an Amp-family theme with navy/silver styling. It is used by the native mallet instruments; it is a palette choice, not a ninth painter family.

Navy and silver Amp-family panel with real hardware widgets.

Navy, tabletop presentation, shared synthetic signal.¶

Individual widget recipes¶

These crops are independently rendered panels, not drawings of hypothetical widgets. The declaration examples all come from make_elements above. Their appearance is skin-specific; the values and signal references stay typed.

Knob¶

Use DisplayKind.SETTING with NumericDisplay(value, NumericControlKind.KNOB). The pointer uses the ranged value’s normalized position. The exact printed value and units come from that same ranged object, avoiding a second display-only interpretation of the control.

Guitar gain knob at .65 with its numeric readout.

Guitar knob, value .65 within [0, 1].¶

Slider and mixer fader¶

Use NumericControlKind.SLIDER with the same setting declaration. Guitar paints a horizontal slider; Mixer tabletop mode paints a vertical fader. No separate fader value type is required.

Guitar horizontal slider at .35.

Guitar tabletop slider at .35.¶

Mixer vertical fader at .35 with seven-segment value.

The same declared SLIDER through Mixer tabletop painting.¶

Numeric readout¶

Use NumericControlKind.READOUT for a displayed parameter without a knob or slider. RangedInteger(440, 20, 999, unit='Hz') supplies the exact value and units shown here. Readout metadata does not make a parameter adjustable.

Seven-segment 440 Hz frequency readout.

Guitar readout, 440 Hz.¶

Text setting or status¶

Use DisplayElement('status', 'STATUS', DisplayKind.SETTING, value='DEMO / ON') without numeric for text. This is a label/value display, not a toggle.

Static text setting reading STATUS and DEMO / ON.

Static status text in the Guitar skin.¶

Waveform¶

Use DisplayKind.WAVEFORM with a SignalRef naming an observed output. The painter receives floating-point signal samples. For this isolated specimen, demo_signal supplies a known sine; normal performance boards select windows from the execution result. Never pass WAV container bytes as waveform samples.

Waveform display of the known 440 Hz synthetic signal.

Guitar tabletop waveform and its derived level summary.¶

Meter¶

Use DisplayKind.METER and a real observed SignalRef. The selected skin computes RMS/peak summaries from the supplied samples. Guitar uses a level bar; Amp and Mixer have specialized tabletop meter appearances.

Guitar signal meter derived from the synthetic sine.

Guitar tabletop meter; the full skin gallery shows the Amp and Mixer variants.¶

Horizontal LED strip¶

Use DisplayKind.LED_STRIP. Horizontal is the default orientation. Levels are derived from the signal rather than a separately authored LED percentage.

Horizontal green and yellow LED level strip for the synthetic sine.

Guitar tabletop horizontal LED strip.¶

Vertical LED strip¶

Pass orientation=DisplayOrientation.VERTICAL to an LED strip declaration. The skin measures and paints a vertical strip observing the same signal. Vertical orientation is rejected for the other DisplayKind values.

Vertical green and yellow LED strip for the same synthetic signal.

Guitar tabletop vertical LED strip.¶

Illuminated drum pad¶

The DrumMachine renderer’s horizontal LED strip looks like a pad. Select DRUM_MACHINE and use the same LED_STRIP declaration to obtain it.

Illuminated drum-machine pad displaying signal level.

Signal-driven pad; it does not accept clicks or schedule percussion events.¶

Control endpoints and signed values¶

The same declared range determines the displayed number and control position. This image exercises minimum, middle, and maximum values of a signed [-1, 1] range for both knobs and sliders. Out-of-range or excess-precision parameter values are rejected, rather than silently changing a control’s range to fit.

Six Guitar controls showing knob and slider positions at minus one, zero, and one.

Signed controls at -1.00, .00, and 1.00; each uses two decimal places.¶

Buttons, switches, and the legacy selector¶

The generic typed component API currently provides READOUT, KNOB, and SLIDER numeric controls plus the display kinds shown above. It has no general button, toggle, switch-state, callback, or click-handling API. A status label, drum pad visualization, or decorative chassis footswitch does not supply one.

An existing legacy analog graph renderer does draw a five-stop waveform selector tied to a serialized oscillator’s op. This is a separate rendering path, not a generic NumericControlKind switch. The example’s legacy_selector function calls submediant.analog_face.paint_face_analog for the five real oscillator operations; each returned parameter list includes op.

Five legacy analog oscillator faces with waveform selectors for sine, triangle, square, sawtooth, and noise.

Legacy waveform-selector detents. These reflect serialized node values and do not mutate the graph when painted.¶

To trigger a drum, author a DrumStrike/CymbalStrike in the musical score. To change a setting, replace its owning definition or parameter binding. A future interactive button/switch abstraction would require an explicit control/event contract; the current static rendering API does not define it.

Standard, compact, and tiny presentation¶

The tabletop images above use hardware=True. Compound panels use hardware=False and STANDARD, COMPACT, or TINY presentation. These comparisons use the same gain setting and waveform through the Guitar renderer:

Standard compound Guitar control and signal display with waveform history.

STANDARD compound presentation, including waveform and synthetic level history.¶

Compact Guitar control and signal value rendered as short numeric summaries.

COMPACT presentation uses compact numeric and signal summaries.¶

Tiny Guitar setting and signal rendered as text summaries.

TINY presentation uses text summaries. These are rendering choices, not new DSP.¶

Bind, measure, and paint¶

The composition root builds the typed skin factory with Config. Painters do not construct injectors or discover services themselves:


def skin_factory():
    # The composition root owns Config/injection. Painters receive typed objects.
    return get_injector(EquipmentSkinConfig()).inject(EquipmentSkinFactory)

factory.bind(theme) returns the selected definition/renderer pair. renderer.measure accounts for labels, units, and the chosen presentation. The example uses those natural sizes in a small gallery-only shelf layout:


def paint_panel(factory, theme, elements, *, hardware=True,
                presentation=Presentation.STANDARD, columns=4):
    renderer = factory.bind(theme).renderer
    component = ComponentDefinition(
        'demo', 'Component demonstration', (audio_out(),audio_out('right')), generator=True,
        panel=ComponentPanel('Component demonstration', tuple(elements)),
    )
    # Measure first. The small gallery uses four shelf-packed columns; production
    # performances use PerformanceLayout/TabletopLayout rather than these shelves.
    sizes = [renderer.measure(e, presentation, hardware=hardware) for e in elements]
    columns = min(columns, len(elements))
    widths = [max(sizes[i][0] for i in range(c, len(elements), columns))
              for c in range(columns)]
    rows = [max(h for _, h in sizes[i:i + columns])
            for i in range(0, len(elements), columns)]
    width, height = sum(widths) + 24 * (columns + 1), sum(rows) + 24 * (len(rows) + 1) + 64
    image = Image.new('RGB', (width, height))
    renderer.background(image, theme)
    box = Rect(10, 10, width - 20, height - 20)
    group = ComponentGroup(('demo',), component.label, box, component.ports, 0, 0)
    renderer.paint_group(image, theme, group)
    renderer.text(image, theme, (28, 24), theme.name, 14, True)
    values, history = demo_signal()
    placements = []
    for i, element in enumerate(component.panel.elements):
        row, col = divmod(i, columns)
        x, y = 24 + sum(widths[:col]) + 24 * col, 64 + sum(rows[:row]) + 24 * row
        w, h = sizes[i]
        placement = DisplayPlacement(DisplayId(('demo',), element.id), component.label,
                                     element, Rect(x, y, w, h), presentation, hardware=hardware)
        assert box.contains(placement.box)
        assert all(not placement.box.overlaps(other.box) for other in placements)
        placements.append(placement)
        if isinstance(element,StereoLevelDisplay):
            renderer.stereo_levels(image,theme,placement,values,values*.3)
        elif presentation is not Presentation.STANDARD:
            renderer.compact(image, theme, placement, values)
        elif hardware:
            renderer.hardware_element(image, theme, placement)
            if element.signal is not None:
                renderer.hardware_signal(image, theme, placement, values, i)
        else:
            renderer.element(image, theme, placement)
            if element.signal is not None:
                renderer.signal(image, theme, placement, values, history, i)
    return image

After defining the example’s imports and functions, render a standalone panel:

image = paint_panel(skin_factory(), GUITAR, make_elements())
Path("build").mkdir(exist_ok=True)
image.save("build/component.png")

In a normal equipment performance, PerformanceLayout/TabletopLayout produces placements and PerformanceBoard/TabletopBoard dispatches the corresponding painting calls. Custom equipment declares its panel through the equipment’s component property, returning the complete ComponentDefinition with real ports and observation paths. Preserve every required display and child; adding a picture does not create a new signal, exposed port, or DSP node.

Choose a device-specific skin with its typed skin field, or set a studio skin/render fallback. Equipment resolves device override, then family skin, then render fallback, then studio default. A fallback does not replace an instrument’s existing family choice. For a custom palette, use dataclasses.replace on an existing SkinDefinition and its typed palettes; for different drawing behavior, override the owning get_*_skin_class hook in EquipmentStudioConfig, calling super().configure() for extra bindings.

Respect the selected renderer’s measurements before audio execution. Reject insufficient space instead of squeezing controls, truncating numeric values, or overlaying signal regions. Changing only presentation must preserve PCM; widget images and video are observations of the performance, not its controls.

Split stereo levels¶

StereoLevelDisplay observes distinct left and right signal references in one mono-width vertical meter. Both channels use the same fixed dBFS scale and time window. This specimen uses the declared synthetic sine on left and a separately attenuated 0.3-times signal on right. Compound compact/tiny text preserves both values; tabletop hardware retains the measured 48-pixel footprint.

Two independently measured L/R strips in one mono meter width

Mixer-style sliders retain their existing three-digit numeric values, signs and decimal points. The narrower skin measures these complete values and wraps labels instead of rounding settings or removing units.

Logo of Submediant

Submediant

Navigation

  • Installation and runtime
  • Command-line reference
  • Generate PCM from Python
  • Component rendering and widget gallery
    • Declare settings and signal displays
    • Skin gallery
    • Individual widget recipes
    • Buttons, switches, and the legacy selector
    • Standard, compact, and tiny presentation
    • Bind, measure, and paint
    • Split stereo levels
  • Python API reference
  • Links for articles and integrations
  • Building the documentation

Related Topics

  • Documentation overview
    • Previous: Generate PCM from Python
    • Next: Python API reference
©2026 Richard Lee. | Powered by Sphinx 8.2.3 & Alabaster 1.0.0 | Page source