Skip to main content

PortPair

Struct PortPair 

Source
pub struct PortPair<'a> { /* private fields */ }
Expand description

A pair of Input and Output ports.

Note that in case of asymmetric port layouts (e.g. side-chain), there may not be an associated output port to an input port, or vice-versa. The same goes for paired channels.

In those cases, a given pair will only contain one port instead of two. However, a PortPair is always guaranteed to contain at least one port, be it an input or output.

Implementations§

Source§

impl<'a> PortPair<'a>

Source

pub fn input(&self) -> Option<InputPort<'_>>

Gets the InputPort of this pair.

If the port layout is asymmetric and there is no input port, this returns None.

Source

pub fn output(&mut self) -> Option<OutputPort<'_>>

Gets the OutputPort of this pair.

If the port layout is asymmetric and there is no output port, this returns None.

Source

pub fn input_info(&self) -> Option<AudioPortProcessingInfo>

Retrieves the port info for the input of this pair.

If the port layout is asymmetric and there is no input port, this returns None.

Source

pub fn output_info(&self) -> Option<AudioPortProcessingInfo>

Retrieves the port info for the output of this pair.

If the port layout is asymmetric and there is no output port, this returns None.

Source

pub fn channels( &mut self, ) -> Result<SampleType<PairedChannels<'a, f32>, PairedChannels<'a, f64>>, BufferError>

Retrieves the port pair’s channels.

Because each port can hold either f32 or f64 sample data, this method returns a SampleType enum of the paired channels, to indicate which one the ports holds.

§Errors

This method returns a BufferError::InvalidChannelBuffer if the host provided neither f32 nor f64 buffer type, which is invalid per the CLAP specification.

Additionally, if the two port have different buffer sample types (i.e. one holds f32 and the other holds f64), then a BufferError::MismatchedBufferPair error is returned.

§Example
use clack_plugin::process::audio::{PairedChannels, PortPair, SampleType};

let mut port: PortPair = /* ... */

// Decide what to do using by matching against every possible configuration
match port.channels().unwrap() {
    SampleType::F32(buf) => { /* Process the 32-bit buffers */ },
    SampleType::F64(buf) => { /* Process the 64-bit buffers */ },
    SampleType::Both(buf32, buf64) => { /* We have both types of buffers available */ }
}

// If we're only interested in a single buffer type,
// we can use SampleType's helper methods:
let channels: PairedChannels<f32> = port.channels().unwrap().into_f32().unwrap();
Source

pub fn channel_pair_count(&self) -> usize

The number of channels in this port pair.

Since there may be more channels in one port than in the other, this method also counts the partial ChannelPairs that can be returned, and therefore returns the maximum number of channels between the two ports.

Source

pub fn frames_count(&self) -> u32

Returns the number of frames to process in this block.

This will always match the number of samples of every audio channel buffer. The two ports cannot have different buffer sizes.

Source

pub fn latencies(&self) -> (Option<u32>, Option<u32>)

The latency from and to the audio interface for this port pair, in samples.

This returns a tuple containing the latenciess for the input and output port, respectively.

If one port isn’t present in this pair, then None is returned.

Source

pub fn constant_masks(&self) -> (ConstantMask, ConstantMask)

The ConstantMasks for the two ports.

This returns a tuple containing the ConstantMasks for the input and output port, respectively.

If one port isn’t present in this pair, then ConstantMask::FULLY_CONSTANT is returned.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for PortPair<'a>

§

impl<'a> Freeze for PortPair<'a>

§

impl<'a> RefUnwindSafe for PortPair<'a>

§

impl<'a> Send for PortPair<'a>

§

impl<'a> Sync for PortPair<'a>

§

impl<'a> Unpin for PortPair<'a>

§

impl<'a> UnsafeUnpin for PortPair<'a>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.