pub struct ConstantMask(/* private fields */);Expand description
A hint that indicates which channels of an audio port are constant.
Channels are defined as constant when all of their samples have the exact same value. This
however doesn’t mean they are silent: the value could be different from 0.
This type is internally by a 64-bit bitmask, as per the CLAP specification, hence its name. This also means a constant mask can only hold constant hints for up to 64 channels: information about any extra channels is lost, and this implementation considers those channels to never be constant.
§Example
use clack_common::process::ConstantMask;
let mut constant_mask = ConstantMask::from_bits(0b101);
assert!(constant_mask.is_channel_constant(0));
assert!(!constant_mask.is_channel_constant(1));
assert!(constant_mask.is_channel_constant(2));
constant_mask.set_channel_constant(1, true);
assert!(constant_mask.is_channel_constant(1));
assert_eq!(0b111, constant_mask.to_bits());
Implementations§
Source§impl ConstantMask
impl ConstantMask
Sourcepub const CAPACITY: u8 = 64
pub const CAPACITY: u8 = 64
The capacity, in bits, of a ConstantMask.
This is how many channels can be represented in a ConstantMask.
Sourcepub const FULLY_CONSTANT: ConstantMask
pub const FULLY_CONSTANT: ConstantMask
A ConstantMask that represents all 64 possible channels as being fully constant.
This constant mask has all its bits set to 1.
Sourcepub const FULLY_DYNAMIC: ConstantMask
pub const FULLY_DYNAMIC: ConstantMask
A ConstantMask that represents all 64 possible channels as being fully dynamic.
This constant mask has all its bits set to 0.
Sourcepub const fn from_bits(bits: u64) -> ConstantMask
pub const fn from_bits(bits: u64) -> ConstantMask
Creates a new constant mask from its inner bitmask representation.
Sourcepub const fn iter(&self) -> ConstantMaskIter ⓘ
pub const fn iter(&self) -> ConstantMaskIter ⓘ
Returns an iterator over the constant status of each channel in this constant mask.
§Example
use clack_common::process::ConstantMask;
let mut iter = ConstantMask::from_bits(0b101).iter();
assert_eq!(Some(true), iter.next());
assert_eq!(Some(false), iter.next());
assert_eq!(Some(true), iter.next());
assert_eq!(Some(false), iter.next());
assert_eq!(Some(false), iter.next());Sourcepub const fn is_channel_constant(&self, channel_index: u64) -> bool
pub const fn is_channel_constant(&self, channel_index: u64) -> bool
Returns true if the channel at the given index is constant, false otherwise.
This function will always return false when given any index over 63.
Sourcepub const fn set_channel_constant(&mut self, channel_index: u64, value: bool)
pub const fn set_channel_constant(&mut self, channel_index: u64, value: bool)
Sets whether the channel at the given index is constant.
This function does nothing when given any index over 63.
Trait Implementations§
Source§impl BitAnd for ConstantMask
impl BitAnd for ConstantMask
Source§type Output = ConstantMask
type Output = ConstantMask
& operator.Source§fn bitand(self, rhs: ConstantMask) -> <ConstantMask as BitAnd>::Output
fn bitand(self, rhs: ConstantMask) -> <ConstantMask as BitAnd>::Output
& operation. Read moreSource§impl BitAndAssign for ConstantMask
impl BitAndAssign for ConstantMask
Source§fn bitand_assign(&mut self, rhs: ConstantMask)
fn bitand_assign(&mut self, rhs: ConstantMask)
&= operation. Read moreSource§impl BitOr for ConstantMask
impl BitOr for ConstantMask
Source§type Output = ConstantMask
type Output = ConstantMask
| operator.Source§fn bitor(self, rhs: ConstantMask) -> <ConstantMask as BitOr>::Output
fn bitor(self, rhs: ConstantMask) -> <ConstantMask as BitOr>::Output
| operation. Read moreSource§impl BitOrAssign for ConstantMask
impl BitOrAssign for ConstantMask
Source§fn bitor_assign(&mut self, rhs: ConstantMask)
fn bitor_assign(&mut self, rhs: ConstantMask)
|= operation. Read moreSource§impl BitXor for ConstantMask
impl BitXor for ConstantMask
Source§type Output = ConstantMask
type Output = ConstantMask
^ operator.Source§fn bitxor(self, rhs: ConstantMask) -> <ConstantMask as BitXor>::Output
fn bitxor(self, rhs: ConstantMask) -> <ConstantMask as BitXor>::Output
^ operation. Read moreSource§impl BitXorAssign for ConstantMask
impl BitXorAssign for ConstantMask
Source§fn bitxor_assign(&mut self, rhs: ConstantMask)
fn bitxor_assign(&mut self, rhs: ConstantMask)
^= operation. Read moreSource§impl Clone for ConstantMask
impl Clone for ConstantMask
Source§fn clone(&self) -> ConstantMask
fn clone(&self) -> ConstantMask
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ConstantMask
Source§impl Debug for ConstantMask
impl Debug for ConstantMask
Source§impl Default for ConstantMask
impl Default for ConstantMask
Source§fn default() -> ConstantMask
fn default() -> ConstantMask
Returns an empty constant mask, i.e. one where every channel is considered dynamic.