mirror of
https://github.com/italicsjenga/usbd-midi.git
synced 2024-12-23 12:21:30 +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]
|
||||
name = "usbd-midi"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["beau trepp <beautrepp@gmail.com>"]
|
||||
edition = "2018"
|
||||
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
|
||||
/// This is a standard midi concept
|
||||
/// Note Channel1 = 0 on the wire
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug,Copy,Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum Channel {
|
||||
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
|
||||
/// but can be referenced like Note::Bb3
|
||||
/// C1m is the C-1
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug,Copy,Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum Note {
|
||||
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
|
||||
/// indicating the number assignment of the Embedded MIDI Jack associated
|
||||
/// with the endpoint that is transferring the data
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug,Clone,Copy)]
|
||||
#[repr(u8)]
|
||||
pub enum CableNumber {
|
||||
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::midi::message::raw::{Payload,Raw};
|
||||
|
||||
|
||||
/// A packet that communicates with the host
|
||||
/// Currently supported is sending the specified normal midi
|
||||
/// 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