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
impl Pckn
Sourcepub fn new(
port: impl Into<Match<u16>>,
channel: impl Into<Match<u16>>,
key: impl Into<Match<u16>>,
note_id: impl Into<Match<u32>>,
) -> Pckn
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.
Sourcepub const fn match_all() -> Pckn
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.
Sourcepub const fn matches_all(&self) -> bool
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.
Sourcepub fn matches(&self, other: &Pckn) -> bool
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)));Sourcepub const fn from_raw(port: i16, channel: i16, key: i16, note_id: i32) -> Pckn
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.
Sourcepub const fn raw_port_index(&self) -> i16
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.
Sourcepub const fn raw_channel(&self) -> i16
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.
Sourcepub const fn raw_key(&self) -> i16
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.
Sourcepub const fn raw_note_id(&self) -> i32
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.