Struct Synthesizer

Source
#[non_exhaustive]
pub struct Synthesizer { /* private fields */ }
Expand description

An instance of the SoundFont synthesizer.

Implementations§

Source§

impl Synthesizer

Source

pub const CHANNEL_COUNT: usize = 16usize

The number of channels.

Source

pub const PERCUSSION_CHANNEL: usize = 9usize

The percussion channel.

Source

pub fn new( sound_font: &Arc<SoundFont>, settings: &SynthesizerSettings, ) -> Result<Self, SynthesizerError>

Initializes a new synthesizer using a specified SoundFont and settings.

§Arguments
  • sound_font - The SoundFont instance.
  • settings - The settings for synthesis.
Source

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.
Source

pub fn note_off(&mut self, channel: i32, key: i32)

Stops a note.

§Arguments
  • channel - The channel of the note.
  • key - The key of the note.
Source

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.
Source

pub fn note_off_all(&mut self, immediate: bool)

Stops all the notes in the specified channel.

§Arguments
  • immediate - If true, notes will stop immediately without the release sound.
Source

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 - If true, notes will stop immediately without the release sound.
Source

pub fn reset_all_controllers(&mut self)

Resets all the controllers.

Source

pub fn reset_all_controllers_channel(&mut self, channel: i32)

Resets all the controllers of the specified channel.

§Arguments
  • channel - The channel to be reset.
Source

pub fn reset(&mut self)

Resets the synthesizer.

Source

pub fn render(&mut self, left: &mut [f32], right: &mut [f32])

Renders the waveform.

§Arguments
  • left - The buffer of the left channel to store the rendered waveform.
  • right - The buffer of the right channel to store the rendered waveform.
§Remarks

The output buffers for the left and right must be the same length.

Source

pub fn get_sound_font(&self) -> &SoundFont

Gets the SoundFont used as the audio source.

Source

pub fn get_sample_rate(&self) -> i32

Gets the sample rate for synthesis.

Source

pub fn get_block_size(&self) -> usize

Gets the block size for rendering waveform.

Source

pub fn get_maximum_polyphony(&self) -> usize

Gets the number of maximum polyphony.

Source

pub fn get_enable_reverb_and_chorus(&self) -> bool

Gets the value indicating whether reverb and chorus are enabled.

Source

pub fn get_master_volume(&self) -> f32

Gets the master volume.

Source

pub fn set_master_volume(&mut self, value: f32)

Sets the master volume.

§Arguments
  • value - The new value of the master volume.

Trait Implementations§

Source§

impl Debug for Synthesizer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.