Zum Inhalt

apple/PhysarumApp/Sources/Model/AudioConfig.swift

import Foundation
import PhysarumEngine

/// A saveable, switchable audio-reactivity preset: routes + gain + auto-gain.
/// AudioTuning (loudness-response constants) is intentionally NOT included — it stays
/// a global/DEBUG device-calibration knob, not a shareable config.
struct AudioConfig: Codable, Identifiable, Equatable {
    var id: String
    var name: String
    var reactive: AudioReactive

    /// Equality is provided app-locally: the engine's `AudioReactive`/`AudioRoute`
    /// deliberately do NOT conform to `Equatable`, so we compare the `reactive`
    /// member through its Codable encoding rather than adding engine conformances.
    static func == (lhs: AudioConfig, rhs: AudioConfig) -> Bool {
        guard lhs.id == rhs.id, lhs.name == rhs.name else { return false }
        let enc = JSONEncoder()
        enc.outputFormatting = [.sortedKeys]
        return (try? enc.encode(lhs.reactive)) == (try? enc.encode(rhs.reactive))
    }
}