EX / Hz.Builtins / Hz.ModExpr

Right-click to copy examples to your workspace


Intro

Hz.ModExpr is a parameter modulator that can be used to drive parameter changes of one or more parameters in your audio graph. If you want to drive an arbitrary anode param from your MIDI device, this is the way to do it. NB: many anodes already have default handling machinery for Note Expression events so this should usually be employed to drive parameters not covered by this.

Example

// NB: this example requires a MIDI input device with a Mod Wheel.
let id = `f${this.GetId()}: `;
let scene = await Ascene.BeginFiber(this);
let inst = scene.NewAnode("Hz.Osc");
let dac = scene.GetDAC()
scene.Chain(inst, dac);

let mod = scene.NewModulator("Hz.ModExpr");
mod.SelectSignal(mod.Signals.ModWheel);
scene.ModulateParam(mod, inst, "/voice/Vibrato");
await scene.Sync();

let port = 0;
let midiInput = new MidiIn(port);
let ok = await midiInput.Open();
while(true)
{
    let ymsg = yield; // allows for external cancellation
    if(ymsg == "_cancel_") break;
    let mmsg = await midiInput.Recv(); // "blocks" until activity
    // distribute event to two parties. this can streamlined by Voices.
    mod.MidiEvent(mmsg);
    inst.MidiEvent(mmsg);
}
midiInput.Close();
console.log("done");

See Also

Hz.ModExpr Ref . Hz.Osc Ref . MIDI CC Ref . Voices

home .. topics .. interface .. reference .. examples .. tipjar