Skip to main content

SamplePlayer

Struct SamplePlayer 

Source
pub struct SamplePlayer { /* private fields */ }
Expand description

Mono sample player with V/Oct pitch, start position, and looping.

§Parameter reads via ModulatedParam (Q147)

Pitch and start position are read through ModulatedParam, making that type a live part of a real DSP path rather than an unused export:

  • pitch uses a ParamRange::VoltPerOctave mapping. Its base field carries the coarse V/Oct pitch from the voct input, and its value is 2^voct, so 0 V plays at unity rate and +1 V doubles the playback speed.
  • start uses a ParamRange::Linear 0..1 mapping. Its base is the panel start-position knob and its CV comes from the start input (normalized on the ModulatedParam ±5 V scale), combined into a normalized 0..1 position.

Implementations§

Source§

impl SamplePlayer

Source

pub fn new( buffer: Vec<f64>, buffer_sample_rate: f64, engine_sample_rate: f64, ) -> Self

Create a player over buffer recorded at buffer_sample_rate, running in a graph at engine_sample_rate.

Source

pub fn empty(engine_sample_rate: f64) -> Self

Create an empty player (silent until a buffer is assigned).

Source

pub fn set_buffer(&mut self, buffer: Vec<f64>, buffer_sample_rate: f64)

Replace the sample buffer (non-real-time; allocates/moves the Vec).

Resets playback state so a stale read position cannot index past a shorter new buffer.

Source

pub fn len(&self) -> usize

Number of samples in the loaded buffer.

Source

pub fn is_empty(&self) -> bool

Whether the loaded buffer is empty.

Source

pub fn set_start(&mut self, start: f64)

Set the panel start-position knob (0..1), the base of the start ModulatedParam.

Source

pub fn start_position(&self) -> f64

Current start-position knob (0..1).

Trait Implementations§

Source§

impl Default for SamplePlayer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GraphModule for SamplePlayer

Source§

fn port_spec(&self) -> &PortSpec

Returns the module’s port specification
Source§

fn tick(&mut self, inputs: &PortValues, outputs: &mut PortValues)

Process one sample given port values
Source§

fn reset(&mut self)

Reset internal state
Source§

fn set_sample_rate(&mut self, sample_rate: f64)

Set sample rate
Source§

fn type_id(&self) -> &'static str

Get module type identifier for serialization
Source§

fn process_block( &mut self, inputs: &BlockPortValues, outputs: &mut BlockPortValues, frames: usize, )

Process a block of samples (optional optimization). Read more
Source§

fn breaks_feedback_cycle(&self) -> bool

Whether this module breaks a feedback cycle in the patch graph. Read more
Source§

fn params(&self) -> &[ParamDef]

Get parameter definitions for UI binding. Read more
Source§

fn get_param(&self, _id: ParamId) -> Option<f64>

Get a parameter value. Read more
Source§

fn set_param(&mut self, _id: ParamId, _value: f64)

Set a parameter value. Read more
Source§

fn serialize_state(&self) -> Option<Value>

Available on crate feature alloc only.
Serialize module state (alloc feature only)
Source§

fn deserialize_state(&mut self, _state: &Value) -> Result<(), String>

Available on crate feature alloc only.
Deserialize module state (alloc feature only)
Source§

fn introspect(&self) -> Option<&dyn ModuleIntrospection>

Available on crate feature alloc only.
Downcast this module to its ModuleIntrospection view, if it exposes one. Read more
Source§

fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection>

Available on crate feature alloc only.
Mutable companion to introspect, used to set internal parameters.
Source§

impl ModuleIntrospection for SamplePlayer

Available on crate feature alloc only.
Source§

fn param_infos(&self) -> Vec<ParamInfo>

Get all parameter descriptors for this module Read more
Source§

fn set_param_by_id(&mut self, id: &str, value: f64) -> bool

Set a parameter value by its ID Read more
Source§

fn get_param_info(&self, id: &str) -> Option<ParamInfo>

Get a specific parameter by its ID

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.