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>
impl<'a> PortPair<'a>
Sourcepub fn output(&mut self) -> Option<OutputPort<'_>>
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.
Sourcepub fn input_info(&self) -> Option<AudioPortProcessingInfo>
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.
Sourcepub fn output_info(&self) -> Option<AudioPortProcessingInfo>
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.
Sourcepub fn channels(
&mut self,
) -> Result<SampleType<PairedChannels<'a, f32>, PairedChannels<'a, f64>>, BufferError>
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();Sourcepub fn channel_pair_count(&self) -> usize
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.
Sourcepub fn frames_count(&self) -> u32
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.
Sourcepub fn latencies(&self) -> (Option<u32>, Option<u32>)
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.
Sourcepub fn constant_masks(&self) -> (ConstantMask, ConstantMask)
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.