mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
simplify track construction
This commit is contained in:
parent
c78b2dc9de
commit
c5586c3a35
2 changed files with 18 additions and 29 deletions
|
|
@ -23,36 +23,23 @@ has_player!(|self: Track|self.player);
|
||||||
|
|
||||||
impl Track {
|
impl Track {
|
||||||
pub const MIN_WIDTH: usize = 9;
|
pub const MIN_WIDTH: usize = 9;
|
||||||
/// Create a new track containing a sequencer.
|
/// Create a new track with only the default [MidiPlayer].
|
||||||
pub fn new_sequencer () -> Self {
|
pub fn new () -> Self {
|
||||||
let mut track = Self::default();
|
Self::default()
|
||||||
track.devices.push(Device::Sequencer(MidiPlayer::default()));
|
|
||||||
track
|
|
||||||
}
|
}
|
||||||
/// Create a new track containing a sequencer and sampler.
|
/// Create a new track connecting the [MidiPlayer] to a [Sampler].
|
||||||
pub fn new_groovebox (
|
pub fn new_with_sampler (
|
||||||
jack: &Jack,
|
jack: &Jack,
|
||||||
midi_from: &[PortConnect],
|
midi_from: &[PortConnect],
|
||||||
audio_from: &[&[PortConnect];2],
|
audio_from: &[&[PortConnect];2],
|
||||||
audio_to: &[&[PortConnect];2],
|
audio_to: &[&[PortConnect];2],
|
||||||
) -> Usually<Self> {
|
) -> Usually<Self> {
|
||||||
let mut track = Self::new_sequencer();
|
let mut track = Self::new_sequencer();
|
||||||
track.devices.push(Device::Sampler(
|
let name = jack.with_client(|c|c.name().to_string());
|
||||||
Sampler::new(jack, &"sampler", midi_from, audio_from, audio_to)?
|
let midi = track.player.midi_outs[0].name();
|
||||||
));
|
let port = PortConnect::exact(format!("{name}:{midi}"));
|
||||||
Ok(track)
|
let sampler = Sampler::new(jack, &"sampler", &[port], audio_from, audio_to)?;
|
||||||
}
|
track.devices.push(Device::Sampler(sampler));
|
||||||
/// Create a new track containing a sampler.
|
|
||||||
pub fn new_sampler (
|
|
||||||
jack: &Jack,
|
|
||||||
midi_from: &[PortConnect],
|
|
||||||
audio_from: &[&[PortConnect];2],
|
|
||||||
audio_to: &[&[PortConnect];2],
|
|
||||||
) -> Usually<Self> {
|
|
||||||
let mut track = Self::default();
|
|
||||||
track.devices.push(Device::Sampler(
|
|
||||||
Sampler::new(jack, &"sampler", midi_from, audio_from, audio_to)?
|
|
||||||
));
|
|
||||||
Ok(track)
|
Ok(track)
|
||||||
}
|
}
|
||||||
pub fn width_inc (&mut self) {
|
pub fn width_inc (&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -136,13 +136,15 @@ impl Cli {
|
||||||
},
|
},
|
||||||
tracks: match mode {
|
tracks: match mode {
|
||||||
LaunchMode::Sequencer => vec![
|
LaunchMode::Sequencer => vec![
|
||||||
Track::new_sequencer()
|
Track::new()
|
||||||
],
|
],
|
||||||
LaunchMode::Groovebox => vec![
|
LaunchMode::Groovebox | LaunchMode::Sampler => vec![
|
||||||
Track::new_groovebox(jack, midi_froms.as_slice(), audio_froms, audio_tos)?
|
Track::new_with_sampler(
|
||||||
],
|
jack,
|
||||||
LaunchMode::Sampler => vec![
|
midi_froms.as_slice(),
|
||||||
Track::new_sampler(jack, midi_froms.as_slice(), audio_froms, audio_tos)?
|
audio_froms,
|
||||||
|
audio_tos,
|
||||||
|
)?
|
||||||
],
|
],
|
||||||
_ => vec![]
|
_ => vec![]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue