Skip to main content

Pckn

Struct Pckn 

Source
pub struct Pckn {
    pub port_index: Match<u16>,
    pub channel: Match<u16>,
    pub key: Match<u16>,
    pub note_id: Match<u32>,
}
Expand description

A Port, Channel, Key, NoteId (PCKN) tuple.

CLAP addresses notes and voices use this 4-value tuple: port, channel, key and note_id. Each of the components in this PCKN can either be a specific value, or a wildcard that matches any value in that part of the tuple. This is representing using the Match enum.

For instance, a Pckn of (0, 3, All, All) will match all voices on channel 3 of port 0. And a Pckn of (All, 0, 60, All) will match all channel 0 key 60 voices, independent of port or note id.

See the matches for an implementation of the PCKN matching logic that you can use to match incoming events against active voices.

Fields§

§port_index: Match<u16>

The Note Port the plugin received this event on. See the Note Ports extension.

§channel: Match<u16>

The Channel the note is on, akin to MIDI1 channels. This is usually in the 0..=15 range.

§key: Match<u16>

The note’s Key. This is the same representation as MIDI1 Key numbers, 60 being a Middle C, and is in the 0..=127 range.

§note_id: Match<u32>

The unique ID of this note. This is used to distinguish between multiple overlapping notes that play the same key. This is in the 0..i32::MAX range.

Implementations§

Source§

impl Pckn

Source

pub fn new( port: impl Into<Match<u16>>, channel: impl Into<Match<u16>>, key: impl Into<Match<u16>>, note_id: impl Into<Match<u32>>, ) -> Pckn

Constructs a new PCKN tuple from each of its components.

Source

pub const fn match_all() -> Pckn

Returns a Pckn tuple that matches all events, i.e. all of its components are set to Match::All.

Source

pub const fn matches_all(&self) -> bool

Returns whether this Pckn tuple matches all possible notes.

This is true if all four matchers are set to Match::All.

Source

pub fn matches(&self, other: &Pckn) -> bool

Returns true if this PCKN tuple matches the given one, considering both specific values and wildcard Match::All values.

§Examples
use clack_common::events::{Match, Pckn};

assert!(Pckn::new(0u16, 0u16, 60u16, 42u32).matches(&Pckn::new(0u16, 0u16, 60u16, Match::All)));
Source

pub const fn from_raw(port: i16, channel: i16, key: i16, note_id: i32) -> Pckn

Constructs a new PCKN tuple from its raw, C-FFI compatible components.

Components set to any negative value (usually -1) are interpreted as Match::All, while any other value is interpreted as Match::Specific.

Source

pub const fn raw_port_index(&self) -> i16

Returns the raw, C-FFI compatible Port component of this PCKN.

This returns -1 if the port is set to Match::All, otherwise the specific value is returned.

Source

pub const fn raw_channel(&self) -> i16

Returns the raw, C-FFI compatible Channel component of this PCKN.

This returns -1 if the Channel is set to Match::All, otherwise the specific value is returned.

Source

pub const fn raw_key(&self) -> i16

Returns the raw, C-FFI compatible Key component of this PCKN.

This returns -1 if the Key is set to Match::All, otherwise the specific value is returned.

Source

pub const fn raw_note_id(&self) -> i32

Returns the raw, C-FFI compatible Note ID component of this PCKN.

This returns -1 if the Note ID is set to Match::All, otherwise the specific value is returned.

Trait Implementations§

Source§

impl Clone for Pckn

Source§

fn clone(&self) -> Pckn

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Pckn

Source§

impl Debug for Pckn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Pckn

Source§

impl Hash for Pckn

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Pckn

Source§

fn eq(&self, other: &Pckn) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Pckn

Auto Trait Implementations§

§

impl Freeze for Pckn

§

impl RefUnwindSafe for Pckn

§

impl Send for Pckn

§

impl Sync for Pckn

§

impl Unpin for Pckn

§

impl UnsafeUnpin for Pckn

§

impl UnwindSafe for Pckn

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.