Audio and MIDI
import { audio } from '@haxiomic/devui/audio';
import { midi } from '@haxiomic/devui/midi';
const input = audio(gui, videoElement); // or a MediaStream (the mic), or any AudioNode
input.bind(gui.find('Scene/size'), 'low', { range: [10, 60], smoothing: 0.7 });
input.values.low; // 0โ1 every frame, for your own use
input.bind(gui.find('Scene/glow'), 'level', { gain: 2, remember: true }); // kept across reloads
input.unbind(gui.find('Scene/glow'));
const m = midi(gui); // asks the browser for MIDI access
m.learn(gui.find('Scene/size')); // the next knob moved drives it
m.map(gui.find('Scene/hue'), { kind: 'cc', channel: 1, number: 21 });
// midi(gui, { softTakeover: false }): knobs set values at once, jumps and all
- Audio: an Audio folder with the spectrum and waveform (bands marked), the level and peak as a plot, and each band (
low 20โ250 Hz, mid to 2 kHz, high to 16 kHz, or your own bands) as a readout. A band, or the level, drives any number control, from code or the row's menu (Drive with audio; those are kept across reloads), across the control's range with gain and smoothing. Each band is normalised to the range it has lately moved in, so a quiet input still moves the whole range (normalize: false for the raw 0โ1). A driven row shows what drives it, and the values it's given aren't saved or undoable: a value you set while it's driven is where it rests, and it goes back there when the driving stops. The context starts on your first click if the browser held it back. - MIDI learn: right-click a row, Learn MIDI, then move a knob or press a key (Esc, or a click elsewhere, stops waiting). CCs map across a number's range (log ranges too; a number without one gets 0 to twice its value), set booleans past half way (a button that sends 0 and 127 toggles them), pick options and press buttons; notes press buttons, flip toggles, step options and set numbers by velocity. A knob learned for a second control leaves the first, and the MIDI log says so.
- Soft takeover: a knob moves a value only once it reaches it, so nothing jumps.
- A twist of a knob is one undo step. Mappings are kept per project, the row shows its CC or note, and the MIDI folder lists the inputs and the last messages with what each drove. Search
is:driven (or cc 21) to find mapped rows. Forget MIDI in the row's menu, or Forget all MIDI mappings in the palette.