pub struct ParameterNumberMessageScanner { /* private fields */ }
Expand description

Scanner for detecting (N)RPN messages in a stream of short messages without polling.

Supports the following message sequences (x and y represent the bytes that make up the parameter number, MSB represents either a data entry MSB or an increment/decrement value):

  • [x, y, MSB]: Interpreted as 7-bit data entry or increment/decrement message.
  • [x, y, LSB, MSB]: Interpreted as 14-bit data entry message.
  • [x, y, MSB, MSB, ...]: Interpreted as 7-bit data entry or increment/decrement messages.
  • [x, y, LSB, MSB, LSB, MSB, ...]: Interpreted as 14-bit data entry messages.

Example

use helgoboss_midi::test_util::{control_change, channel, u14};
use helgoboss_midi::{ParameterNumberMessage, ParameterNumberMessageScanner};

let mut scanner = ParameterNumberMessageScanner::new();
let result_1 = scanner.feed(&control_change(0, 101, 3));
let result_2 = scanner.feed(&control_change(0, 100, 36));
let result_3 = scanner.feed(&control_change(0, 38, 24));
let result_4 = scanner.feed(&control_change(0, 6, 117));
assert_eq!(result_1, None);
assert_eq!(result_2, None);
assert_eq!(result_3, None);
assert_eq!(
    result_4,
    Some(ParameterNumberMessage::registered_14_bit(
        channel(0),
        u14(420),
        u14(15000)
    ))
);

Implementations

Creates a new scanner.

Feeds the scanner a single short message.

Returns the (N)RPN message if one has been detected.

Resets the scanner discarding all intermediate scanning progress.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.