Struct Synthesizer
#[non_exhaustive]pub struct Synthesizer {Show 14 fields
pub(crate) sound_font: Arc<SoundFont>,
pub(crate) sample_rate: i32,
pub(crate) block_size: usize,
pub(crate) maximum_polyphony: usize,
preset_lookup: HashMap<i32, usize>,
default_preset: usize,
channels: Vec<Channel>,
voices: VoiceCollection,
block_left: Vec<f32>,
block_right: Vec<f32>,
inverse_block_size: f32,
block_read: usize,
master_volume: f32,
effects: Option<Effects>,
}Expand description
An instance of the SoundFont synthesizer.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sound_font: Arc<SoundFont>§sample_rate: i32§block_size: usize§maximum_polyphony: usize§preset_lookup: HashMap<i32, usize>§default_preset: usize§channels: Vec<Channel>§voices: VoiceCollection§block_left: Vec<f32>§block_right: Vec<f32>§inverse_block_size: f32§block_read: usize§master_volume: f32§effects: Option<Effects>Implementations§
§impl Synthesizer
impl Synthesizer
pub const CHANNEL_COUNT: usize = 16
pub const CHANNEL_COUNT: usize = 16
The number of channels.
pub const PERCUSSION_CHANNEL: usize = 9
pub const PERCUSSION_CHANNEL: usize = 9
The percussion channel.
pub fn new(
sound_font: &Arc<SoundFont>,
settings: &SynthesizerSettings,
) -> Result<Synthesizer, SynthesizerError>
pub fn new( sound_font: &Arc<SoundFont>, settings: &SynthesizerSettings, ) -> Result<Synthesizer, SynthesizerError>
Initializes a new synthesizer using a specified SoundFont and settings.
§Arguments
sound_font- The SoundFont instance.settings- The settings for synthesis.
pub fn process_midi_message(
&mut self,
channel: i32,
command: i32,
data1: i32,
data2: i32,
)
pub fn process_midi_message( &mut self, channel: i32, command: i32, data1: i32, data2: i32, )
Processes a MIDI message.
§Arguments
channel- The channel to which the message will be sent.command- The type of the message.data1- The first data part of the message.data2- The second data part of the message.
pub fn note_on(&mut self, channel: i32, key: i32, velocity: i32)
pub fn note_on(&mut self, channel: i32, key: i32, velocity: i32)
Starts a note.
§Arguments
channel- The channel of the note.key- The key of the note.velocity- The velocity of the note.
pub fn note_off_all(&mut self, immediate: bool)
pub fn note_off_all(&mut self, immediate: bool)
Stops all the notes in the specified channel.
§Arguments
immediate- Iftrue, notes will stop immediately without the release sound.
pub fn note_off_all_channel(&mut self, channel: i32, immediate: bool)
pub fn note_off_all_channel(&mut self, channel: i32, immediate: bool)
Stops all the notes in the specified channel.
§Arguments
channel- The channel in which the notes will be stopped.immediate- Iftrue, notes will stop immediately without the release sound.
pub fn reset_all_controllers(&mut self)
pub fn reset_all_controllers(&mut self)
Resets all the controllers.
pub fn reset_all_controllers_channel(&mut self, channel: i32)
pub fn reset_all_controllers_channel(&mut self, channel: i32)
pub fn reset(&mut self)
pub fn reset(&mut self)
Resets the synthesizer.
pub fn get_sound_font(&self) -> &SoundFont
pub fn get_sound_font(&self) -> &SoundFont
Gets the SoundFont used as the audio source.
pub fn get_sample_rate(&self) -> i32
pub fn get_sample_rate(&self) -> i32
Gets the sample rate for synthesis.
pub fn get_block_size(&self) -> usize
pub fn get_block_size(&self) -> usize
Gets the block size for rendering waveform.
pub fn get_maximum_polyphony(&self) -> usize
pub fn get_maximum_polyphony(&self) -> usize
Gets the number of maximum polyphony.
pub fn get_enable_reverb_and_chorus(&self) -> bool
pub fn get_enable_reverb_and_chorus(&self) -> bool
Gets the value indicating whether reverb and chorus are enabled.
pub fn get_master_volume(&self) -> f32
pub fn get_master_volume(&self) -> f32
Gets the master volume.
pub fn set_master_volume(&mut self, value: f32)
pub fn set_master_volume(&mut self, value: f32)
Trait Implementations§
Auto Trait Implementations§
impl Forget for Synthesizer
impl Freeze for Synthesizer
impl RefUnwindSafe for Synthesizer
impl Send for Synthesizer
impl Sync for Synthesizer
impl Unpin for Synthesizer
impl UnsafeUnpin for Synthesizer
impl UnwindSafe for Synthesizer
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for Twhere
T: 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.