Struct tune::mts::SingleNoteTuningChangeMessage[][src]

pub struct SingleNoteTuningChangeMessage { /* fields omitted */ }

Implementations

impl SingleNoteTuningChangeMessage[src]

pub fn from_tuning(
    tuning: impl KeyboardMapping<PianoKey>,
    keys: impl IntoIterator<Item = PianoKey>,
    device_id: DeviceId,
    tuning_program: u8
) -> Result<Self, SingleNoteTuningChangeError>
[src]

pub fn from_tuning_changes(
    tuning_changes: impl IntoIterator<Item = SingleNoteTuningChange>,
    device_id: DeviceId,
    tuning_program: u8
) -> Result<Self, SingleNoteTuningChangeError>
[src]

Creates a SingleNoteTuningChangeMessage from the provided tuning_changes.

Examples

let a4 = NoteLetter::A.in_octave(4).as_piano_key();
let target_pitch = Pitch::from_hz(445.0);

let tuning_changes = std::iter::once(SingleNoteTuningChange::new(a4, target_pitch));
let tuning_message = SingleNoteTuningChangeMessage::from_tuning_changes(
    tuning_changes,
    Default::default(),
    55,
)
.unwrap();

assert_eq!(
    Vec::from_iter(tuning_message.sysex_bytes()),
    [[0xf0, 0x7f, 0x7f, 0x08, 0x02, 55, 1, 69, 69, 25, 5, 0xf7]]
);

pub fn sysex_bytes(&self) -> impl Iterator<Item = &[u8]>[src]

Returns the tuning message conforming to the MIDI tuning standard.

If less than 128 notes are retuned the iterator yields a single tuning message. If the number of retuned notes is 128 two messages with a batch of 64 notes are yielded.

Examples

let scl = Scl::builder()
    .push_ratio(Ratio::octave().divided_into_equal_steps(31))
    .build()
    .unwrap();
let kbm = KbmRoot::from(NoteLetter::D.in_octave(4)).to_kbm();
let tuning = (scl, kbm);

let single_message = SingleNoteTuningChangeMessage::from_tuning(
    &tuning,
    (0..127).map(PianoKey::from_midi_number),
    Default::default(),
    0,
)
.unwrap();
assert_eq!(Vec::from_iter(single_message.sysex_bytes()).len(), 1);

let split_message = SingleNoteTuningChangeMessage::from_tuning(
    &tuning,
    (0..128).map(PianoKey::from_midi_number),
    Default::default(),
    0,
)
.unwrap();
assert_eq!(Vec::from_iter(split_message.sysex_bytes()).len(), 2);

pub fn retuned_notes(&self) -> &[SingleNoteTuningChange][src]

pub fn out_of_range_notes(&self) -> &[SingleNoteTuningChange][src]

Trait Implementations

impl Clone for SingleNoteTuningChangeMessage[src]

impl Debug for SingleNoteTuningChangeMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.