mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
add HasJack; Arrangement
This commit is contained in:
parent
744ce21e24
commit
e73c31d494
12 changed files with 565 additions and 387 deletions
102
tek/src/audio.rs
102
tek/src/audio.rs
|
|
@ -1,4 +1,105 @@
|
|||
use crate::*;
|
||||
impl HasJack for App {
|
||||
fn jack (&self) -> &Arc<RwLock<JackConnection>> { &self.jack }
|
||||
}
|
||||
impl HasJack for Arranger {
|
||||
fn jack (&self) -> &Arc<RwLock<JackConnection>> { &self.jack }
|
||||
}
|
||||
audio!(|self: App, client, scope|{
|
||||
// Start profiling cycle
|
||||
let t0 = self.perf.get_t0();
|
||||
// Update transport clock
|
||||
if Control::Quit == ClockAudio(self).process(client, scope) {
|
||||
return Control::Quit
|
||||
}
|
||||
// Collect MIDI input (TODO preallocate)
|
||||
let midi_in = self.midi_ins.iter()
|
||||
.map(|port|port.port.iter(scope)
|
||||
.map(|RawMidi { time, bytes }|(time, LiveEvent::parse(bytes)))
|
||||
.collect::<Vec<_>>())
|
||||
.collect::<Vec<_>>();
|
||||
// Update standalone MIDI sequencer
|
||||
if let Some(player) = self.player.as_mut() {
|
||||
if Control::Quit == PlayerAudio(
|
||||
player,
|
||||
&mut self.note_buf,
|
||||
&mut self.midi_buf,
|
||||
).process(client, scope) {
|
||||
return Control::Quit
|
||||
}
|
||||
}
|
||||
// Update standalone sampler
|
||||
if let Some(sampler) = self.sampler.as_mut() {
|
||||
if Control::Quit == SamplerAudio(sampler).process(client, scope) {
|
||||
return Control::Quit
|
||||
}
|
||||
//for port in midi_in.iter() {
|
||||
//for message in port.iter() {
|
||||
//match message {
|
||||
//Ok(M
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
}
|
||||
// TODO move these to editor and sampler?:
|
||||
for port in midi_in.iter() {
|
||||
for event in port.iter() {
|
||||
match event {
|
||||
(time, Ok(LiveEvent::Midi {message, ..})) => match message {
|
||||
MidiMessage::NoteOn {ref key, ..} if let Some(editor) = self.editor.as_ref() => {
|
||||
editor.set_note_point(key.as_int() as usize);
|
||||
},
|
||||
MidiMessage::Controller {controller, value} if let (Some(editor), Some(sampler)) = (
|
||||
self.editor.as_ref(),
|
||||
self.sampler.as_ref(),
|
||||
) => {
|
||||
// TODO: give sampler its own cursor
|
||||
if let Some(sample) = &sampler.mapped[editor.note_point()] {
|
||||
sample.write().unwrap().handle_cc(*controller, *value)
|
||||
}
|
||||
}
|
||||
_ =>{}
|
||||
},
|
||||
_ =>{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update track sequencers
|
||||
let tracks = &mut self.tracks;
|
||||
let note_buf = &mut self.note_buf;
|
||||
let midi_buf = &mut self.midi_buf;
|
||||
if Control::Quit == TracksAudio(tracks, note_buf, midi_buf).process(client, scope) {
|
||||
return Control::Quit
|
||||
}
|
||||
|
||||
// TODO: update timeline position in editor.
|
||||
// must be in sync with clip's playback. since
|
||||
// a clip can be on multiple tracks and launched
|
||||
// at different times, add a playhead with the
|
||||
// playing track's color.
|
||||
//self.now.set(0.);
|
||||
//if let ArrangerSelection::Clip(t, s) = self.selected {
|
||||
//let clip = self.scenes.get(s).map(|scene|scene.clips.get(t));
|
||||
//if let Some(Some(Some(clip))) = clip {
|
||||
//if let Some(track) = self.tracks().get(t) {
|
||||
//if let Some((ref started_at, Some(ref playing))) = track.player.play_clip {
|
||||
//let clip = clip.read().unwrap();
|
||||
//if *playing.read().unwrap() == *clip {
|
||||
//let pulse = self.current().pulse.get();
|
||||
//let start = started_at.pulse.get();
|
||||
//let now = (pulse - start) % clip.length as f64;
|
||||
//self.now.set(now);
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
// End profiling cycle
|
||||
self.perf.update(t0, scope);
|
||||
Control::Continue
|
||||
});
|
||||
|
||||
audio!(|self: Sequencer, client, scope|{
|
||||
// Start profiling cycle
|
||||
|
|
@ -8,7 +109,6 @@ audio!(|self: Sequencer, client, scope|{
|
|||
if Control::Quit == ClockAudio(self).process(client, scope) {
|
||||
return Control::Quit
|
||||
}
|
||||
|
||||
// Update MIDI sequencer
|
||||
if Control::Quit == PlayerAudio(
|
||||
&mut self.player, &mut self.note_buf, &mut self.midi_buf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue