Skip to content

Colors and behavior

One spectrum switching between every built-in palette

Any color= takes a theme token ("accent", "success", "warning", "error"…) or a hex color ("#ff9f3d"). Tokens follow the theme: switch to a light theme and the knobs follow.

Meters and analyzers take colors=: a palette name or a list of colors, from quiet to loud (or from bass to treble with color_by="frequency").

Palette Colors
"fl" Green → yellow → orange → red, like FL Studio’s meters.
"vu" Mostly green, yellow near the top, red at the very top.
"neon" Cyan → violet → pink.
"fire" Dark purple → red → orange → yellow → white.
"ice" Navy → blue → light cyan.
"magma", "viridis" The scientific color maps, best for spectrograms.
"mono" Gray to white.
"scope" The oscilloscope’s trace colors.

Add your own to ui.audio.PALETTES and use it by name everywhere:

ui.audio.PALETTES["sunset"] = ["#2d1b69", "#f72585", "#ffbe0b"]
ui.audio.Spectrum(magnitudes=mags, colors="sunset")
What Where
Look variant= on every component (knob, fader, meter, spectrum…).
How far a drag turns a control travel= on knobs, length= on faders; Shift is always ten times finer.
How a value maps to the control curve="log", step=, options=, bipolar=True.
How meters move hold= (peak hold), falloff= and peaks= (analyzers), variant="analog" ballistics.
How a scope reads trigger=, window=, persistence=, xy=.

All of them are pz.Components, so style=, class_=, stylesheets and animate= work as on any other component (see Components).

The helpers are public: ui.audio.bands() (FFT bins to log bands), ui.audio.format_value() (1.2 kHz, -6.0 dB), ui.audio.note_name() and ui.audio.PALETTES. Every component also has a shapes() method returning its drawing as pyzed.draw shapes, so you can put a knob or a meter inside your own pz.canvas.