pub struct QuiverEngine { /* private fields */ }wasm only.Expand description
Main WASM interface for Quiver audio engine
Implementations§
Source§impl QuiverEngine
impl QuiverEngine
Sourcepub fn sample_rate(&self) -> f64
pub fn sample_rate(&self) -> f64
Get the sample rate
Sourcepub fn get_catalog(&self) -> Result<JsValue, JsValue>
pub fn get_catalog(&self) -> Result<JsValue, JsValue>
Get the full module catalog
Sourcepub fn search_modules(&self, query: &str) -> Result<JsValue, JsValue>
pub fn search_modules(&self, query: &str) -> Result<JsValue, JsValue>
Search modules by query string
Sourcepub fn get_modules_by_category(
&self,
category: &str,
) -> Result<JsValue, JsValue>
pub fn get_modules_by_category( &self, category: &str, ) -> Result<JsValue, JsValue>
Get modules by category
Sourcepub fn get_categories(&self) -> Result<JsValue, JsValue>
pub fn get_categories(&self) -> Result<JsValue, JsValue>
Get all categories
Sourcepub fn get_signal_colors(&self) -> Result<JsValue, JsValue>
pub fn get_signal_colors(&self) -> Result<JsValue, JsValue>
Get default signal colors
Sourcepub fn check_compatibility(
&self,
from: &str,
to: &str,
) -> Result<JsValue, JsValue>
pub fn check_compatibility( &self, from: &str, to: &str, ) -> Result<JsValue, JsValue>
Check port compatibility between two signal kinds
Sourcepub fn load_patch(&mut self, patch_json: JsValue) -> Result<(), JsValue>
pub fn load_patch(&mut self, patch_json: JsValue) -> Result<(), JsValue>
Load a patch from JSON
Sourcepub fn save_patch(&self, name: &str) -> Result<JsValue, JsValue>
pub fn save_patch(&self, name: &str) -> Result<JsValue, JsValue>
Save the current patch to JSON
Sourcepub fn validate_patch(&self, patch_json: JsValue) -> Result<JsValue, JsValue>
pub fn validate_patch(&self, patch_json: JsValue) -> Result<JsValue, JsValue>
Validate a patch definition
Sourcepub fn clear_patch(&mut self)
pub fn clear_patch(&mut self)
Clear the current patch
Sourcepub fn add_module(&mut self, type_id: &str, name: &str) -> Result<(), JsValue>
pub fn add_module(&mut self, type_id: &str, name: &str) -> Result<(), JsValue>
Add a module to the patch
Sourcepub fn remove_module(&mut self, name: &str) -> Result<(), JsValue>
pub fn remove_module(&mut self, name: &str) -> Result<(), JsValue>
Remove a module from the patch
Sourcepub fn set_module_position(
&mut self,
name: &str,
x: f32,
y: f32,
) -> Result<(), JsValue>
pub fn set_module_position( &mut self, name: &str, x: f32, y: f32, ) -> Result<(), JsValue>
Set module position for UI layout
Sourcepub fn module_count(&self) -> usize
pub fn module_count(&self) -> usize
Get the number of modules in the patch
Sourcepub fn cable_count(&self) -> usize
pub fn cable_count(&self) -> usize
Get the number of cables in the patch
Sourcepub fn set_output(&mut self, name: &str) -> Result<(), JsValue>
pub fn set_output(&mut self, name: &str) -> Result<(), JsValue>
Set the output module (required for audio output)
The specified module’s outputs will be read as the patch’s stereo output. Port 0 is left channel, port 1 is right channel.
Sourcepub fn connect(&mut self, from: &str, to: &str) -> Result<usize, JsValue>
pub fn connect(&mut self, from: &str, to: &str) -> Result<usize, JsValue>
Connect two ports (format: “module.port”).
Returns the new cable’s stable CableId as a number.
Hold onto it and pass it to disconnect_cable to
remove exactly this connection later, even after other cables change.
Sourcepub fn connect_attenuated(
&mut self,
from: &str,
to: &str,
attenuation: f64,
) -> Result<usize, JsValue>
pub fn connect_attenuated( &mut self, from: &str, to: &str, attenuation: f64, ) -> Result<usize, JsValue>
Connect with attenuation. Returns the new cable’s stable CableId.
Sourcepub fn connect_modulated(
&mut self,
from: &str,
to: &str,
attenuation: f64,
offset: f64,
) -> Result<usize, JsValue>
pub fn connect_modulated( &mut self, from: &str, to: &str, attenuation: f64, offset: f64, ) -> Result<usize, JsValue>
Connect with full modulation (attenuation and offset).
Returns the new cable’s stable CableId.
Sourcepub fn disconnect_by_index(&mut self, cable_index: usize) -> Result<(), JsValue>
pub fn disconnect_by_index(&mut self, cable_index: usize) -> Result<(), JsValue>
Disconnect the cable at the given position in the cable list.
Convenience for callers that track cables positionally. Resolves the position
to the cable’s stable CableId and removes it, so the
underlying removal is id-based (never off-by-one after prior removals).
Sourcepub fn disconnect(&mut self, from: &str, to: &str) -> Result<(), JsValue>
pub fn disconnect(&mut self, from: &str, to: &str) -> Result<(), JsValue>
Disconnect two ports (format: “module.port”)
Sourcepub fn get_module_names(&self) -> Result<JsValue, JsValue>
pub fn get_module_names(&self) -> Result<JsValue, JsValue>
Get all module names in the patch
Sourcepub fn get_params(&self, node_name: &str) -> Result<JsValue, JsValue>
pub fn get_params(&self, node_name: &str) -> Result<JsValue, JsValue>
Get parameters for a module
Note: This returns metadata about the module’s type from the registry, not the current parameter values. Use get_param for values.
Sourcepub fn set_param(
&mut self,
node_name: &str,
param_index: u32,
value: f64,
) -> Result<(), JsValue>
pub fn set_param( &mut self, node_name: &str, param_index: u32, value: f64, ) -> Result<(), JsValue>
Set a parameter value by numeric index
Sourcepub fn get_param(
&self,
node_name: &str,
param_index: u32,
) -> Result<f64, JsValue>
pub fn get_param( &self, node_name: &str, param_index: u32, ) -> Result<f64, JsValue>
Get a parameter value
Sourcepub fn set_param_by_name(
&mut self,
node_name: &str,
param_name: &str,
value: f64,
) -> Result<(), JsValue>
pub fn set_param_by_name( &mut self, node_name: &str, param_name: &str, value: f64, ) -> Result<(), JsValue>
Set a parameter value by name
This is a convenience method that looks up the parameter index by name.
Sourcepub fn subscribe(&mut self, targets: JsValue) -> Result<(), JsValue>
pub fn subscribe(&mut self, targets: JsValue) -> Result<(), JsValue>
Subscribe to real-time value updates
Sourcepub fn unsubscribe(&mut self, target_ids: JsValue) -> Result<(), JsValue>
pub fn unsubscribe(&mut self, target_ids: JsValue) -> Result<(), JsValue>
Unsubscribe from real-time value updates
Sourcepub fn clear_subscriptions(&mut self)
pub fn clear_subscriptions(&mut self)
Clear all subscriptions
Sourcepub fn poll_updates(&mut self) -> Result<JsValue, JsValue>
pub fn poll_updates(&mut self) -> Result<JsValue, JsValue>
Poll for pending updates (called from requestAnimationFrame)
Sourcepub fn pending_update_count(&self) -> usize
pub fn pending_update_count(&self) -> usize
Get the number of pending updates
Sourcepub fn tick(&mut self) -> Box<[f64]>
pub fn tick(&mut self) -> Box<[f64]>
Process a single sample and return stereo output as a Float64Array
[left, right].
Sourcepub fn process_block(&mut self, num_samples: usize) -> Float32Array
pub fn process_block(&mut self, num_samples: usize) -> Float32Array
Process a block of num_samples frames and return the interleaved stereo
result as a Float32Array of length num_samples * 2 ([l0, r0, l1, r1, ...]).
§Zero-allocation
The engine keeps preallocated, reused L/R and interleaved buffers (grown on
demand). Rendering uses the allocation-free Patch::tick_block, so a
steady-state render quantum performs no per-sample or per-block heap
allocation. Output is safety-clamped to ±10V to prevent speaker/hearing
damage from runaway signals.
§Ownership rule (important)
The returned Float32Array is a view into WASM linear memory, valid only
until the next call into this engine (which reuses/grows the buffer) or
free. Read it immediately — e.g. copy into your own array with
Array.from(...) or myBuffer.set(...) — before calling any other engine
method. Do not retain the returned object.
Sourcepub fn set_observer_interval(&mut self, blocks: u32)
pub fn set_observer_interval(&mut self, blocks: u32)
Set how often the state observer collects values, in blocks.
1 collects on every process_block; higher values
decimate collection (default 8). Clamped to a minimum of 1.
Sourcepub fn compile(&mut self) -> Result<(), JsValue>
pub fn compile(&mut self) -> Result<(), JsValue>
Compile the patch (required after adding/removing modules or cables)
Sourcepub fn add_midi_inputs(&mut self)
pub fn add_midi_inputs(&mut self)
Inject the engine-owned MIDI CV source modules into the current patch.
Adds five ExternalInput modules the user can
cable from to make MIDI actually drive audio:
| Module name | Signal | Fed by |
|---|---|---|
midi_voct | V/Oct | midi_note_on (pitch) |
midi_gate | Gate (0/5V) | midi_note_on / midi_note_off |
midi_velocity | CV unipolar 0–1 | midi_note_on (velocity) |
midi_mod | CV unipolar 0–1 | midi_cc(1, ...) (mod wheel) |
midi_bend | CV bipolar V/Oct | midi_pitch_bend |
Each exposes a single out port (e.g. cable midi_voct.out -> vco.voct).
Idempotent: modules already present (by name) are left untouched, so it is
safe to call after building or loading a patch. Marks the patch dirty.
Note: these modules are engine-managed and are not in the module registry, so
a patch saved while they are present cannot be re-instantiated by
load_patch on a fresh engine — call add_midi_inputs() again after loading.
Sourcepub fn midi_note_on(&mut self, note: u8, velocity: u8) -> Result<(), JsValue>
pub fn midi_note_on(&mut self, note: u8, velocity: u8) -> Result<(), JsValue>
Handle a MIDI Note On message.
Updates both the scalar getters and the shared midi_voct / midi_gate /
midi_velocity CV sources (see add_midi_inputs),
so a cabled patch responds on the next processed sample.
The shared CV sources are monophonic, so overlapping notes follow last-note
priority: the newly pressed note becomes the sounding note and is pushed onto
the held-note stack (see midi_note_off).
Sourcepub fn midi_note_off(&mut self, note: u8, _velocity: u8) -> Result<(), JsValue>
pub fn midi_note_off(&mut self, note: u8, _velocity: u8) -> Result<(), JsValue>
Handle a MIDI Note Off message.
The midi_* CV sources are monophonic and shared, so releasing a note only
closes the gate when it is the last held note. With overlapping notes (a
chord, or legato where the next note-on precedes the previous note-off),
releasing an inner note keeps the gate open and re-points pitch/velocity to the
most recently pressed note still held (last-note priority). This preserves
the documented “Gate: 5.0 while a note is held” contract instead of dropping the
gate — and prematurely releasing every cabled envelope — on the first release.
Sourcepub fn midi_velocity(&self) -> f64
pub fn midi_velocity(&self) -> f64
Get the current MIDI velocity (0-1)
Sourcepub fn midi_cc(&mut self, cc: u8, value: u8) -> Result<(), JsValue>
pub fn midi_cc(&mut self, cc: u8, value: u8) -> Result<(), JsValue>
Handle a MIDI Control Change message.
All CCs are stored for retrieval via get_midi_cc. CC1
(mod wheel) additionally drives the shared midi_mod CV source.
Sourcepub fn get_midi_cc(&self, cc: u8) -> f64
pub fn get_midi_cc(&self, cc: u8) -> f64
Get a MIDI CC value (0-1 normalized)
Sourcepub fn midi_pitch_bend(&mut self, value: f64) -> Result<(), JsValue>
pub fn midi_pitch_bend(&mut self, value: f64) -> Result<(), JsValue>
Handle a MIDI Pitch Bend message (value in -1..1).
Drives the shared midi_bend CV source as a V/Oct offset of ±2 semitones at
full deflection. The pitch_bend getter still returns the
raw -1..1 value.
Sourcepub fn pitch_bend(&self) -> f64
pub fn pitch_bend(&self) -> f64
Get the current pitch bend value (-1 to 1)
Trait Implementations§
Source§impl From<QuiverEngine> for JsValue
impl From<QuiverEngine> for JsValue
Source§fn from(value: QuiverEngine) -> Self
fn from(value: QuiverEngine) -> Self
Source§impl FromWasmAbi for QuiverEngine
impl FromWasmAbi for QuiverEngine
Source§impl IntoWasmAbi for QuiverEngine
impl IntoWasmAbi for QuiverEngine
Source§impl LongRefFromWasmAbi for QuiverEngine
impl LongRefFromWasmAbi for QuiverEngine
Source§impl OptionFromWasmAbi for QuiverEngine
impl OptionFromWasmAbi for QuiverEngine
Source§impl OptionIntoWasmAbi for QuiverEngine
impl OptionIntoWasmAbi for QuiverEngine
Source§impl RefFromWasmAbi for QuiverEngine
impl RefFromWasmAbi for QuiverEngine
Source§type Anchor = RcRef<QuiverEngine>
type Anchor = RcRef<QuiverEngine>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for QuiverEngine
impl RefMutFromWasmAbi for QuiverEngine
impl SupportsConstructor for QuiverEngine
impl SupportsInstanceProperty for QuiverEngine
impl SupportsStaticProperty for QuiverEngine
Source§impl TryFromJsValue for QuiverEngine
impl TryFromJsValue for QuiverEngine
Source§impl VectorFromWasmAbi for QuiverEngine
impl VectorFromWasmAbi for QuiverEngine
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[QuiverEngine]>
Source§impl VectorIntoWasmAbi for QuiverEngine
impl VectorIntoWasmAbi for QuiverEngine
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[QuiverEngine]>) -> Self::Abi
Source§impl WasmDescribeVector for QuiverEngine
impl WasmDescribeVector for QuiverEngine
Auto Trait Implementations§
impl !RefUnwindSafe for QuiverEngine
impl !UnwindSafe for QuiverEngine
impl Freeze for QuiverEngine
impl Send for QuiverEngine
impl Sync for QuiverEngine
impl Unpin for QuiverEngine
impl UnsafeUnpin for QuiverEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.