somehow, no warnings

This commit is contained in:
🪞👃🪞 2024-12-27 16:00:31 +01:00
parent 8652a5e415
commit a64925ba8c
7 changed files with 118 additions and 118 deletions

View file

@ -8,13 +8,13 @@ impl GrooveboxCli {
Tui::run(JackClient::new("tek_groovebox")?.activate_with(|jack|{
let app = tek::tui::GrooveboxTui::try_from(jack)?;
let jack = jack.read().unwrap();
let midi_out = jack.register_port("out", MidiOut::default())?;
let midi_in_1 = jack.register_port("in1", MidiIn::default())?;
let midi_in_2 = jack.register_port("in2", MidiIn::default())?;
let audio_in_1 = jack.register_port("inL", AudioIn::default())?;
let audio_in_2 = jack.register_port("inR", AudioIn::default())?;
let audio_out_1 = jack.register_port("out1", AudioOut::default())?;
let audio_out_2 = jack.register_port("out2", AudioOut::default())?;
let _midi_out = jack.register_port("out", MidiOut::default())?;
let _midi_in_1 = jack.register_port("in1", MidiIn::default())?;
let _midi_in_2 = jack.register_port("in2", MidiIn::default())?;
let _audio_in_1 = jack.register_port("inL", AudioIn::default())?;
let _audio_in_2 = jack.register_port("inR", AudioIn::default())?;
let _audio_out_1 = jack.register_port("out1", AudioOut::default())?;
let _audio_out_2 = jack.register_port("out2", AudioOut::default())?;
Ok(app)
})?)?;
Ok(())

View file

@ -1,3 +1,3 @@
use std::sync::Arc;
use clap::{self, Parser};
use tek::{*, jack::*};
#[allow(unused_imports)] use std::sync::Arc;
#[allow(unused_imports)] use clap::{self, Parser};
#[allow(unused_imports)] use tek::{*, jack::*};

View file

@ -1,27 +1,10 @@
use tek::{*, jack::*, plugin::*, audio::*};
#[allow(unused_imports)] use tek::{*, jack::*, plugin::*, audio::*};
use std::sync::{Arc, RwLock};
use std::collections::BTreeMap;
pub use clojure_reader::edn::Edn;
//pub use clojure_reader::{edn::{read, Edn}, error::Error as EdnError};
pub trait FromEdn<C>: Sized {
const ID: &'static str;
fn from_edn (context: C, expr: &[Edn<'_>]) -> Usually<Self>;
}
/// Implements the [FromEdn] trait.
#[macro_export] macro_rules! from_edn {
(|$context:pat = $Context:ty, $id:expr, $args:ident| -> $T:ty $body:block) => {
impl FromEdn<$Context> for $T {
const ID: &'static str = $id;
fn from_edn <'e> ($context: $Context, $args: &[Edn<'e>]) -> Usually<Self> {
$body
}
}
}
}
/// EDN parsing helper.
#[macro_export] macro_rules! edn {
($edn:ident { $($pat:pat => $expr:expr),* $(,)? }) => {
@ -34,7 +17,24 @@ pub trait FromEdn<C>: Sized {
};
}
from_edn!(|jack = &Arc<RwLock<JackClient>>, "sampler", args| -> crate::Sampler {
pub trait FromEdn<C>: Sized {
const ID: &'static str;
fn from_edn (context: C, expr: &[Edn<'_>]) -> Usually<Self>;
}
/// Implements the [FromEdn] trait.
#[macro_export] macro_rules! from_edn {
($id:expr => |$context:tt:$Context:ty, $args:ident| -> $T:ty $body:block) => {
impl FromEdn<$Context> for $T {
const ID: &'static str = $id;
fn from_edn <'e> ($context: $Context, $args: &[Edn<'e>]) -> Usually<Self> {
$body
}
}
}
}
from_edn!("sampler" => |jack: &Arc<RwLock<JackClient>>, args| -> crate::Sampler {
let mut name = String::new();
let mut dir = String::new();
let mut samples = BTreeMap::new();
@ -76,7 +76,7 @@ from_edn!(|jack = &Arc<RwLock<JackClient>>, "sampler", args| -> crate::Sampler {
type MidiSample = (Option<u7>, Arc<RwLock<crate::Sample>>);
from_edn!(|(jack, dir) = (&Arc<RwLock<JackClient>>, &str), "sample", args| -> MidiSample {
from_edn!("sample" => |(_jack, dir): (&Arc<RwLock<JackClient>>, &str), args| -> MidiSample {
let mut name = String::new();
let mut file = String::new();
let mut midi = None;
@ -108,80 +108,77 @@ from_edn!(|(jack, dir) = (&Arc<RwLock<JackClient>>, &str), "sample", args| -> Mi
}))))
});
impl LV2Plugin {
pub fn from_edn <'e> (jack: &Arc<RwLock<JackClient>>, args: &[Edn<'e>]) -> Usually<Plugin> {
let mut name = String::new();
let mut path = String::new();
edn!(edn in args {
Edn::Map(map) => {
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":name")) {
name = String::from(*n);
}
if let Some(Edn::Str(p)) = map.get(&Edn::Key(":path")) {
path = String::from(*p);
}
},
_ => panic!("unexpected in lv2 '{name}'"),
});
Plugin::new_lv2(jack, &name, &path)
}
}
from_edn!("plugin/lv2" => |jack: &Arc<RwLock<JackClient>>, args| -> Plugin {
let mut name = String::new();
let mut path = String::new();
edn!(edn in args {
Edn::Map(map) => {
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":name")) {
name = String::from(*n);
}
if let Some(Edn::Str(p)) = map.get(&Edn::Key(":path")) {
path = String::from(*p);
}
},
_ => panic!("unexpected in lv2 '{name}'"),
});
Plugin::new_lv2(jack, &name, &path)
});
impl MixerTrack {
const SYM_NAME: &'static str = ":name";
const SYM_GAIN: &'static str = ":gain";
const SYM_SAMPLER: &'static str = "sampler";
const SYM_LV2: &'static str = "lv2";
pub fn from_edn <'a, 'e> (jack: &Arc<RwLock<JackClient>>, args: &[Edn<'e>]) -> Usually<Self> {
let mut _gain = 0.0f64;
let mut track = MixerTrack {
name: String::new(),
audio_ins: vec![],
audio_outs: vec![],
devices: vec![],
};
edn!(edn in args {
Edn::Map(map) => {
if let Some(Edn::Str(n)) = map.get(&Edn::Key(Self::SYM_NAME)) {
track.name = n.to_string();
}
if let Some(Edn::Double(g)) = map.get(&Edn::Key(Self::SYM_GAIN)) {
_gain = f64::from(*g);
}
const SYM_NAME: &'static str = ":name";
const SYM_GAIN: &'static str = ":gain";
const SYM_SAMPLER: &'static str = "sampler";
const SYM_LV2: &'static str = "lv2";
from_edn!("mixer/track" => |jack: &Arc<RwLock<JackClient>>, args| -> MixerTrack {
let mut _gain = 0.0f64;
let mut track = MixerTrack {
name: String::new(),
audio_ins: vec![],
audio_outs: vec![],
devices: vec![],
};
edn!(edn in args {
Edn::Map(map) => {
if let Some(Edn::Str(n)) = map.get(&Edn::Key(SYM_NAME)) {
track.name = n.to_string();
}
if let Some(Edn::Double(g)) = map.get(&Edn::Key(SYM_GAIN)) {
_gain = f64::from(*g);
}
},
Edn::List(args) => match args.get(0) {
// Add a sampler device to the track
Some(Edn::Symbol(SYM_SAMPLER)) => {
track.devices.push(
Box::new(Sampler::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
);
panic!(
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"sampler\"",
&track.name,
args.get(0).unwrap()
)
},
Edn::List(args) => match args.get(0) {
// Add a sampler device to the track
Some(Edn::Symbol(Self::SYM_SAMPLER)) => {
track.devices.push(
Box::new(Sampler::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
);
panic!(
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"sampler\"",
&track.name,
args.get(0).unwrap()
)
},
// Add a LV2 plugin to the track.
Some(Edn::Symbol(Self::SYM_LV2)) => {
track.devices.push(
Box::new(LV2Plugin::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
);
panic!(
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"plugin\"",
&track.name,
args.get(0).unwrap()
)
},
None =>
panic!("empty list track {}", &track.name),
_ =>
panic!("unexpected in track {}: {:?}", &track.name, args.get(0).unwrap())
// Add a LV2 plugin to the track.
Some(Edn::Symbol(SYM_LV2)) => {
track.devices.push(
Box::new(Plugin::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
);
panic!(
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"plugin\"",
&track.name,
args.get(0).unwrap()
)
},
_ => {}
});
Ok(track)
}
}
None =>
panic!("empty list track {}", &track.name),
_ =>
panic!("unexpected in track {}: {:?}", &track.name, args.get(0).unwrap())
},
_ => {}
});
Ok(track)
});
//impl ArrangerScene {

View file

@ -1,6 +1,9 @@
pub(crate) use std::error::Error;
pub(crate) mod color; pub(crate) use color::*;
pub(crate) mod color;
pub(crate) use color::*;
pub use color::*;
pub(crate) mod command; pub(crate) use command::*;
pub(crate) mod engine; pub(crate) use engine::*;
pub(crate) mod focus; pub(crate) use focus::*;

View file

@ -1,9 +1,9 @@
#![allow(unused)]
#![allow(clippy::unit_arg)]
pub mod core; pub use self::core::*;
pub mod core; pub use self::core::*;
pub mod time; pub(crate) use self::time::*;
pub mod time; pub(crate) use self::time::*;
pub mod space; pub(crate) use self::space::*;
@ -41,7 +41,7 @@ pub(crate) use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen,
pub(crate) use crossterm::event::{KeyCode, KeyModifiers, KeyEvent, KeyEventKind, KeyEventState};
pub use ::ratatui; pub(crate) use ratatui::{
prelude::{Style, Color, Buffer},
prelude::{Style, Buffer},
style::{Stylize, Modifier},
backend::{Backend, CrosstermBackend, ClearType}
};

View file

@ -7,15 +7,15 @@ use PhrasePoolCommand::*;
/// Root view for standalone `tek_sequencer`.
pub struct SequencerTui {
_jack: Arc<RwLock<JackClient>>,
pub(crate) clock: ClockModel,
pub(crate) phrases: PoolModel,
pub(crate) player: MidiPlayer,
pub(crate) editor: MidiEditorModel,
pub(crate) size: Measure<Tui>,
pub(crate) status: bool,
pub(crate) note_buf: Vec<u8>,
pub(crate) midi_buf: Vec<Vec<Vec<u8>>>,
pub(crate) perf: PerfModel,
pub clock: ClockModel,
pub phrases: PoolModel,
pub player: MidiPlayer,
pub editor: MidiEditorModel,
pub size: Measure<Tui>,
pub status: bool,
pub note_buf: Vec<u8>,
pub midi_buf: Vec<Vec<Vec<u8>>>,
pub perf: PerfModel,
}
from_jack!(|jack|SequencerTui {
let clock = ClockModel::from(jack);

View file

@ -26,13 +26,13 @@ impl ArrangerTui {
}
#[derive(Debug)] pub struct ArrangerTrack {
/// Name of track
pub(crate) name: Arc<RwLock<String>>,
pub name: Arc<RwLock<String>>,
/// Preferred width of track column
pub(crate) width: usize,
pub width: usize,
/// Identifying color of track
pub(crate) color: ItemPalette,
pub color: ItemPalette,
/// MIDI player state
pub(crate) player: MidiPlayer,
pub player: MidiPlayer,
}
has_clock!(|self:ArrangerTrack|self.player.clock());
has_player!(|self:ArrangerTrack|self.player);