pub struct ScaleOctaveTuningOptions {
    pub realtime: bool,
    pub device_id: u8,
    pub channels: Channels,
    pub format: ScaleOctaveTuningFormat,
}
Expand description

Properties of the generated Scale/Octave Tuning message.

Examples

let octave_tuning = ScaleOctaveTuning {
    c: Ratio::from_cents(10.0),
    csh: Ratio::from_cents(-200.0), // Will be clamped
    d: Ratio::from_cents(200.0),    // Will be clamped
    ..Default::default()
};

// Use default options
let options = ScaleOctaveTuningOptions::default();

let tuning_message = ScaleOctaveTuningMessage::from_octave_tuning(
    &options,
    &octave_tuning,
)
.unwrap();

assert_eq!(
    tuning_message.sysex_bytes(),
    [0xf0, 0x7e, 0x7f, 0x08, 0x08,                   // Non-RT Scale/Octave Tuning (1-Byte)
     0b00000011, 0b01111111, 0b01111111,             // Channel bits
     74, 0, 127, 64, 64, 64, 64, 64, 64, 64, 64, 64, // Tuning changes (C - B)
     0xf7]                                           // Sysex end
);

// Use custom options
let options = ScaleOctaveTuningOptions {
    realtime: true,
    device_id: 55,
    channels: HashSet::from([0, 3, 6, 9, 12, 15]).into(),
    format: ScaleOctaveTuningFormat::TwoByte,
};

let tuning_message = ScaleOctaveTuningMessage::from_octave_tuning(
    &options,
    &octave_tuning,
)
.unwrap();

assert_eq!(
    tuning_message.sysex_bytes(),
    [0xf0, 0x7f, 55, 0x08, 0x09,                  // RT Scale/Octave Tuning (2-Byte)
     0b00000010, 0b00100100, 0b01001001,          // Channel bits
     70, 51, 0, 0, 127, 127, 64, 0, 64, 0, 64, 0, // Tuning changes (C - F)
     64, 0, 64, 0, 64, 0, 64, 0, 64, 0, 64, 0,    // Tuning changes (F# - B)
     0xf7]                                        // Sysex end
);

Fields

realtime: bool

If set to true, generate a realtime SysEx message (defaults to false).

device_id: u8

Specifies the device ID (defaults to broadcast/0x7f).

channels: Channels

Specifies the channels that are affected by the tuning change (defaults to Channels::All).

format: ScaleOctaveTuningFormat

Specifies whether to send a 1-byte or 2-byte message (defaults to ScaleOctaveTuningFormat::OneByte).

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

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.