Add segmented pedal switch control; Mu-Tron sweep + mode switches
Introduces a discrete multi-position switch control alongside the rotary knobs, and uses it to expose the Mu-Tron's sweep direction and filter mode. - PedalSwitch: UI-agnostic descriptor (label, node, ordered options of caption + value), parallel to PedalKnob. Two options make a two-state switch, three a three-state switch. - PedalSwitchView: segmented SwiftUI control bound to a UIParamNode. Lit segment is the option nearest the node's value; tapping writes that option's value. Serves both two- and three-state switches. - Pedal gains an effectSwitches hook; PedalView renders a switch row between the knob grid and the footswitch. - MuTronPedal: sweep direction is now a two-state switch (Down/Up) and filter mode a three-state switch (LP/BP/HP). The effect builds six MuTronIII instances (three modes x two directions) selected by a nested Select so every filter state stays warmed for click-free switching. - Presets: PedalState gains a backward-compatible switchValues array (decodes to empty for older presets); captureState/applyState persist and restore switch positions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,9 +17,11 @@ extension Pedal {
|
||||
/// - Returns: A `PedalState` reflecting the pedal's current parameter values.
|
||||
public func captureState() -> PedalState {
|
||||
let values: [Double] = knobs.map { $0.node.value }
|
||||
let switchValues: [Double] = effectSwitches.map { $0.node.value }
|
||||
return PedalState(
|
||||
type: displayName,
|
||||
knobValues: values,
|
||||
switchValues: switchValues,
|
||||
bypass: bypass
|
||||
)
|
||||
}
|
||||
@@ -27,10 +29,12 @@ extension Pedal {
|
||||
/// Applies a previously captured `PedalState` to this pedal's parameters.
|
||||
///
|
||||
/// For each (knob, value) pair in `zip(knobs, state.knobValues)`, the knob's
|
||||
/// `UIParamNode` is updated via `node.update(_:)`. If `state.knobValues` has
|
||||
/// fewer entries than `knobs`, the trailing knobs retain their current values.
|
||||
/// Extra values beyond `knobs.count` are ignored. The `bypass` parameter is
|
||||
/// always applied regardless of knob-count mismatches.
|
||||
/// `UIParamNode` is updated via `node.update(_:)`; switch positions are restored the
|
||||
/// same way from `zip(effectSwitches, state.switchValues)`. If either array has fewer
|
||||
/// entries than its controls, the trailing controls retain their current values; extra
|
||||
/// values are ignored. The `bypass` parameter is always applied regardless of any
|
||||
/// count mismatch. Presets saved before switches existed carry an empty
|
||||
/// `switchValues`, leaving switch positions at their defaults.
|
||||
///
|
||||
/// - Parameter state: The state to restore. The `state.type` is not validated
|
||||
/// against `displayName` — the caller is responsible for matching types before
|
||||
@@ -39,6 +43,9 @@ extension Pedal {
|
||||
for (knob, value) in zip(knobs, state.knobValues) {
|
||||
knob.node.update(value)
|
||||
}
|
||||
for (pedalSwitch, value) in zip(effectSwitches, state.switchValues) {
|
||||
pedalSwitch.node.update(value)
|
||||
}
|
||||
bypass = state.bypass
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user