mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +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 {
|
||||
pub const MIN_WIDTH: usize = 9;
|
||||
/// Create a new track containing a sequencer.
|
||||
pub fn new_sequencer () -> Self {
|
||||
let mut track = Self::default();
|
||||
track.devices.push(Device::Sequencer(MidiPlayer::default()));
|
||||
track
|
||||
/// Create a new track with only the default [MidiPlayer].
|
||||
pub fn new () -> Self {
|
||||
Self::default()
|
||||
}
|
||||
/// Create a new track containing a sequencer and sampler.
|
||||
pub fn new_groovebox (
|
||||
/// Create a new track connecting the [MidiPlayer] to a [Sampler].
|
||||
pub fn new_with_sampler (
|
||||
jack: &Jack,
|
||||
midi_from: &[PortConnect],
|
||||
audio_from: &[&[PortConnect];2],
|
||||
audio_to: &[&[PortConnect];2],
|
||||
) -> Usually<Self> {
|
||||
let mut track = Self::new_sequencer();
|
||||
track.devices.push(Device::Sampler(
|
||||
Sampler::new(jack, &"sampler", midi_from, audio_from, audio_to)?
|
||||
));
|
||||
Ok(track)
|
||||
}
|
||||
/// 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)?
|
||||
));
|
||||
let name = jack.with_client(|c|c.name().to_string());
|
||||
let midi = track.player.midi_outs[0].name();
|
||||
let port = PortConnect::exact(format!("{name}:{midi}"));
|
||||
let sampler = Sampler::new(jack, &"sampler", &[port], audio_from, audio_to)?;
|
||||
track.devices.push(Device::Sampler(sampler));
|
||||
Ok(track)
|
||||
}
|
||||
pub fn width_inc (&mut self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue