mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-11 22:26:44 +01:00
big ass refactor (rip client)
This commit is contained in:
parent
94c1f83ef2
commit
8c3cf53c67
56 changed files with 2232 additions and 1891 deletions
132
src/model/mixer.rs
Normal file
132
src/model/mixer.rs
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
use crate::core::*;
|
||||
|
||||
pub struct Mixer {
|
||||
pub name: String,
|
||||
pub tracks: Vec<MixerTrack>,
|
||||
pub selected_track: usize,
|
||||
pub selected_column: usize,
|
||||
}
|
||||
|
||||
impl Mixer {
|
||||
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||
let (client, _status) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
||||
Ok(DynamicDevice::new(
|
||||
crate::view::mixer::render,
|
||||
crate::control::mixer::handle,
|
||||
process,
|
||||
Self {
|
||||
name: name.into(),
|
||||
selected_column: 0,
|
||||
selected_track: 1,
|
||||
tracks: vec![
|
||||
MixerTrack::new(&client, 1, "Mono 1")?,
|
||||
MixerTrack::new(&client, 1, "Mono 2")?,
|
||||
MixerTrack::new(&client, 2, "Stereo 1")?,
|
||||
MixerTrack::new(&client, 2, "Stereo 2")?,
|
||||
MixerTrack::new(&client, 2, "Stereo 3")?,
|
||||
MixerTrack::new(&client, 2, "Bus 1")?,
|
||||
MixerTrack::new(&client, 2, "Bus 2")?,
|
||||
MixerTrack::new(&client, 2, "Mix")?,
|
||||
],
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process (
|
||||
_: &mut Mixer,
|
||||
_: &Client,
|
||||
_: &ProcessScope
|
||||
) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
pub struct MixerTrack {
|
||||
pub name: String,
|
||||
pub channels: u8,
|
||||
pub input_ports: Vec<Port<AudioIn>>,
|
||||
pub pre_gain_meter: f64,
|
||||
pub gain: f64,
|
||||
pub insert_ports: Vec<Port<AudioOut>>,
|
||||
pub return_ports: Vec<Port<AudioIn>>,
|
||||
pub post_gain_meter: f64,
|
||||
pub post_insert_meter: f64,
|
||||
pub level: f64,
|
||||
pub pan: f64,
|
||||
pub output_ports: Vec<Port<AudioOut>>,
|
||||
pub post_fader_meter: f64,
|
||||
pub route: String,
|
||||
}
|
||||
|
||||
impl MixerTrack {
|
||||
pub fn new (jack: &Client, channels: u8, name: &str) -> Result<Self, Box<dyn Error>> {
|
||||
let mut input_ports = vec![];
|
||||
let mut insert_ports = vec![];
|
||||
let mut return_ports = vec![];
|
||||
let mut output_ports = vec![];
|
||||
for channel in 1..=channels {
|
||||
input_ports.push(jack.register_port(&format!("{name} [input {channel}]"), AudioIn::default())?);
|
||||
output_ports.push(jack.register_port(&format!("{name} [out {channel}]"), AudioOut::default())?);
|
||||
let insert_port = jack.register_port(&format!("{name} [pre {channel}]"), AudioOut::default())?;
|
||||
let return_port = jack.register_port(&format!("{name} [insert {channel}]"), AudioIn::default())?;
|
||||
jack.connect_ports(&insert_port, &return_port)?;
|
||||
insert_ports.push(insert_port);
|
||||
return_ports.push(return_port);
|
||||
}
|
||||
Ok(Self {
|
||||
name: name.into(),
|
||||
channels,
|
||||
input_ports,
|
||||
pre_gain_meter: 0.0,
|
||||
gain: 0.0,
|
||||
post_gain_meter: 0.0,
|
||||
insert_ports,
|
||||
return_ports,
|
||||
post_insert_meter: 0.0,
|
||||
level: 0.0,
|
||||
pan: 0.0,
|
||||
post_fader_meter: 0.0,
|
||||
route: "---".into(),
|
||||
output_ports,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//impl<W: Write> Input<TUI<W>, bool> for Mixer {
|
||||
//fn handle (&mut self, engine: &mut TUI<W>) -> Result<Option<bool>> {
|
||||
//Ok(None)
|
||||
//}
|
||||
//
|
||||
|
||||
//impl<W: Write> Output<TUI<W>, [u16;2]> for Mixer {
|
||||
//fn render (&self, envine: &mut TUI<W>) -> Result<Option<[u16;2]>> {
|
||||
|
||||
//let tracks_table = Columns::new()
|
||||
//.add(titles)
|
||||
//.add(input_meters)
|
||||
//.add(gains)
|
||||
//.add(gain_meters)
|
||||
//.add(pres)
|
||||
//.add(pre_meters)
|
||||
//.add(levels)
|
||||
//.add(pans)
|
||||
//.add(pan_meters)
|
||||
//.add(posts)
|
||||
//.add(routes)
|
||||
|
||||
//Rows::new()
|
||||
//.add(Columns::new()
|
||||
//.add(Rows::new()
|
||||
//.add("[Arrows]".bold())
|
||||
//.add("Navigate"))
|
||||
//.add(Rows::new()
|
||||
//.add("[+/-]".bold())
|
||||
//.add("Adjust"))
|
||||
//.add(Rows::new()
|
||||
//.add("[Ins/Del]".bold())
|
||||
//.add("Add/remove track")))
|
||||
//.add(tracks_table)
|
||||
//.render(engine)
|
||||
//}
|
||||
//}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue