Skip to content

Commit

Permalink
Fix regression that broke pause during recording or overdubbing
Browse files Browse the repository at this point in the history
  • Loading branch information
mwylde committed Nov 12, 2021
1 parent 5b877f3 commit d552d7b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions loopers-common/src/gui_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub const WAVEFORM_DOWNSAMPLE: usize = 2048;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum EngineState {
Stopped,
Paused,
Active,
}

Expand Down
10 changes: 5 additions & 5 deletions loopers-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ impl Engine {
self.state = EngineState::Active;
}
Pause => {
self.state = EngineState::Stopped;
self.state = EngineState::Paused;
}
Stop => {
self.state = EngineState::Stopped;
self.reset();
}
StartStop => {
self.state = match self.state {
EngineState::Stopped => EngineState::Active,
EngineState::Stopped | EngineState::Paused => EngineState::Active,
EngineState::Active => {
self.reset();
EngineState::Stopped
Expand All @@ -523,8 +523,8 @@ impl Engine {
}
PlayPause => {
self.state = match self.state {
EngineState::Stopped => EngineState::Active,
EngineState::Active => EngineState::Stopped,
EngineState::Stopped | EngineState::Paused => EngineState::Active,
EngineState::Active => EngineState::Paused,
}
}
Reset => {
Expand Down Expand Up @@ -994,7 +994,7 @@ impl Engine {
self.output_right[i] = *r as f64;
}

if self.state != EngineState::Active && (!self.triggers.is_empty() ||
if (self.state != EngineState::Active && self.state != EngineState::Paused) && (!self.triggers.is_empty() ||
self.loopers.iter().any(|l| l.local_mode() == LooperMode::Recording ||
l.local_mode() == LooperMode::Overdubbing)) {
self.state = EngineState::Active;
Expand Down
14 changes: 7 additions & 7 deletions loopers-gui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,13 @@ impl PlayPauseButton {
};
}

if data.engine_state.engine_state == EngineState::Stopped {
if data.engine_state.engine_state == EngineState::Active {
// draw pause button
let rect1 = Rect::new(0.0, 0.0, 7.5, 20.0);
let rect2 = Rect::new(12.5, 0.0, 20.0, 20.0);
canvas.draw_rect(&rect1, &paint);
canvas.draw_rect(&rect2, &paint);
} else {
// draw play icon
let mut path = Path::new();
path.move_to((0.0, 0.0));
Expand All @@ -1244,12 +1250,6 @@ impl PlayPauseButton {
path.line_to((0.0, 0.0));
path.close();
canvas.draw_path(&path, &paint);
} else {
// draw pause button
let rect1 = Rect::new(0.0, 0.0, 7.5, 20.0);
let rect2 = Rect::new(12.5, 0.0, 20.0, 20.0);
canvas.draw_rect(&rect1, &paint);
canvas.draw_rect(&rect2, &paint);
}

Size::new(25.0, 25.0)
Expand Down

0 comments on commit d552d7b

Please sign in to comment.