Struct rsynth::synth::Synth[][src]

pub struct Synth<T> where
    T: Renderable
{ pub voices: Vec<Voice<T>>, pub steal_mode: StealMode, pub pan_raw: (f32, f32), pub sample_counter: f64, // some fields omitted }

The base structure for handling voices, sounds, and processing

  • T - a struct we create that implements the Renderable trait, and contains all of our DSP code.

Fields

A vector containing multiple objects implementing the Voice trait

What method the synth should use to steal voices (if any)

The raw amp values for panning This can be used in tandem with a state object to set the global panning values every block render, without having to perform an expensive panning formula every time. For instance, we can calculate constant_power_pan in a callback every time the pan knob is moved and assign that value to a tuple. Then, before calling the render_next method on our synth, we can set the pan_raw field to our aforementioned tuple. Note that although the framework supports any number of outputs, panning is currently only supported with stereo.

The number of samples passed since the plugin started. Can represent 24372 centuries of samples at 48kHz, so wrapping shouldn't be a problem.

Methods

impl<T> Synth<T> where
    T: Renderable
[src]

Constructor for the Synthesizer utilizing a builder pattern

Set voices using the builder

  • voices - A vector containing any number of Voice structures. If our instrument is polyphonic, the number of voices will determine the maximum amount of notes it can play at once.

Set the sample rate using the builder. This is also useful after the Synth is finalized if the host sample rate is changed, or a voice is added during execution with default filling in the sample rate.

  • sample_rate - set the sample rate of our instrument

Set the note steal mode using the builder

  • steal_mode - this determines how "voice stealing" will be implemented, if at all.

Finalize the builder and return an immutable Synth

Set the panning for the entire instrument This is done via a function instead of directly setting the field as the formula is potentially costly and should only be calculated when needed. For instance, do not use this function in a loop for every sample. Instead, update the value only when parameters change. If you need to set the panning every block render, consider accessing the pan_raw field directly.

  • amount - a float value between -1 and 1 where 0 is center and 1 is to the right. Values not within this range will be

Modify an audio buffer with rendered audio from the voice

  • buffer - the audio buffer to modify

Process events from the plugin host. This is useful if you are responding to MIDI notes and data.

  • events - a reference to an Events structure from the vst::api::Events module.

Trait Implementations

impl<T> Default for Synth<T> where
    T: Renderable
[src]

Get default values This is only really useful with our internal builder methods. If we try something like let s = { sample_rate: 48_000, .. Synthesizer::default() }; the compiler will complain that some fields are private.

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl<T> Send for Synth<T> where
    T: Send

impl<T> !Sync for Synth<T>