Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use shared midi-types and midi-convert #11

Closed
wants to merge 12 commits into from
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Swapped out bespoke MIDI types for shared [midi-types](https://crates.io/crates/midi-types).
* And in turn [midi-convert](https://crates.io/crates/midi-convert) for parsing/rendering.
* **NOTE**: `midi-types` uses C3 as middle C, whereas `usbd-midi` previously
used C4 as middle C. If you use the note constants from `usbd-midi`, you
will need to lower them by an octave when upgrading to preserve the pitch.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ license = "MIT"
embedded-hal = "0.2.2"
nb = "1.0.0"
usb-device = "0.2.3"
midi-convert = "0.1.1"
midi-types = "0.1.4"

[dependencies.num_enum]
version = "0.5.1"
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ fn main() -> ! {
.device_sub_class(USB_MIDISTREAMING_SUBCLASS)
.build();

const CHANNEL1: Channel = Channel::new(0);

loop {
if !usb_dev.poll(&mut [&mut midi]) {
continue;
Expand All @@ -55,10 +57,10 @@ fn main() -> ! {
for packet in buffer_reader.into_iter() {
if let Ok(packet) = packet {
match packet.message {
Message::NoteOn(Channel1, Note::C2, ..) => {
MidiMessage::NoteOn(CHANNEL1, Note::C2, ..) => {
led.set_low().unwrap();
},
Message::NoteOff(Channel1, Note::C2, ..) => {
MidiMessage::NoteOff(CHANNEL1, Note::C2, ..) => {
led.set_high().unwrap();
},
_ => {}
Expand Down
12 changes: 0 additions & 12 deletions src/data/byte/from_traits.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/data/byte/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub mod u7;
pub mod u4;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe u4 should be moved into midi-types as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

midi-types has Channel so doesn't need u4..

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I was mixing up CableNumber and Channel

pub mod from_traits;
50 changes: 0 additions & 50 deletions src/data/byte/u7.rs

This file was deleted.

83 changes: 0 additions & 83 deletions src/data/midi/channel.rs

This file was deleted.

137 changes: 0 additions & 137 deletions src/data/midi/message/control_function.rs

This file was deleted.

Loading