Skip to content

Commit

Permalink
Refactor MIDI message handling to use fluidlite's Chan type for chann…
Browse files Browse the repository at this point in the history
…el representation
  • Loading branch information
Guy Chronister committed Dec 19, 2024
1 parent 7908456 commit 5dd79fa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions neothesia-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::{default::Default, time::Duration};
#[cfg(feature = "fluid-synth")]
use {fluidlite::{Settings, Synth}, std::sync::Arc};
use {
fluidlite::{Settings, Synth, midi::Chan},
std::sync::Arc,
};

use neothesia_core::{
config::Config,
Expand Down Expand Up @@ -175,10 +178,15 @@ impl Recorder {
for e in &events {
match e.message {
midi_file::midly::MidiMessage::NoteOn { key, vel } => {
synth.note_on(e.channel as i32, key.as_int() as i32, vel.as_int() as i32).ok();
let chan = Chan::try_from(e.channel as u32).unwrap();
let key = key.as_int() as u32;
let vel = vel.as_int() as u32;
synth.note_on(chan, key, vel).ok();
}
midi_file::midly::MidiMessage::NoteOff { key, .. } => {
synth.note_off(e.channel as i32, key.as_int() as i32).ok();
let chan = Chan::try_from(e.channel as u32).unwrap();
let key = key.as_int() as u32;
synth.note_off(chan, key).ok();
}
_ => {}
}
Expand Down

0 comments on commit 5dd79fa

Please sign in to comment.