Sign in

    dowdiness/moondsp/voice does not have a README file

    BoundVoicePool

    pub struct BoundVoicePool {
    // private fields
    }

    BoundVoicePool::active_voice_count

    fn BoundVoicePool::active_voice_count(self : BoundVoicePool) -> Int

    BoundVoicePool::apply_voice_control_result

    fn BoundVoicePool::apply_voice_control_result(self : BoundVoicePool, handle : VoiceHandle, control :
    GraphControl
    ) -> Result[Unit, VoiceControlError]

    Apply one validated graph control to an already-sounding voice.

    BoundVoicePool::apply_voice_controls_result

    fn BoundVoicePool::apply_voice_controls_result(self : BoundVoicePool, handle : VoiceHandle, controls : Array[
    GraphControl
    ]) -> Result[Unit, VoiceControlError]

    Apply a graph-control batch transactionally to an already-sounding voice.

    BoundVoicePool::apply_voice_param_bool

    fn BoundVoicePool::apply_voice_param_bool(self : BoundVoicePool, handle : VoiceHandle, node_index : Int, slot :
    GraphParamSlot
    , value : Double) -> Bool

    Allocation-conscious live parameter update predicate for host callback paths.

    BoundVoicePool::kill

    #deprecated("Use BoundVoicePool::kill_result(handle) to observe VoiceControlError")
    fn BoundVoicePool::kill(self : BoundVoicePool, handle : VoiceHandle) -> Bool

    Deprecated compatibility wrapper. Use kill_result to observe stale or invalid handles as VoiceControlError values.

    BoundVoicePool::kill_all

    fn BoundVoicePool::kill_all(self : BoundVoicePool) -> Unit

    BoundVoicePool::kill_result

    fn BoundVoicePool::kill_result(self : BoundVoicePool, handle : VoiceHandle) -> Result[Unit, VoiceControlError]

    BoundVoicePool::last_sanitized_count

    fn BoundVoicePool::last_sanitized_count(self : BoundVoicePool) -> Int

    BoundVoicePool::note_gate

    fn BoundVoicePool::note_gate(self : BoundVoicePool, controls : Map[String, Double]) -> NoteGate

    Resolve gate timing without starting a voice or changing the input controls. Attack/release controls use graph milliseconds; hold uses seconds. Instruments without all four envelope bindings retain their event gate.

    BoundVoicePool::note_off

    #deprecated("Use BoundVoicePool::note_off_result(handle) to observe VoiceControlError")
    fn BoundVoicePool::note_off(self : BoundVoicePool, handle : VoiceHandle) -> Bool

    Deprecated compatibility wrapper. Use note_off_result to observe stale or invalid handles as VoiceControlError values.

    BoundVoicePool::note_off_all

    fn BoundVoicePool::note_off_all(self : BoundVoicePool) -> Unit

    BoundVoicePool::note_off_bool

    fn BoundVoicePool::note_off_bool(self : BoundVoicePool, handle : VoiceHandle) -> Bool

    Allocation-conscious note-off predicate for host callback paths.

    BoundVoicePool::note_off_result

    fn BoundVoicePool::note_off_result(self : BoundVoicePool, handle : VoiceHandle) -> Result[Unit, VoiceControlError]

    BoundVoicePool::note_on_controls

    fn BoundVoicePool::note_on_controls(self : BoundVoicePool, controls : Map[String, Double]) -> VoiceHandle?

    BoundVoicePool::note_on_graph_controls

    Trigger a voice with an already-materialized graph-control batch. This bypasses string-key control-map resolution while preserving the same transactional semantics as VoicePool::note_on.

    BoundVoicePool::note_on_prevalidated_params4_id

    fn BoundVoicePool::note_on_prevalidated_params4_id(self : BoundVoicePool, node0 : Int, slot0 :
    GraphParamSlot
    , value0 : Double, node1 : Int, slot1 :
    GraphParamSlot
    , value1 : Double, node2 : Int, slot2 :
    GraphParamSlot
    , value2 : Double, node3 : Int, slot3 :
    GraphParamSlot
    , value3 : Double, pan : Double) -> Int64

    Trigger a voice from four fixed, prevalidated parameter updates and set its pan before it becomes visible to callers. This is for host integrations that validate a stable template outside the audio callback and need a non-allocating note-on path. Returns a negative id on rejection; dynamic graph-control callers should use note_on_graph_controls.

    BoundVoicePool::process_with_send

    Render dry stereo and the pool's single post-pan stereo send in one pass.

    BoundVoicePool::set_voice_pan

    #deprecated("Use BoundVoicePool::set_voice_pan_result(handle, pan) to observe VoiceControlError")
    fn BoundVoicePool::set_voice_pan(self : BoundVoicePool, handle : VoiceHandle, pan : Double) -> Bool

    Deprecated compatibility wrapper. Use set_voice_pan_result to observe stale or invalid handles as VoiceControlError values.

    BoundVoicePool::set_voice_pan_bool

    fn BoundVoicePool::set_voice_pan_bool(self : BoundVoicePool, handle : VoiceHandle, pan : Double) -> Bool

    Allocation-conscious pan update predicate for host callback paths.

    BoundVoicePool::set_voice_pan_result

    fn BoundVoicePool::set_voice_pan_result(self : BoundVoicePool, handle : VoiceHandle, pan : Double) -> Result[Unit, VoiceControlError]

    BoundVoicePool::set_voice_send_result

    fn BoundVoicePool::set_voice_send_result(self : BoundVoicePool, handle : VoiceHandle, gain : Double) -> Result[Unit, VoiceControlError]

    Set this voice's gain into the pool's single stereo send output.

    BoundVoicePool::validate_voice_controls_result

    fn BoundVoicePool::validate_voice_controls_result(self : BoundVoicePool, handle : VoiceHandle, controls : Array[
    GraphControl
    ]) -> Result[Unit, VoiceControlError]

    Validate a live control batch against an active voice without mutating it.

    BoundVoicePool::voice_state

    fn BoundVoicePool::voice_state(self : BoundVoicePool, handle : VoiceHandle) -> VoiceState

    BoundVoicePoolError

    pub(all) enum BoundVoicePoolError {
    InvalidMaxVoices
    OrphanAdsr
    CompileRejected
    Binding(
    ControlBindingError
    )
    } derive(Eq,
    Debug
    )

    BoundVoicePoolError::from_voice_pool

    Lift a VoicePoolError to a BoundVoicePoolError. Used by BoundVoicePool's constructors after delegating to validate_voice_template (which now returns VoicePoolError after the boundary-type migration per ADR-0010).

    NoteGate

    pub(all) enum NoteGate {
    EventEnd
    AfterSeconds(Double)
    InvalidDuration
    } derive(Eq,
    Debug
    )

    Gate timing selected by the instrument. Release continues after gate-off.

    VoiceControlError

    pub(all) enum VoiceControlError {
    InvalidVoiceHandle(VoiceHandle)
    Graph(
    GraphControlError
    )
    } derive(
    Debug
    )

    VoiceHandle

    pub struct VoiceHandle {
    slot : Int
    generation : Int
    } derive(Eq,
    Debug
    )

    Generation-tagged voice handle. WHY generation counter: slot indices are reused after voice stealing. Without a generation tag, a stale handle from a stolen note could accidentally gate_off or pan the wrong voice occupying that slot. Every note_on increments the slot's generation; all operations compare the handle's generation against the slot's current generation.
    impl Show for VoiceHandle

    VoiceHandle::from_parts

    fn VoiceHandle::from_parts(slot~ : Int, generation~ : Int) -> VoiceHandle

    Construct a handle from primitive parts for host-side fixed storage.

    VoiceHandle::packed_generation

    fn VoiceHandle::packed_generation(handle_id : Int64) -> Int

    VoiceHandle::packed_slot

    fn VoiceHandle::packed_slot(handle_id : Int64) -> Int

    VoicePool

    pub struct VoicePool {
    // private fields
    }

    VoicePool::active_voice_count

    fn VoicePool::active_voice_count(self : VoicePool) -> Int

    VoicePool::kill_all

    fn VoicePool::kill_all(self : VoicePool) -> Unit

    VoicePool::last_sanitized_count

    fn VoicePool::last_sanitized_count(self : VoicePool) -> Int

    Number of non-finite samples replaced with 0.0 during the most recent process() call, across both L and R output channels after mixdown.

    VoicePool::new

    WHY test_compile: validates the template structurally (reachable Output node, no invalid cycles, valid node indices) before accepting it. This is a correctness gate so that per-voice note_on compiles can assume the template is well-formed. The compiled result is discarded. WHY orphan-ADSR reject: VoicePool::note_on calls gate_on for every ADSR index in the template. If an ADSR is authored into the template but not wired to Output, optimize_graph eliminates it and gate_on would now return Err(OrphanNode). Rejecting at pool-construction time keeps the per-note gate_adsrs_at(...) loop infallible (it can .unwrap()) and surfaces the misconfiguration at the earliest observable point rather than at every note trigger. WHY adsr_authoring_indices snapshot: the pool's long-lived snapshot (used by note_on to gate ADSRs, and refreshed by set_template) stores only the indices needed for gating — not the full template — so the caller's CompiledTemplate can be freely discarded after VoicePool::new returns. optimize_graph does not mutate its input, so neither CompiledTemplate::analyze nor CompiledDsp::compile disturbs the caller's array.

    VoicePool::note_off

    #deprecated("Use VoicePool::note_off_result(handle) to observe VoiceControlError")
    fn VoicePool::note_off(self : VoicePool, handle : VoiceHandle) -> Bool

    Deprecated compatibility wrapper. Use note_off_result to observe stale or invalid handles as VoiceControlError values.

    VoicePool::note_off_all

    fn VoicePool::note_off_all(self : VoicePool) -> Unit

    VoicePool::note_off_result

    fn VoicePool::note_off_result(self : VoicePool, handle : VoiceHandle) -> Result[Unit, VoiceControlError]

    VoicePool::process_with_send

    Render dry stereo and the pool's single post-pan stereo send in one pass.

    VoicePool::set_template

    fn VoicePool::set_template(self : VoicePool, compiled_template :
    CompiledTemplate
    ) -> Result[Unit, VoicePoolError]

    VoicePool::set_voice_pan

    #deprecated("Use VoicePool::set_voice_pan_result(handle, pan) to observe VoiceControlError")
    fn VoicePool::set_voice_pan(self : VoicePool, handle : VoiceHandle, pan : Double) -> Bool

    Deprecated compatibility wrapper. Use set_voice_pan_result to observe stale or invalid handles as VoiceControlError values.

    VoicePool::set_voice_pan_result

    fn VoicePool::set_voice_pan_result(self : VoicePool, handle : VoiceHandle, pan : Double) -> Result[Unit, VoiceControlError]

    VoicePool::set_voice_send_result

    fn VoicePool::set_voice_send_result(self : VoicePool, handle : VoiceHandle, gain : Double) -> Result[Unit, VoiceControlError]

    VoicePool::voice_state

    fn VoicePool::voice_state(self : VoicePool, handle : VoiceHandle) -> VoiceState

    VoicePoolError

    pub(all) enum VoicePoolError {
    InvalidMaxVoices
    OrphanAdsr
    CompileRejected
    } derive(Eq,
    Debug
    )

    Failure modes for VoicePool construction and template replacement. Mirrors BoundVoicePoolError minus the Binding(...) variant (VoicePool has no bindings).

    VoiceState

    pub enum VoiceState {
    Idle
    Active
    Releasing
    } derive(Eq,
    Debug
    )

    impl Show for VoiceState