mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
move Phrase::process_in logic to Track::process
This commit is contained in:
parent
4b909ffdc3
commit
163ecaaed6
6 changed files with 107 additions and 105 deletions
53
src/main.rs
53
src/main.rs
|
|
@ -76,6 +76,9 @@ pub fn main () -> Usually<()> {
|
|||
12 * ppq/4 => MidiMessage::NoteOn { key: 40.into(), vel: 100.into() },
|
||||
}));
|
||||
|
||||
// FIXME:
|
||||
drums.sequence = Some(1);
|
||||
|
||||
let bass = state.add_track(Some("Bass"))?;
|
||||
bass.add_device(Plugin::lv2("Odin2", "file:///home/user/.lv2/Odin2.lv2")?);
|
||||
bass.add_phrase("Offbeat", ppq * 4, Some(phrase! {
|
||||
|
|
@ -89,6 +92,9 @@ pub fn main () -> Usually<()> {
|
|||
14 * ppq/4 => MidiMessage::NoteOn { key: 40.into(), vel: 100.into() },
|
||||
}));
|
||||
|
||||
// FIXME:
|
||||
bass.sequence = Some(0);
|
||||
|
||||
Ok(())
|
||||
}))
|
||||
}
|
||||
|
|
@ -144,54 +150,29 @@ pub struct App {
|
|||
/// Collection of tracks
|
||||
pub tracks: Vec<Track>,
|
||||
}
|
||||
|
||||
process!(App |self, _client, scope| {
|
||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
||||
let mut send_all_notes_off = false;
|
||||
let mut panic = false;
|
||||
if Some(transport.state) != self.playing {
|
||||
send_all_notes_off = true;
|
||||
panic = true;
|
||||
}
|
||||
self.playing = Some(transport.state);
|
||||
self.playhead = transport.pos.frame() as usize;
|
||||
let frame = scope.last_frame_time() as usize;
|
||||
let frames = scope.n_frames() as usize;
|
||||
for track in self.tracks.iter_mut() {
|
||||
// Output buffer
|
||||
let mut output: Vec<Option<Vec<Vec<u8>>>> = vec![None;frames];
|
||||
if send_all_notes_off { all_notes_off(&mut output); }
|
||||
// For highlighting keys
|
||||
let mut notes_on = vec![false;128];
|
||||
// Need to be borrowed outside the if
|
||||
let recording = track.recording;
|
||||
let monitoring = track.monitoring;
|
||||
// If there's an active phrase, play/record
|
||||
if let Some(phrase) = track.phrase_mut() {
|
||||
// Play from phrase into output buffer
|
||||
if self.playing == Some(TransportState::Rolling) {
|
||||
phrase.process_out(
|
||||
&mut output,
|
||||
&mut notes_on,
|
||||
&self.timebase,
|
||||
frame,
|
||||
frames
|
||||
);
|
||||
}
|
||||
// Play from input to monitor, and record into phrase.
|
||||
phrase.process_in(
|
||||
self.midi_in.as_ref().unwrap().iter(scope),
|
||||
&mut notes_on,
|
||||
if monitoring { Some(&mut output) } else { None },
|
||||
recording && self.playing == Some(TransportState::Rolling),
|
||||
&self.timebase,
|
||||
frame,
|
||||
);
|
||||
}
|
||||
track.notes_on = notes_on;
|
||||
write_output(&mut track.midi_out.writer(scope), &mut output, frames);
|
||||
track.process(
|
||||
self.midi_in.as_ref().unwrap().iter(scope),
|
||||
&self.timebase,
|
||||
self.playing,
|
||||
&scope,
|
||||
frame,
|
||||
frames,
|
||||
panic,
|
||||
);
|
||||
}
|
||||
Control::Continue
|
||||
});
|
||||
|
||||
impl App {
|
||||
pub fn toggle_play (&mut self) -> Usually<()> {
|
||||
self.playing = match self.playing.expect("after jack init") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue