From 841ec96d2d943559a62cfadd453cf0da5eca63f4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 8 Nov 2022 19:36:07 +0100 Subject: [PATCH] Use Rust range notation for NoteEvent docs #42 Apparently `from x to y` is ambiguous, so we now use the Rust `x..y` syntax instead. --- src/midi.rs | 81 ++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/src/midi.rs b/src/midi.rs index 27fe7343..be2a7370 100644 --- a/src/midi.rs +++ b/src/midi.rs @@ -26,8 +26,7 @@ pub enum MidiConfig { /// [`util`][crate::util] module for convenient conversion functions. /// /// All of the timings are sample offsets withing the current buffer. All sample, channel and note -/// numbers are zero-indexed. All integer `from n to m` are exclusive, and they are equivalent to -/// the `n..m` range in Rust. +/// numbers are zero-indexed. #[derive(Debug, Clone, Copy, PartialEq)] #[non_exhaustive] pub enum NoteEvent { @@ -37,12 +36,12 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's velocity, in the range `[0, 1]`. Some plugin APIs may allow higher precision - /// than the 128 levels available in MIDI. + /// The note's velocity, in `[0, 1]`. Some plugin APIs may allow higher precision than the + /// 128 levels available in MIDI. velocity: f32, }, /// A note off event, available on [`MidiConfig::Basic`] and up. Bitwig Studio does not provide @@ -52,12 +51,12 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's velocity, in the range `[0, 1]`. Some plugin APIs may allow higher precision - /// than the 128 levels available in MIDI. + /// The note's velocity, in `[0, 1]`. Some plugin APIs may allow higher precision than the + /// 128 levels available in MIDI. velocity: f32, }, /// A note choke event, available on [`MidiConfig::Basic`] and up. When the host sends this to @@ -68,9 +67,9 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, }, @@ -82,9 +81,9 @@ pub enum NoteEvent { /// The voice's unique identifier. Setting this allows a single voice to be terminated if /// the plugin allows multiple overlapping voices for a single key. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, }, /// A polyphonic modulation event, available on [`MidiConfig::Basic`] and up. This will only be @@ -165,11 +164,11 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's pressure, in the range `[0, 1]`. + /// The note's pressure, in `[0, 1]`. pressure: f32, }, /// A volume expression event, available on [`MidiConfig::Basic`] and up. Not all hosts may @@ -179,9 +178,9 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, /// The note's voltage gain ratio, where 1.0 is unity gain. gain: f32, @@ -193,11 +192,11 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's panning from, in the range `[-1, 1]`, with -1 being panned hard left, and 1 + /// The note's panning from, in `[-1, 1]`, with -1 being panned hard left, and 1 /// being panned hard right. pan: f32, }, @@ -208,11 +207,11 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's tuning in semitones, in the range `[-128, 128]`. + /// The note's tuning in semitones, in `[-128, 128]`. tuning: f32, }, /// A vibrato expression event, available on [`MidiConfig::Basic`] and up. Not all hosts may support @@ -222,11 +221,11 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's vibrato amount, in the range `[0, 1]`. + /// The note's vibrato amount, in `[0, 1]`. vibrato: f32, }, /// A expression expression (yes, expression expression) event, available on @@ -236,11 +235,11 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's expression amount, in the range `[0, 1]`. + /// The note's expression amount, in `[0, 1]`. expression: f32, }, /// A brightness expression event, available on [`MidiConfig::Basic`] and up. Not all hosts may support @@ -250,17 +249,17 @@ pub enum NoteEvent { /// A unique identifier for this note, if available. Using this to refer to a note is /// required when allowing overlapping voices for CLAP plugins. voice_id: Option, - /// The note's channel, from 0 to 16. + /// The note's channel, in `0..16`. channel: u8, - /// The note's MIDI key number, from 0 to 128. + /// The note's MIDI key number, in `0..128`. note: u8, - /// The note's brightness amount, in the range `[0, 1]`. + /// The note's brightness amount, in `[0, 1]`. brightness: f32, }, /// A MIDI channel pressure event, available on [`MidiConfig::MidiCCs`] and up. MidiChannelPressure { timing: u32, - /// The affected channel, from 0 to 16. + /// The affected channel, in `0..16`. channel: u8, /// The pressure, normalized to `[0, 1]` to match the poly pressure event. pressure: f32, @@ -268,7 +267,7 @@ pub enum NoteEvent { /// A MIDI pitch bend, available on [`MidiConfig::MidiCCs`] and up. MidiPitchBend { timing: u32, - /// The affected channel, from 0 to 16. + /// The affected channel, in `0..16`. channel: u8, /// The pressure, normalized to `[0, 1]`. `0.5` means no pitch bend. value: f32, @@ -278,11 +277,11 @@ pub enum NoteEvent { /// # Note /// /// The wrapper does not perform any special handling for two message 14-bit CCs (where the CC - /// number is in the range `[0, 31]`, and the next CC is that number plus 32) or for four - /// message RPN messages. For now you will need to handle these CCs yourself. + /// number is in `0..32`, and the next CC is that number plus 32) or for four message RPN + /// messages. For now you will need to handle these CCs yourself. MidiCC { timing: u32, - /// The affected channel, from 0 to 16. + /// The affected channel, in `0..16`. channel: u8, /// The control change number. See [`control_change`] for a list of CC numbers. cc: u8, @@ -293,9 +292,9 @@ pub enum NoteEvent { /// cannot receive these events. MidiProgramChange { timing: u32, - /// The affected channel, from 0 to 16. + /// The affected channel, in `0..16`. channel: u8, - /// The program number, from 0 to 128. + /// The program number, in `0..128`. program: u8, }, }