1use std::fmt;
2
3pub const MIDI_CHANNELS: usize = 16;
4pub const KEYS_SCROLL_ID: &str = "piano.keys.scroll";
5pub const NOTES_SCROLL_ID: &str = "piano.notes.scroll";
6pub const CTRL_SCROLL_ID: &str = "piano.ctrl.scroll";
7pub const SYSEX_SCROLL_ID: &str = "piano.sysex.scroll";
8
9pub const KEYBOARD_WIDTH: f32 = 128.0;
10pub const RIGHT_SCROLL_GUTTER_WIDTH: f32 = 16.0;
11pub const TOOLS_STRIP_WIDTH: f32 = 248.0;
12pub const MAIN_SPLIT_SPACING: f32 = 3.0;
13pub const H_ZOOM_MIN: f32 = 1.0;
14pub const H_ZOOM_MAX: f32 = 127.0;
15pub const MIDI_NOTE_COUNT: usize = 128;
16pub const OCTAVES: usize = 11;
17pub const WHITE_KEYS_PER_OCTAVE: usize = 7;
18pub const NOTES_PER_OCTAVE: usize = 12;
19pub const PITCH_MAX: u8 = (MIDI_NOTE_COUNT as u8) - 1;
20pub const WHITE_KEY_HEIGHT: f32 = 14.0;
21pub const MAX_RPN_NRPN_POINTS: usize = 4096;
22pub const MIDI_DIN_BYTES_PER_SEC: f64 = 3125.0;
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum PianoControllerLane {
26 Controller,
27 Velocity,
28 Rpn,
29 Nrpn,
30 SysEx,
31}
32
33impl fmt::Display for PianoControllerLane {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 match self {
36 Self::Controller => write!(f, "Controller"),
37 Self::Velocity => write!(f, "Velocity"),
38 Self::Rpn => write!(f, "RPN"),
39 Self::Nrpn => write!(f, "NRPN"),
40 Self::SysEx => write!(f, "SysEx"),
41 }
42 }
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub enum PianoRpnKind {
47 PitchBendSensitivity,
48 FineTuning,
49 CoarseTuning,
50}
51
52impl fmt::Display for PianoRpnKind {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 match self {
55 Self::PitchBendSensitivity => write!(f, "Pitch Bend Sensitivity"),
56 Self::FineTuning => write!(f, "Fine Tuning"),
57 Self::CoarseTuning => write!(f, "Coarse Tuning"),
58 }
59 }
60}
61
62pub const PIANO_RPN_KIND_ALL: [PianoRpnKind; 3] = [
63 PianoRpnKind::PitchBendSensitivity,
64 PianoRpnKind::FineTuning,
65 PianoRpnKind::CoarseTuning,
66];
67
68#[derive(Debug, Clone, Copy, PartialEq, Eq)]
69pub enum PianoNrpnKind {
70 Brightness,
71 VibratoRate,
72 VibratoDepth,
73}
74
75impl fmt::Display for PianoNrpnKind {
76 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
77 match self {
78 Self::Brightness => write!(f, "Brightness"),
79 Self::VibratoRate => write!(f, "Vibrato Rate"),
80 Self::VibratoDepth => write!(f, "Vibrato Depth"),
81 }
82 }
83}
84
85pub const PIANO_NRPN_KIND_ALL: [PianoNrpnKind; 3] = [
86 PianoNrpnKind::Brightness,
87 PianoNrpnKind::VibratoRate,
88 PianoNrpnKind::VibratoDepth,
89];
90
91#[derive(Debug, Clone)]
92pub struct PianoNote {
93 pub start_sample: usize,
94 pub length_samples: usize,
95 pub pitch: u8,
96 pub velocity: u8,
97 pub channel: u8,
98}
99
100#[derive(Debug, Clone)]
101pub struct PianoControllerPoint {
102 pub sample: usize,
103 pub controller: u8,
104 pub value: u8,
105 pub channel: u8,
106}
107
108#[derive(Debug, Clone)]
109pub struct PianoSysExPoint {
110 pub sample: usize,
111 pub data: Vec<u8>,
112}