Ascene . Agraph . Aengine
. Anode
Songbook . Song
WSLoader . Sound Loaders
Random . Rhythm . TimeKeeper
MIDI . OSC . HID . Piano
Plot . Envelope . Util
Music Theory with Tonal
Ascene == "audio scene" The Audio Scene is the mechanism for managing audio nodes, the audio graph and other audio-engine state.
// start audio engine for this Fiber (before creating Anodes).
let scene = await Ascene.BeginFiber(this);
// create three Anode instances...
let fluid = scene.NewAnode("FluidSynth");
let vital = scene.NewAnode("Vital");
let gain = scene.NewAnode("Hz.Mix", {name:"gain", cfg:"stereo", preset:{Gain:3}});
let out = scene.GetDAC();
// configure the audio graph.
scene.Chain(fluid, gain, out);
scene.Chain(vital, out);
await scene.Sync();
// Load Anode presets if desired.
await fluid.LoadPreset("VintageDreamsWaves-v2.sf2");
await vital.RestoreState(path.join(thisDir, "presets/Cinema Bells.vital"));
//
// make music here ...
//
// ... and when the music dies:
scene.Cleanup();
| Function | Description |
|---|---|
async Ascene.BeginFiber(ctx) |
initialize the audio engine and create a scene context. |
| Method | Description |
|---|---|
GetDAC() |
returns the special scene output anode. |
GetADC() |
returns the special scene input anode. |
GetBlackhole() |
returns the special scene output null-sink anode. |
async Sync() |
synchronizes pending audio-engine edits (like Chain, Connect) |
async Wait(dur) |
blocks the running coroutine for a duration |
async WaitTil(time) |
blocks the running coroutine util time has arrived |
Now() |
returns an approximate value of the Aengine's current time (in samples). |
Seconds(sec) |
converts the requested seconds to a duration (in samples) |
Cleanup() |
clears the audio scene graph and nodes. |
NewAnode(plugNameOrId, opts?) * |
creates an anode instance of the given audio plugin. |
NewModule(modNameOrId, opts?)* |
creates a (builtin) modulator node instance. |
NewVoices() |
creates a Voices instance for modular polyphony. |
Chain(anode1, anode2, ..) |
Connect anodes in a chain. Arguments are a list of anodes or [anode, srcPort, targetPort]. |
Connect(a0, a1, p0?, p1?) |
Connects the output of anode a0 to the input of a1. Optional parameters p0 and p1 specify the output and input ports |
VisualizeGraph(title) |
Updates the GraphViz panel with the current state of the audio graph. |
ModulateParam(modSrc, sinkNode, sinkParam, remapper?) |
Connects the output of modulator to the parameter of sinkNode through an optional remapper. |
| * Anode/Module options | Description |
|---|---|
name |
sets the name of your Anode instance. |
cfg |
selects from the anode audio configurations, depends upon the Anode class. |
preset |
requests an initial state for the Anode instance |