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

Retunes one or multiple MIDI notes using the Single Note Tuning Change message format.

Implementations

Creates a SingleNoteTuningChangeMessage from the provided tuning and keys.

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

let tuning_message = SingleNoteTuningChangeMessage::from_tuning(
    &Default::default(),
    (scl, kbm),
    (21..109).map(PianoKey::from_midi_number),
)
.unwrap();

assert_eq!(tuning_message.sysex_bytes().count(), 1);
assert_eq!(tuning_message.out_of_range_notes().len(), 13);

Creates a SingleNoteTuningChangeMessage from the provided tuning_changes.

Examples
let key = NoteLetter::A.in_octave(4).as_piano_key();

let good = SingleNoteTuningChange { key, target_pitch: Pitch::from_hz(445.0) };
let too_low = SingleNoteTuningChange { key, target_pitch: Pitch::from_hz(1.0) };
let too_high = SingleNoteTuningChange { key, target_pitch: Pitch::from_hz(100000.0) };

let tuning_message = SingleNoteTuningChangeMessage::from_tuning_changes(
    &Default::default(), [good, too_low, too_high]
)
.unwrap();

assert_eq!(tuning_message.sysex_bytes().count(), 1);
assert_eq!(tuning_message.out_of_range_notes(), [too_low, too_high]);

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. If the number of retuned notes is 0 no message is yielded.

Examples
let create_tuning_message_with_num_changes = |num_changes| {
    let tuning_changes = (0..num_changes).map(|midi_number| {
        SingleNoteTuningChange {
            key: PianoKey::from_midi_number(midi_number),
            target_pitch: Note::from_midi_number(midi_number).pitch(),
        }
    });

    SingleNoteTuningChangeMessage::from_tuning_changes(
        &Default::default(),
        tuning_changes,
    )
    .unwrap()
};

assert_eq!(create_tuning_message_with_num_changes(0).sysex_bytes().count(), 0);
assert_eq!(create_tuning_message_with_num_changes(127).sysex_bytes().count(), 1);
assert_eq!(create_tuning_message_with_num_changes(128).sysex_bytes().count(), 2);

Return notes whose target pitch is not representable by the tuning message.

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

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.