per-track reset

This commit is contained in:
🪞👃🪞 2024-07-05 20:14:49 +03:00
parent 2989c79fd0
commit 63b5eb3740
4 changed files with 17 additions and 6 deletions

View file

@ -302,10 +302,12 @@ fn activate (app: &mut App) -> Usually<bool> {
if app.track_cursor == 0 { if app.track_cursor == 0 {
for (i, track) in app.tracks.iter_mut().enumerate() { for (i, track) in app.tracks.iter_mut().enumerate() {
track.sequence = scene.clips[i]; track.sequence = scene.clips[i];
track.reset = true;
} }
} else { } else {
let track = &mut app.tracks[app.track_cursor - 1]; let track = &mut app.tracks[app.track_cursor - 1];
track.sequence = scene.clips[app.track_cursor - 1]; track.sequence = scene.clips[app.track_cursor - 1];
track.reset = true;
}; };
true true
} }

View file

@ -82,7 +82,7 @@ process!(App |self, _client, scope| {
} = scope.cycle_times().unwrap(); } = scope.cycle_times().unwrap();
let transport = self.transport.as_ref().unwrap().query().unwrap(); let transport = self.transport.as_ref().unwrap().query().unwrap();
self.playhead = transport.pos.frame() as usize; self.playhead = transport.pos.frame() as usize;
let mut send_all_off = false; let mut reset = false;
if self.playing != Some(transport.state) { if self.playing != Some(transport.state) {
match transport.state { match transport.state {
TransportState::Rolling => { TransportState::Rolling => {
@ -90,7 +90,7 @@ process!(App |self, _client, scope| {
}, },
TransportState::Stopped => { TransportState::Stopped => {
self.play_started = None; self.play_started = None;
send_all_off = true; reset = true;
}, },
_ => {} _ => {}
} }
@ -103,7 +103,7 @@ process!(App |self, _client, scope| {
self.playing, self.playing,
self.play_started, self.play_started,
self.quant, self.quant,
send_all_off, reset,
&scope, &scope,
(current_frames as usize, self.chunk_size), (current_frames as usize, self.chunk_size),
(current_usecs as usize, next_usecs.saturating_sub(current_usecs) as usize), (current_usecs as usize, next_usecs.saturating_sub(current_usecs) as usize),

View file

@ -22,6 +22,9 @@ pub struct Track {
pub devices: Vec<JackDevice>, pub devices: Vec<JackDevice>,
/// Device selector /// Device selector
pub device: usize, pub device: usize,
/// Send all notes off
/// FIXME: Some(nframes)?
pub reset: bool
} }
ports!(Track { ports!(Track {
audio: { audio: {
@ -51,6 +54,7 @@ impl Track {
phrases: phrases.unwrap_or_else(||Vec::with_capacity(16)), phrases: phrases.unwrap_or_else(||Vec::with_capacity(16)),
devices: devices.unwrap_or_else(||Vec::with_capacity(16)), devices: devices.unwrap_or_else(||Vec::with_capacity(16)),
device: 0, device: 0,
reset: true,
}) })
} }
pub fn device (&self) -> Option<RwLockReadGuard<Box<dyn Device>>> { pub fn device (&self) -> Option<RwLockReadGuard<Box<dyn Device>>> {
@ -117,7 +121,7 @@ impl Track {
playing: Option<TransportState>, playing: Option<TransportState>,
started: Option<usize>, started: Option<usize>,
quant: usize, quant: usize,
panic: bool, reset: bool,
scope: &ProcessScope, scope: &ProcessScope,
(frame0, frames): (usize, usize), (frame0, frames): (usize, usize),
(usec0, usecs): (usize, usize), (usec0, usecs): (usize, usize),
@ -131,7 +135,11 @@ impl Track {
frame.clear(); frame.clear();
} }
// Emit "all notes off" at start of buffer if requested // Emit "all notes off" at start of buffer if requested
if panic { if self.reset {
all_notes_off(&mut self.midi_out_buf);
self.reset = false;
}
else if reset {
all_notes_off(&mut self.midi_out_buf); all_notes_off(&mut self.midi_out_buf);
} }
// Play from phrase into output buffer // Play from phrase into output buffer

View file

@ -45,12 +45,13 @@ render!(App |self, buf, area| {
.get(self.track_cursor - 1) .get(self.track_cursor - 1)
.unwrap(); .unwrap();
let chain_area = Rect { x, y: y + height - height / 3 - 1, width, height: height / 3 };
ChainView { ChainView {
focused: self.section == 1, focused: self.section == 1,
track: Some(track), track: Some(track),
vertical: false, vertical: false,
} }
.render(buf, Rect { x, y: y + height - height / 3 - 1, width, height: height / 3 })?.height; .render(buf, chain_area)?;
let phrase = self.phrase(); let phrase = self.phrase();