Struct ControlChange14BitMessage

Source
pub struct ControlChange14BitMessage { /* private fields */ }
Expand description

A 14-bit MIDI Control Change message.

Unlike a ShortMessage of type ShortMessageType::ControlChange, this one supports 14-bit resolution, that means 16384 different values instead of only 128. MIDI systems emit those by sending 2 short Control Change messages in a row. The ControlChange14BitMessageScanner can be used to extract such messages from a stream of ShortMessages.

§Example

use helgoboss_midi::{
    controller_numbers, Channel, ControlChange14BitMessage, RawShortMessage, U14,
};

let msg = ControlChange14BitMessage::new(
    Channel::new(5),
    controller_numbers::CHANNEL_VOLUME,
    U14::new(1057),
);
assert_eq!(msg.channel().get(), 5);
assert_eq!(msg.msb_controller_number().get(), 7);
assert_eq!(
    msg.lsb_controller_number(),
    controller_numbers::CHANNEL_VOLUME_LSB
);
use helgoboss_midi::test_util::control_change;
assert_eq!(msg.value().get(), 1057);
let short_messages: [RawShortMessage; 2] = msg.to_short_messages();
assert_eq!(
    short_messages,
    [control_change(5, 7, 8), control_change(5, 39, 33)]
);

Implementations§

Source§

impl ControlChange14BitMessage

Source

pub fn new( channel: Channel, msb_controller_number: ControllerNumber, value: U14, ) -> ControlChange14BitMessage

Creates a 14-bit Control Change message.

§Panics

This function panics if msb_controller_number can’t serve as controller number for transmitting the most significant byte of a 14-bit Control Change message.

Source

pub fn channel(&self) -> Channel

Returns the channel of this message.

Source

pub fn msb_controller_number(&self) -> ControllerNumber

Returns the controller number for transmitting the most significant byte of this message.

Source

pub fn lsb_controller_number(&self) -> ControllerNumber

Returns the controller number for transmitting the least significant byte of this message.

Source

pub fn value(&self) -> U14

Returns the 14-bit value of this message.

Source

pub fn to_short_messages<T: ShortMessageFactory>(&self) -> [T; 2]

Translates this message into 2 short messages, which need to be sent in a row in order to encode this 14-bit Control Change message.

Trait Implementations§

Source§

impl Clone for ControlChange14BitMessage

Source§

fn clone(&self) -> ControlChange14BitMessage

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ControlChange14BitMessage

Source§

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

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

impl<T: ShortMessageFactory> From<ControlChange14BitMessage> for [T; 2]

Source§

fn from(msg: ControlChange14BitMessage) -> Self

Converts to this type from the input type.
Source§

impl Hash for ControlChange14BitMessage

Source§

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

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 ControlChange14BitMessage

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ControlChange14BitMessage

Source§

impl Eq for ControlChange14BitMessage

Source§

impl StructuralPartialEq for ControlChange14BitMessage

Auto Trait Implementations§

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.