mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: sequencer now copies from buffers
This commit is contained in:
parent
aa478099d9
commit
2fc8e84551
15 changed files with 310 additions and 256 deletions
|
|
@ -33,8 +33,8 @@ pub fn write_midi_output (writer: &mut ::jack::MidiWriter, output: &MIDIChunk, f
|
|||
}
|
||||
}
|
||||
|
||||
/// (ppq, name)
|
||||
pub const NOTE_DURATIONS: [(usize, &str);26] = [
|
||||
/// (pulses, name)
|
||||
pub const NOTE_DURATIONS: [(u16, &str);26] = [
|
||||
(1, "1/384"),
|
||||
(2, "1/192"),
|
||||
(3, "1/128"),
|
||||
|
|
@ -63,16 +63,7 @@ pub const NOTE_DURATIONS: [(usize, &str);26] = [
|
|||
(6144, "16/1"),
|
||||
];
|
||||
|
||||
pub fn ppq_to_name (ppq: usize) -> &'static str {
|
||||
for (length, name) in &NOTE_DURATIONS {
|
||||
if *length == ppq {
|
||||
return name
|
||||
}
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
pub fn prev_note_length (ppq: usize) -> usize {
|
||||
pub fn prev_note_length (ppq: u16) -> u16 {
|
||||
for i in 1..=16 {
|
||||
let length = NOTE_DURATIONS[16-i].0;
|
||||
if length < ppq {
|
||||
|
|
@ -82,7 +73,7 @@ pub fn prev_note_length (ppq: usize) -> usize {
|
|||
ppq
|
||||
}
|
||||
|
||||
pub fn next_note_length (ppq: usize) -> usize {
|
||||
pub fn next_note_length (ppq: u16) -> u16 {
|
||||
for (length, _) in &NOTE_DURATIONS {
|
||||
if *length > ppq {
|
||||
return *length
|
||||
|
|
@ -90,3 +81,12 @@ pub fn next_note_length (ppq: usize) -> usize {
|
|||
}
|
||||
ppq
|
||||
}
|
||||
|
||||
pub fn ppq_to_name (ppq: u16) -> &'static str {
|
||||
for (length, name) in &NOTE_DURATIONS {
|
||||
if *length == ppq {
|
||||
return name
|
||||
}
|
||||
}
|
||||
""
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue