Skip to content

Commit

Permalink
Merge branch 'release/0.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Leadbetter committed May 17, 2024
2 parents 53ef5c1 + e4a6bf5 commit ac5a69f
Show file tree
Hide file tree
Showing 34 changed files with 303 additions and 73 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 0.5.1
# 0.5.3
docs: flex data module docs
docs: adds system common module docs
docs: channel voice 2 module docs
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "midi2"
version = "0.5.2"
version = "0.5.3"
description = "Ergonomic, versatile, strong types wrapping MIDI 2.0 message data."
edition = "2021"
readme = "README.md"
Expand Down Expand Up @@ -35,7 +35,7 @@ utility = []

[dependencies]
derive_more = { version = "0.99.17", features = ["from"], default-features = false }
midi2_proc = { version = "0.5.2", path = "midi2_proc" }
midi2_proc = { version = "0.5.3", path = "midi2_proc" }
ux = "0.1.6"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ You'll want to setup midi2 without default features to compile
without the `std` feature.

```toml
midi2 = { version = "0.5.2", default-features = false, features = ["channel-voice2", "sysex7"], }
midi2 = { version = "0.5.3", default-features = false, features = ["channel-voice2", "sysex7"], }
```

### Generic Representation
Expand Down
2 changes: 1 addition & 1 deletion midi2_proc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "midi2_proc"
description = "Internal procedural macro crate. Only intended for use with midi2"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
readme = "README.md"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 2 additions & 0 deletions src/channel_voice2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![doc = include_str!("channel_voice2/README.md")]

mod assignable_controller;
mod assignable_per_note_controller;
mod attribute;
Expand Down
98 changes: 53 additions & 45 deletions src/channel_voice2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,86 @@ use midi2::{
channel_voice2::NoteOn,
};

let mut message = ControlChange::<[u32; 4]>::new();
message.set_channel(u4::new(0xA));
message.set_group(u4::new(0xC));
message.set_control(u7::new(0x36));
message.set_control_data(u7::new(0x37));

assert_eq!(message.data(), &[0x2CBA_3637]);
let mut message = NoteOn::<[u32; 4]>::new();
message.set_group(u4::new(0x8));
message.set_channel(u4::new(0x8));
message.set_note(u7::new(0x5E));
message.set_velocity(0x6A14);
message.set_attribute(Some(channel_voice2::NoteAttribute::Pitch7_9 {
note: u7::new(0x74),
pitch_up: u9::new(0x18A),
}));

assert_eq!(message.data(), &[0x4898_5E03, 0x6A14_E98A]);
assert_eq!(message.group(), u4::new(0x8));
assert_eq!(message.channel(), u4::new(0x8));
assert_eq!(message.note(), u7::new(0x5E));
assert_eq!(message.velocity(), 0x6A14);
assert_eq!(
message.attribute(),
Some(channel_voice2::NoteAttribute::Pitch7_9 {
note: u7::new(0x74),
pitch_up: u9::new(0x18A),
}
));
```

## Channeled

`channel_voice1` messages are [Channeled](crate::Channeled).
`channel_voice2` messages are [Channeled](crate::Channeled).

## Grouped

`channel_voice1` messages are [Grouped](crate::Grouped)
when backed with [Ump](crate::buffer::Ump) buffers.
`channel_voice2` messages are [Grouped](crate::Grouped).

## Aggregate Message

There is a single aggregate [ChannelVoice1] enum type which
can represent an arbitrary `channel_voice1` message.
There is a single aggregate [ChannelVoice2] enum type which
can represent an arbitrary `channel_voice2` message.

```rust
use midi2::{
prelude::*,
channel_voice1::ChannelVoice1,
channel_voice2::ChannelVoice2,
};

let mut message = ChannelVoice1::try_from(&[0x2CBA_3637_u32][..]).expect("Valid data");
let mut message = ChannelVoice2::try_from(&[0x4898_5E03, 0x6A14_E98A][..]).expect("Valid data");

match message {
ChannelVoice1::ChannelPressure(m) => println!("channel_pressure {:?}", m.data()),
ChannelVoice1::ControlChange(m) => println!("control_change {:?}", m.data()),
ChannelVoice1::KeyPressure(m) => println!("key_pressure {:?}", m.data()),
ChannelVoice1::NoteOff(m) => println!("note_off {:?}", m.data()),
ChannelVoice1::NoteOn(m) => println!("note_on {:?}", m.data()),
ChannelVoice1::PitchBend(m) => println!("pitch_bend {:?}", m.data()),
ChannelVoice1::ProgramChange(m) => println!("program_change {:?}", m.data()),
ChannelVoice2::AssignableController(m) => println!("assignable_controller {:?}", m.data()),
ChannelVoice2::AssignablePerNoteController(m) => println!("assignable_per_note_controller {:?}", m.data()),
ChannelVoice2::ChannelPitchBend(m) => println!("channel_pitch_bend {:?}", m.data()),
ChannelVoice2::ChannelPressure(m) => println!("channel_pressure {:?}", m.data()),
ChannelVoice2::ControlChange(m) => println!("control_change {:?}", m.data()),
ChannelVoice2::KeyPressure(m) => println!("key_pressure {:?}", m.data()),
ChannelVoice2::NoteOff(m) => println!("note_off {:?}", m.data()),
ChannelVoice2::NoteOn(m) => println!("note_on {:?}", m.data()),
ChannelVoice2::PerNoteManagement(m) => println!("per_note_management {:?}", m.data()),
ChannelVoice2::PerNotePitchBend(m) => println!("per_note_pitch_bend {:?}", m.data()),
ChannelVoice2::ProgramChange(m) => println!("program_change {:?}", m.data()),
ChannelVoice2::RegisteredController(m) => println!("registered_controller {:?}", m.data()),
ChannelVoice2::RegisteredPerNoteController(m) => println!("registered_per_note_controller {:?}", m.data()),
ChannelVoice2::RelativeAssignableController(m) => println!("relative_assignable_controller {:?}", m.data()),
ChannelVoice2::RelativeRegisteredController(m) => println!("relative_registered_controller {:?}", m.data()),
}
```

## Generic Over [Unit](crate::buffer::Unit)
## Fixed Size

`channel_voice1` messages can also be represented with [Bytes](crate::buffer::Bytes) buffers
as well as [Ump](crate::buffer::Ump) buffers.
All `channel_voice1` messages are Fixed size and will fit
into an array of [u32] size 2 or greater.

```rust
use midi2::{
prelude::*,
channel_voice1::ControlChange,
};

let mut message = ControlChange::<[u8; 3]>::new();
message.set_channel(u4::new(0xA));
message.set_control(u7::new(0x36));
message.set_control_data(u7::new(0x37));
use midi2::channel_voice2::NoteOn;

assert_eq!(message.data(), &[0xBA, 0x36, 0x37]);
let _ = NoteOn::<[u32; 2]>::new();
let _ = NoteOn::<[u32; 4]>::new();
```

## Fixed Size

All `channel_voice1` messages are Fixed size.

```rust
use midi2::channel_voice1::KeyPressure;

Arrays smaller than two are invalid backing buffers.

// All channel_voice1 bytes-backed messages fit into a `[u8; 3]`
let _ = KeyPressure::<[u8; 3]>::new();
```rust,compile_fail,E0080
use midi2::channel_voice2::NoteOn;
// All channel_voice1 ump-backed messages fit into a `[u32; 1]`
let _ = KeyPressure::<[u32; 1]>::new();
let _ = NoteOn::<[u32; 1]>::new(); // compile err - buffer too short
```
3 changes: 3 additions & 0 deletions src/channel_voice2/assignable_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0011;

/// MIDI 2.0 Channel Voice Assignable Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct AssignableController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/assignable_per_note_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0001;

/// MIDI 2.0 Channel Voice Assignable Per Note Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct AssignablePerNoteController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/channel_pitch_bend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1110;

/// MIDI 2.0 Channel Voice Channel Pitch Bend Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct ChannelPitchBend {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/channel_pressure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1101;

/// MIDI 2.0 Channel Voice Channel Pressure Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct ChannelPressure {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/control_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1011;

/// MIDI 2.0 Channel Voice Control Change Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct ControlChange {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/key_pressure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1010;

/// MIDI 2.0 Channel Voice Key Pressure Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct KeyPressure {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/note_off.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1000;

/// MIDI 2.0 Channel Voice Note Off Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct NoteOff {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
21 changes: 2 additions & 19 deletions src/channel_voice2/note_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1001;

/// Note On MIDI 2.0 Channel Voice message.
/// MIDI 2.0 Channel Voice Note On Message
///
/// # Basic Usage
///
/// ```rust
/// use midi2::prelude::*;
/// use midi2::prelude::*;
///
/// let mut message = channel_voice2::NoteOn::<[u32; 4]>::new();
/// message.set_group(u4::new(0x8));
/// message.set_channel(u4::new(0x8));
/// message.set_note(u7::new(0x5E));
/// message.set_velocity(0x6A14);
/// message.set_attribute(Some(channel_voice2::NoteAttribute::Pitch7_9 {
/// note: u7::new(0x74),
/// pitch_up: u9::new(0x18A),
/// }));
///
/// assert_eq!(message.data(), &[0x4898_5E03, 0x6A14_E98A]);
/// ```
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct NoteOn {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/per_note_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1111;

/// MIDI 2.0 Channel Voice Per Note Management Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(1))]
struct PerNoteManagement {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/per_note_pitch_bend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0110;

/// MIDI 2.0 Channel Voice Per Note Pitch Bend Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct PerNotePitchBend {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/program_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b1100;

/// MIDI 2.0 Channel Voice Program Change Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct ProgramChange {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/registered_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0010;

/// MIDI 2.0 Channel Voice Registered Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct RegisteredController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/registered_per_note_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0000;

/// MIDI 2.0 Channel Voice Registered Per Note Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct RegisteredPerNoteController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/relative_assignable_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0101;

/// MIDI 2.0 Channel Voice Relative Assignable Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct RelativeAssignableController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
3 changes: 3 additions & 0 deletions src/channel_voice2/relative_registered_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{

pub(crate) const STATUS: u8 = 0b0100;

/// MIDI 2.0 Channel Voice Relative Registered Controller Message
///
/// See the [module docs](crate::channel_voice2) for more info.
#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
struct RelativeRegisteredController {
#[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
Expand Down
Loading

0 comments on commit ac5a69f

Please sign in to comment.