mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
clone ports as unowned and pass outwards
This commit is contained in:
parent
394355331d
commit
ddaf870271
9 changed files with 123 additions and 112 deletions
|
|
@ -17,16 +17,6 @@ pub struct Plugin {
|
|||
render!(Plugin = crate::view::plugin::render);
|
||||
handle!(Plugin = crate::control::plugin::handle);
|
||||
process!(Plugin = Plugin::process);
|
||||
ports!(Plugin {
|
||||
audio: {
|
||||
ins: |p|Ok(p.ports.audio_ins.values().collect()),
|
||||
outs: |p|Ok(p.ports.audio_outs.values().collect()),
|
||||
}
|
||||
midi: {
|
||||
ins: |p|Ok(p.ports.midi_ins.values().collect()),
|
||||
outs: |p|Ok(p.ports.midi_outs.values().collect()),
|
||||
}
|
||||
});
|
||||
|
||||
pub enum PluginKind {
|
||||
LV2(LV2Plugin),
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl LV2Plugin {
|
|||
}
|
||||
|
||||
impl super::Plugin {
|
||||
pub fn lv2 (name: &str, path: &str) -> Usually<Arc<Mutex<Box<dyn Device>>>> {
|
||||
pub fn lv2 (name: &str, path: &str) -> Usually<JackDevice> {
|
||||
let plugin = LV2Plugin::new(path)?;
|
||||
Jack::new(name)?
|
||||
.ports_from_lv2(&plugin.plugin)?
|
||||
|
|
|
|||
|
|
@ -74,21 +74,21 @@ handle!(Sampler = crate::control::sampler::handle);
|
|||
//}
|
||||
//});
|
||||
process!(Sampler = Sampler::process);
|
||||
ports!(Sampler {
|
||||
audio: {
|
||||
ins: |s|Ok(s.ports.audio_ins.values().collect()),
|
||||
outs: |s|Ok(s.ports.audio_outs.values().collect()),
|
||||
}
|
||||
midi: {
|
||||
ins: |s|Ok(s.ports.midi_ins.values().collect()),
|
||||
outs: |s|Ok(s.ports.midi_outs.values().collect()),
|
||||
}
|
||||
});
|
||||
//ports!(Sampler {
|
||||
//audio: {
|
||||
//ins: |s|Ok(s.ports.audio_ins.values().collect()),
|
||||
//outs: |s|Ok(s.ports.audio_outs.values().collect()),
|
||||
//}
|
||||
//midi: {
|
||||
//ins: |s|Ok(s.ports.midi_ins.values().collect()),
|
||||
//outs: |s|Ok(s.ports.midi_outs.values().collect()),
|
||||
//}
|
||||
//});
|
||||
|
||||
impl Sampler {
|
||||
pub fn new (
|
||||
name: &str, samples: Option<BTreeMap<u7, Arc<Sample>>>,
|
||||
) -> Usually<Arc<Mutex<Box<dyn Device>>>> {
|
||||
) -> Usually<JackDevice> {
|
||||
Jack::new(name)?
|
||||
.register_midi_in("midi")?
|
||||
.register_audio_in("recL")?
|
||||
|
|
@ -104,7 +104,7 @@ impl Sampler {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
// Output buffer: this will be copied to the audio outs.
|
||||
let channel_count = self.ports.audio_outs.len();
|
||||
let mut mixed = vec![vec![0.0;scope.n_frames() as usize];channel_count];
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub struct Track {
|
|||
/// Red keys on piano roll.
|
||||
pub notes_on: Vec<bool>,
|
||||
/// Device chain
|
||||
pub devices: Vec<Arc<Mutex<Box<dyn Device>>>>,
|
||||
pub devices: Vec<JackDevice>,
|
||||
/// Device selector
|
||||
pub device: usize,
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ impl Track {
|
|||
name: &str,
|
||||
jack: &Client,
|
||||
phrases: Option<Vec<Phrase>>,
|
||||
devices: Option<Vec<Arc<Mutex<Box<dyn Device>>>>>,
|
||||
devices: Option<Vec<JackDevice>>,
|
||||
) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
|
|
@ -44,7 +44,7 @@ impl Track {
|
|||
})
|
||||
}
|
||||
pub fn device (&self, i: usize) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.devices.get(i).map(|d|d.lock().unwrap())
|
||||
self.devices.get(i).map(|d|d.state.lock().unwrap())
|
||||
}
|
||||
pub fn active_device (&self) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.device(self.device)
|
||||
|
|
@ -73,22 +73,10 @@ impl Track {
|
|||
|
||||
ports!(Track {
|
||||
audio: {
|
||||
outs: |track|{
|
||||
if let Some(device) = track.last_device() {
|
||||
device.audio_outs()
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
},
|
||||
outs: |_t|Ok(vec![]),
|
||||
}
|
||||
midi: {
|
||||
ins: |track|if let Some(device) = track.first_device() {
|
||||
device.midi_ins()
|
||||
} else {
|
||||
Ok(vec![])
|
||||
},
|
||||
outs: |track|Ok(vec![
|
||||
&track.midi_out
|
||||
]),
|
||||
ins: |_t|Ok(vec![]),
|
||||
outs: |_t|Ok(vec![]),
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue