44 lines
1.5 KiB
Swift
44 lines
1.5 KiB
Swift
// PedalState.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// Serialisable snapshot of one pedal's parameter values.
|
|
///
|
|
/// `type` stores the pedal's `displayName` and is used by `PedalRegistry` to
|
|
/// reconstruct the correct subclass on load. `knobValues` mirrors `Pedal.knobs`
|
|
/// in order — effect-specific knobs first, then `mix`, then `level`. `bypass`
|
|
/// stores the bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
|
///
|
|
/// - Note: Extra knob values beyond the pedal's current knob count are silently
|
|
/// ignored on apply; missing values (fewer entries than knobs) leave trailing
|
|
/// knobs at their current value.
|
|
public struct PedalState: Codable, Equatable {
|
|
|
|
/// The pedal's `displayName` — used as a factory key by `PedalRegistry`.
|
|
public let type: String
|
|
|
|
/// Knob values in the same order as `Pedal.knobs` (effect knobs then Mix, Level).
|
|
public let knobValues: [Double]
|
|
|
|
/// Bypass parameter value. `0.0` = engaged, `1.0` = bypassed.
|
|
public let bypass: Double
|
|
|
|
/// Creates a pedal state snapshot.
|
|
///
|
|
/// - Parameters:
|
|
/// - type: The pedal's `displayName`, used to identify the pedal type on load.
|
|
/// - knobValues: Current knob values in `Pedal.knobs` order.
|
|
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
|
public init(
|
|
type: String,
|
|
knobValues: [Double],
|
|
bypass: Double
|
|
) {
|
|
self.type = type
|
|
self.knobValues = knobValues
|
|
self.bypass = bypass
|
|
}
|
|
}
|