Looper: also reset on rig teardown
Add a Pedal.rigWillTeardown() hook fired for every pedal at the top of ShoeGaze.teardown() (rig load / clear / input-source change), while the pedal is still live. LooperPedal resets and posts a notice, sharing the path with engineDidStop() — so a looper stops its background routines cleanly and logs before its instance is discarded across a rig change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -470,9 +470,21 @@ public final class LooperPedal: Pedal {
|
||||
/// state — a stopped engine can't keep a loop running, and resuming into a half-recorded take
|
||||
/// is confusing. Posts a notice to the message log and briefly on the pedal's own card.
|
||||
public override func engineDidStop() {
|
||||
resetAndNotify("engine stopped")
|
||||
}
|
||||
|
||||
/// The rig is being torn down (load / clear / input-source change) — reset before this looper
|
||||
/// instance is discarded, stopping any background routines cleanly and logging a notice.
|
||||
public override func rigWillTeardown() {
|
||||
resetAndNotify("rig changed")
|
||||
}
|
||||
|
||||
/// Returns to the clear state and posts a notice (message log + briefly on the pedal card),
|
||||
/// unless already clear. Shared by ``engineDidStop()`` and ``rigWillTeardown()``.
|
||||
private func resetAndNotify(_ reason: String) {
|
||||
guard phase != .clear else { return }
|
||||
resetLoop()
|
||||
let message: String = "Looper reset — engine stopped."
|
||||
let message: String = "Looper reset — \(reason)."
|
||||
noticeText = message
|
||||
noticeExpiry = Date().addingTimeInterval(LooperPedal.noticeDuration)
|
||||
LyrebirdMessageCenter.shared.info(message, source: displayName)
|
||||
|
||||
Reference in New Issue
Block a user