Struct ParameterNumberMessage

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

A MIDI Parameter Number message, either registered (RPN) or non-registered (NRPN).

MIDI systems emit those by sending up to 4 short Control Change messages in a row. The ParameterNumberMessageScanner can be used to extract such messages from a stream of ShortMessages.

§Example

use helgoboss_midi::{
    controller_numbers, Channel, ParameterNumberMessage, RawShortMessage, U14,
    DataEntryByteOrder::MsbFirst
};

let msg =
    ParameterNumberMessage::registered_14_bit(Channel::new(0), U14::new(420), U14::new(15000));
assert_eq!(msg.channel().get(), 0);
assert_eq!(msg.number().get(), 420);
assert_eq!(msg.value().get(), 15000);
assert!(msg.is_registered());
assert!(msg.is_14_bit());
let short_messages: [Option<RawShortMessage>; 4] = msg.to_short_messages(MsbFirst);
use helgoboss_midi::test_util::control_change;
assert_eq!(
    short_messages,
    [
        Some(control_change(0, 101, 3)),
        Some(control_change(0, 100, 36)),
        Some(control_change(0, 6, 117)),
        Some(control_change(0, 38, 24)),
    ]
);

Implementations§

Source§

impl ParameterNumberMessage

Source

pub fn non_registered_7_bit( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an NRPN message with a 7-bit data-entry value.

Source

pub fn non_registered_14_bit( channel: Channel, number: U14, value: U14, ) -> ParameterNumberMessage

Creates an NRPN message with a 14-bit data-entry value.

Source

pub fn non_registered_decrement( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an NRPN message with a data decrement value.

Source

pub fn non_registered_increment( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an NRPN message with a data increment value.

Source

pub fn registered_7_bit( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an RPN message with a 7-bit data-entry value.

Source

pub fn registered_14_bit( channel: Channel, number: U14, value: U14, ) -> ParameterNumberMessage

Creates an RPN message with a 14-bit data-entry value.

Source

pub fn registered_decrement( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an RPN message with a data decrement value.

Source

pub fn registered_increment( channel: Channel, number: U14, value: U7, ) -> ParameterNumberMessage

Creates an RPN message with a data increment value.

Source

pub fn channel(&self) -> Channel

Returns the channel of this message.

Source

pub fn number(&self) -> U14

Returns the parameter number of this message.

Source

pub fn value(&self) -> U14

Returns the value of this message.

If it’s just a 7-bit message, the value is <= 127.

Source

pub fn is_14_bit(&self) -> bool

Returns true if this message has a 14-bit value and false if only a 7-bit value.

Source

pub fn is_registered(&self) -> bool

Returns whether this message uses a registered parameter number.

Source

pub fn data_type(&self) -> DataType

Returns the data type of the value in this message.

Source

pub fn to_short_messages<T: ShortMessageFactory>( &self, data_entry_byte_order: DataEntryByteOrder, ) -> [Option<T>; 4]

Translates this message into up to 4 short Control Change messages, which need to be sent in a row in order to encode this (N)RPN message.

If this message has a 14-bit value, all returned short messages are Some and the given data entry byte order is respected. If it has a 7-bit value only, the last short message is None.

Trait Implementations§

Source§

impl Clone for ParameterNumberMessage

Source§

fn clone(&self) -> ParameterNumberMessage

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 ParameterNumberMessage

Source§

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

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

impl<T: ShortMessageFactory> From<ParameterNumberMessage> for [Option<T>; 4]

Source§

fn from(msg: ParameterNumberMessage) -> Self

Converts to this type from the input type.
Source§

impl Hash for ParameterNumberMessage

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 ParameterNumberMessage

Source§

fn eq(&self, other: &ParameterNumberMessage) -> 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 ParameterNumberMessage

Source§

impl Eq for ParameterNumberMessage

Source§

impl StructuralPartialEq for ParameterNumberMessage

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.