Looper: stomp-style Reset button; reset on engine stop

Reset now renders as an LED + footswitch like the other transport buttons —
its LED lights whenever there's something to reset (any non-clear state),
driven off a phase didSet.

Add a Pedal.engineDidStop() hook, invoked for every pedal by a new
ShoeGaze.stopEngine() that the user-facing Stop control now calls (transient
stop-around-rebuild sequences still call engine.stop() directly, so pedals
keep state across a restart). LooperPedal overrides it to return to the clear
state, post to LyrebirdMessageCenter, and briefly show "Looper reset — engine
stopped." on its own card via the state indicator.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 15:20:33 -07:00
parent 83b8fff74b
commit fee7892101
5 changed files with 93 additions and 4 deletions
+35
View File
@@ -195,6 +195,41 @@ public final class ShoeGaze {
/// - `BusAllocatorError.noFreeBus` if no mono bus is available.
/// - `EngineAddError` if the engine rejects a node insertion.
@discardableResult
/// Stops the audio engine as a deliberate user action: notifies every pedal via
/// ``Pedal/engineDidStop()`` (so stateful pedals like the looper return to a clean state and
/// post a notice) and then stops the engine. Use this for the user-facing Stop control — not
/// for transient stop-around-rebuild sequences, which call `engine.stop()` directly so
/// pedals keep their state across the restart.
public func stopEngine() {
for pedal: Pedal in allPedals() {
pedal.engineDidStop()
}
engine.stop()
}
/// Every live `Pedal` across all boards, including pedals inside parallel and stereo-split
/// branches (branch pedals live in their section objects, not as top-level segments).
private func allPedals() -> [Pedal] {
var result: [Pedal] = []
for board: PedalBoard in boards {
for segment: BoardSegment in board.orderedSegments {
switch segment {
case .pedal(let pedal):
result.append(pedal)
case .parallel(let section):
result.append(contentsOf: section.branchA.pedals)
result.append(contentsOf: section.branchB.pedals)
case .stereoSplit(let section), .stereoUnzip(let section):
result.append(contentsOf: section.left.pedals)
result.append(contentsOf: section.right.pedals)
case .mergeToMono:
break
}
}
}
return result
}
public func addBoard() throws -> PedalBoard {
let board: PedalBoard = try PedalBoard(engine: engine, clock: clock)
board.label = "Board \(boards.count + 1)"