pub struct VoicePool { /* private fields */ }Expand description
A polyphony-limited pool of voices that emits scheduled tones as voices finish or are stolen.
Implementations§
Source§impl VoicePool
impl VoicePool
Sourcepub fn new(polyphony_limit: usize) -> Result<Self, SoundBridgeError>
pub fn new(polyphony_limit: usize) -> Result<Self, SoundBridgeError>
Builds a pool with the given polyphony limit, rejecting a limit of zero.
Sourcepub fn polyphony_limit(&self) -> usize
pub fn polyphony_limit(&self) -> usize
Returns the maximum number of simultaneous voices.
Sourcepub fn active_voice_count(&self) -> usize
pub fn active_voice_count(&self) -> usize
Returns the number of currently active voices.
Sourcepub fn emitted(&self) -> &[ScheduledTone]
pub fn emitted(&self) -> &[ScheduledTone]
Returns the scheduled tones emitted but not yet drained.
Sourcepub fn stolen_voice_count(&self) -> usize
pub fn stolen_voice_count(&self) -> usize
Returns the running count of stolen voices.
Sourcepub fn drain_emitted(&mut self) -> Vec<ScheduledTone>
pub fn drain_emitted(&mut self) -> Vec<ScheduledTone>
Drains and returns the emitted scheduled tones, clearing the buffer.
Sourcepub fn note_on(&mut self, voice: Voice, now: Duration)
pub fn note_on(&mut self, voice: Voice, now: Duration)
Starts a new voice at now, retiring any same-key voice and stealing a
voice if the polyphony limit is reached.
Sourcepub fn note_off(&mut self, channel: u8, key: u8, now: Duration, sustain: bool)
pub fn note_off(&mut self, channel: u8, key: u8, now: Duration, sustain: bool)
Releases the most recent voice matching channel/key, holding it
under the sustain pedal when sustain is set.
Sourcepub fn release_channel_sustain(&mut self, channel: u8, now: Duration)
pub fn release_channel_sustain(&mut self, channel: u8, now: Duration)
Releases all sustain-held voices on channel at now.
Sourcepub fn transpose_channel_cents(&mut self, channel: u8, cents: f64)
pub fn transpose_channel_cents(&mut self, channel: u8, cents: f64)
Shifts the frequency of all non-released voices on channel by cents.
Sourcepub fn reap_finished(&mut self, now: Duration)
pub fn reap_finished(&mut self, now: Duration)
Emits and removes voices whose release stage has completed by now.