Skip to main content

SamplerVoice

Struct SamplerVoice 

Source
pub struct SamplerVoice {
Show 13 fields pub note: u8, pub channel: u8, pub velocity: f32, pub position: f64, pub pitch_ratio: f64, pub volume: f32, pub phase: VoicePhase, pub envelope: EnvelopeState, pub zone_id: String, pub articulation: ArticulationType, pub loop_start: usize, pub loop_end: usize, pub key_held: bool,
}
Expand description

One active voice in the sampler.

Fields§

§note: u8

MIDI note number.

§channel: u8

MIDI channel.

§velocity: f32

Velocity (0.0–1.0).

§position: f64

Current playback position in frames (sub-sample precision).

§pitch_ratio: f64

Playback speed ratio (accounts for pitch shifting).

§volume: f32

Volume multiplier from zone + velocity.

§phase: VoicePhase

Current lifecycle phase.

§envelope: EnvelopeState

ADSR envelope.

§zone_id: String

Zone id this voice is playing.

§articulation: ArticulationType

Articulation type (cached from zone).

§loop_start: usize

Loop start frame (if sustain loop).

§loop_end: usize

Loop end frame (if sustain loop).

§key_held: bool

Whether the key is still held.

Implementations§

Source§

impl SamplerVoice

Source

pub fn new( note: u8, channel: u8, velocity: f32, pitch_ratio: f64, volume: f32, zone: &SampleZone, ) -> Self

Source

pub fn release(&mut self)

Signal key release.

Source

pub fn is_done(&self) -> bool

Is this voice finished?

Source

pub fn advance(&mut self, buffer_frames: usize) -> f64

Advance position by one sample, handling loop points. Returns the current frame position for sample lookup.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.