HostInterface

Trait HostInterface 

Source
pub trait HostInterface {
    // Required method
    fn output_initialized(&self) -> bool;

    // Provided method
    fn stop(&mut self) { ... }
}
Expand description

Defines an interface for communicating with the host or server of the backend, e.g. the VST host when using VST or the Jack server when using Jack.

Required Methods§

Source

fn output_initialized(&self) -> bool

Return whether the output buffers are zero-initialized. Returns false when in doubt.

§Example

The following example illustrates how output_initialized() can be used in combination with the set method on AudioBufferOut to initialize the output buffers to zero in an implementation of the [ContextualAudioRenderer] trait.

use rsynth::ContextualAudioRenderer;
use rsynth::backend::HostInterface;
use rsynth::buffer::AudioBufferInOut;
struct MyPlugin { /* ... */ }
impl<H> ContextualAudioRenderer<f32, H> for MyPlugin
where H: HostInterface
{
    fn render_buffer(
        &mut self,
        buffer: &mut AudioBufferInOut<f32>,
        context: &mut H)
    {
        if ! context.output_initialized() {
            buffer.outputs().set(0.0);
        }
        // The rest of the audio rendering.
    }
}

Provided Methods§

Source

fn stop(&mut self)

Stop processing. For backends that do not support stopping, this is a no-op. For back-ends that do support stopping and that implement the Stop trait, this stops the processing.

Implementors§

Source§

impl HostInterface for HostCallback

Source§

impl<'c, 'mp, 'mw> HostInterface for JackHost<'c, 'mp, 'mw>