mirror of
https://github.com/italicsjenga/usbd-midi.git
synced 2025-01-11 04:41:31 +11:00
Adds in some derivation traits
This allows other structs to easily copy the data around
This commit is contained in:
parent
ad09837bbd
commit
468ce4ed39
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "usbd-midi"
|
name = "usbd-midi"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
authors = ["beau trepp <beautrepp@gmail.com>"]
|
authors = ["beau trepp <beautrepp@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "A usb-midi implementation for usb-device"
|
description = "A usb-midi implementation for usb-device"
|
||||||
|
|
|
@ -3,7 +3,7 @@ use core::convert::TryFrom;
|
||||||
/// The Channel is a value ranging from 0x0 to 0xF
|
/// The Channel is a value ranging from 0x0 to 0xF
|
||||||
/// This is a standard midi concept
|
/// This is a standard midi concept
|
||||||
/// Note Channel1 = 0 on the wire
|
/// Note Channel1 = 0 on the wire
|
||||||
#[derive(Debug)]
|
#[derive(Debug,Copy,Clone)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Channel {
|
pub enum Channel {
|
||||||
Channel1 = 0x0, Channel2 = 0x1, Channel3 = 0x2, Channel4 = 0x3,
|
Channel1 = 0x0, Channel2 = 0x1, Channel3 = 0x2, Channel4 = 0x3,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::data::byte::from_traits::FromOverFlow;
|
||||||
/// note the flat versions are associated constants
|
/// note the flat versions are associated constants
|
||||||
/// but can be referenced like Note::Bb3
|
/// but can be referenced like Note::Bb3
|
||||||
/// C1m is the C-1
|
/// C1m is the C-1
|
||||||
#[derive(Debug)]
|
#[derive(Debug,Copy,Clone)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Note {
|
pub enum Note {
|
||||||
C1m, Cs1m, D1m, Ds1m, E1m, F1m, Fs1m, G1m, Gs1m, A1m, As1m, B1m,
|
C1m, Cs1m, D1m, Ds1m, E1m, F1m, Fs1m, G1m, Gs1m, A1m, As1m, B1m,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::data::byte::u4::U4;
|
||||||
/// The Cable Number (CN) is a value ranging from 0x0 to 0xF
|
/// The Cable Number (CN) is a value ranging from 0x0 to 0xF
|
||||||
/// indicating the number assignment of the Embedded MIDI Jack associated
|
/// indicating the number assignment of the Embedded MIDI Jack associated
|
||||||
/// with the endpoint that is transferring the data
|
/// with the endpoint that is transferring the data
|
||||||
#[derive(Debug)]
|
#[derive(Debug,Clone,Copy)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum CableNumber {
|
pub enum CableNumber {
|
||||||
Cable0 = 0x0, Cable1 = 0x1, Cable2 = 0x2, Cable3 = 0x3,
|
Cable0 = 0x0, Cable1 = 0x1, Cable2 = 0x2, Cable3 = 0x3,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::data::midi::message::Message;
|
||||||
use crate::data::byte::u4::U4;
|
use crate::data::byte::u4::U4;
|
||||||
use crate::data::midi::message::raw::{Payload,Raw};
|
use crate::data::midi::message::raw::{Payload,Raw};
|
||||||
|
|
||||||
|
|
||||||
/// A packet that communicates with the host
|
/// A packet that communicates with the host
|
||||||
/// Currently supported is sending the specified normal midi
|
/// Currently supported is sending the specified normal midi
|
||||||
/// message over the supplied cable number
|
/// message over the supplied cable number
|
||||||
|
@ -35,3 +36,14 @@ impl From<UsbMidiEventPacket> for [u8;4] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl UsbMidiEventPacket{
|
||||||
|
|
||||||
|
pub fn from_midi(cable:CableNumber, midi:Message)
|
||||||
|
-> UsbMidiEventPacket{
|
||||||
|
UsbMidiEventPacket{
|
||||||
|
cable_number : cable,
|
||||||
|
message : midi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue