mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-08 06:26:57 +02:00
wip: prototype chains/stacks
This commit is contained in:
parent
dc09ea901f
commit
d330d31ce4
3 changed files with 239 additions and 66 deletions
52
src/device/sequencer/midi.rs
Normal file
52
src/device/sequencer/midi.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
pub struct MIDISequence {
|
||||
channels: [MIDISequenceChannel;16],
|
||||
}
|
||||
|
||||
pub struct MIDISequenceChannel {
|
||||
number: u8,
|
||||
notes: [MIDISequenceVoice;128],
|
||||
}
|
||||
|
||||
pub type MIDISequenceVoice = std::collections::BTreeMap<u32, NoteEvent>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum NoteEvent {
|
||||
On(u8),
|
||||
Off(u8),
|
||||
}
|
||||
|
||||
const VOICE_EMPTY: MIDISequenceVoice = MIDISequenceVoice::new();
|
||||
|
||||
impl MIDISequence {
|
||||
fn new () -> Self {
|
||||
Self {
|
||||
channels: [
|
||||
MIDISequenceChannel::new(1),
|
||||
MIDISequenceChannel::new(2),
|
||||
MIDISequenceChannel::new(3),
|
||||
MIDISequenceChannel::new(4),
|
||||
MIDISequenceChannel::new(5),
|
||||
MIDISequenceChannel::new(6),
|
||||
MIDISequenceChannel::new(7),
|
||||
MIDISequenceChannel::new(8),
|
||||
MIDISequenceChannel::new(9),
|
||||
MIDISequenceChannel::new(10),
|
||||
MIDISequenceChannel::new(11),
|
||||
MIDISequenceChannel::new(12),
|
||||
MIDISequenceChannel::new(13),
|
||||
MIDISequenceChannel::new(14),
|
||||
MIDISequenceChannel::new(15),
|
||||
MIDISequenceChannel::new(16),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MIDISequenceChannel {
|
||||
fn new (number: u8) -> Self {
|
||||
Self {
|
||||
number,
|
||||
notes: [VOICE_EMPTY;128]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue