mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-15 16:06:41 +01:00
implement ConnectPort
This commit is contained in:
parent
0cca06e054
commit
9e4406c66a
4 changed files with 77 additions and 64 deletions
67
src/main.rs
67
src/main.rs
|
|
@ -105,23 +105,20 @@ pub fn main () -> Usually<()> {
|
|||
}))?)?,
|
||||
|
||||
TekMode::Sequencer {
|
||||
midi_from,
|
||||
midi_to, ..
|
||||
midi_from, midi_to, ..
|
||||
} => engine.run(&jack.activate_with(|jack|Ok({
|
||||
let clock = Clock::from(jack);
|
||||
let phrase = Arc::new(RwLock::new(MidiClip::new(
|
||||
let clip = Arc::new(RwLock::new(MidiClip::new(
|
||||
"Clip", true, 4 * clock.timebase.ppq.get() as usize,
|
||||
None, Some(ItemColor::random().into())
|
||||
)));
|
||||
let midi_in = jack.read().unwrap().register_port("i", MidiIn::default())?;
|
||||
connect_from(jack, &midi_in, &midi_from)?;
|
||||
let midi_out = jack.read().unwrap().register_port("o", MidiOut::default())?;
|
||||
connect_to(jack, &midi_out, &midi_to)?;
|
||||
let player = MidiPlayer::new(&jack, name, Some(&clip), &midi_from, &midi_to)?;
|
||||
Sequencer {
|
||||
_jack: jack.clone(),
|
||||
pool: PoolModel::from(&phrase),
|
||||
editor: MidiEditor::from(&phrase),
|
||||
player: MidiPlayer::new(&clock, &phrase, &[midi_in], &[midi_out])?,
|
||||
clock: player.clock.clone(),
|
||||
player,
|
||||
editor: MidiEditor::from(&clip),
|
||||
pool: PoolModel::from(&clip),
|
||||
compact: true,
|
||||
transport: true,
|
||||
selectors: true,
|
||||
|
|
@ -130,7 +127,6 @@ pub fn main () -> Usually<()> {
|
|||
note_buf: vec![],
|
||||
perf: PerfModel::default(),
|
||||
status: true,
|
||||
clock,
|
||||
}
|
||||
}))?)?,
|
||||
|
||||
|
|
@ -224,55 +220,6 @@ pub fn main () -> Usually<()> {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn connect_from (jack: &JackConnection, input: &Port<MidiIn>, ports: &[String]) -> Usually<()> {
|
||||
for port in ports.iter() {
|
||||
if let Some(port) = jack.port_by_name(port).as_ref() {
|
||||
jack.client().connect_ports(port, input)?;
|
||||
} else {
|
||||
panic!("Missing MIDI output: {port}. Use jack_lsp to list all port names.");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn connect_to (jack: &JackConnection, output: &Port<MidiOut>, ports: &[String]) -> Usually<()> {
|
||||
for port in ports.iter() {
|
||||
if let Some(port) = jack.port_by_name(port).as_ref() {
|
||||
jack.client().connect_ports(output, port)?;
|
||||
} else {
|
||||
panic!("Missing MIDI input: {port}. Use jack_lsp to list all port names.");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn connect_audio_from (jack: &JackConnection, input: &Port<AudioIn>, ports: &[String]) -> Usually<()> {
|
||||
for port in ports.iter() {
|
||||
if let Some(port) = jack.port_by_name(port).as_ref() {
|
||||
jack.client().connect_ports(port, input)?;
|
||||
} else {
|
||||
panic!("Missing MIDI output: {port}. Use jack_lsp to list all port names.");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn connect_audio_to (jack: &JackConnection, output: &Port<AudioOut>, ports: &[String]) -> Usually<()> {
|
||||
for port in ports.iter() {
|
||||
if let Some(port) = jack.port_by_name(port).as_ref() {
|
||||
jack.client().connect_ports(output, port)?;
|
||||
} else {
|
||||
panic!("Missing MIDI input: {port}. Use jack_lsp to list all port names.");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[test] fn verify_cli () {
|
||||
use clap::CommandFactory;
|
||||
TekCli::command().debug_assert();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue