SPB Git

Repository Public

EffectCatalog.swift 10.5 KB 153 lines swift

1// ORIX DJ2// File: Packages/ORIXDJCore/Sources/ORIXDSP/EffectCatalog.swift3// Description: The single catalogue of effects and their parameters. The DSP units, the effects rack UI, the ORIX Script4//              schema, the in-app reference documentation and the Claude context are all generated from this table.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import Foundation910public enum EffectKind: String, CaseIterable, Codable, Sendable {11    case reverb, delay, echo, flanger, phaser, chorus, distortion, bitcrusher12    case highpass, lowpass, bandpass, tremolo, autopan, gate, compressor, limiter, beatrepeat, noise13}1415public enum EffectParamUnit: String, Codable, Sendable {16    /// 0...1 amount.17    case ratio18    case hertz19    case decibels20    /// Musical length in beats (1 = a quarter note). Converted with the transport tempo.21    case beats22    case milliseconds23    /// 0 or 1.24    case toggle25    /// Plain number (bits, factor, ratio n:1).26    case number27}2829public struct EffectParamSpec: Sendable, Codable, Equatable {30    public let id: String31    public let name: String32    public let unit: EffectParamUnit33    public let min: Float34    public let max: Float35    public let defaultValue: Float36    /// True when the control should be laid out on a logarithmic scale (frequencies, times).37    public let logarithmic: Bool38    public let doc: String3940    public init(_ id: String, _ name: String, _ unit: EffectParamUnit, _ min: Float, _ max: Float, _ defaultValue: Float, log: Bool = false, _ doc: String) {41        self.id = id; self.name = name; self.unit = unit; self.min = min; self.max = max42        self.defaultValue = defaultValue; logarithmic = log; self.doc = doc43    }44}4546public enum EffectCategory: String, Codable, Sendable, CaseIterable {47    case space, modulation, filter, dynamics, distortion, rhythm, generator48}4950public struct EffectDescriptor: Sendable, Equatable {51    public let kind: EffectKind52    public let displayName: String53    public let category: EffectCategory54    public let summary: String55    public let params: [EffectParamSpec]56    /// Default wet/dry mix (0 = dry only, 1 = wet only).57    public let defaultMix: Float5859    public func index(of paramID: String) -> Int? { params.firstIndex { $0.id == paramID } }60}6162public enum EffectCatalog {63    public static func descriptor(_ kind: EffectKind) -> EffectDescriptor { table[kind]! }6465    public static let all: [EffectDescriptor] = [66        EffectDescriptor(kind: .reverb, displayName: "Reverb", category: .space, summary: "Algorithmic room reverb (feedback comb and all-pass network).", params: [67            EffectParamSpec("size", "Size", .ratio, 0, 1, 0.55, "Room size: longer decay as it grows."),68            EffectParamSpec("damping", "Damping", .ratio, 0, 1, 0.45, "High-frequency absorption inside the tail."),69            EffectParamSpec("predelay", "Pre-delay", .milliseconds, 0, 200, 15, "Gap before the first reflections."),70            EffectParamSpec("width", "Width", .ratio, 0, 1, 1, "Stereo spread of the tail."),71        ], defaultMix: 0.3),72        EffectDescriptor(kind: .delay, displayName: "Delay", category: .space, summary: "Clean beat-synchronised stereo delay.", params: [73            EffectParamSpec("time", "Time", .beats, 0.0625, 4, 0.5, log: true, "Delay length in beats."),74            EffectParamSpec("feedback", "Feedback", .ratio, 0, 0.95, 0.35, "Amount of the delayed signal fed back."),75            EffectParamSpec("pingpong", "Ping-pong", .toggle, 0, 1, 0, "Alternate repeats between left and right."),76        ], defaultMix: 0.25),77        EffectDescriptor(kind: .echo, displayName: "Echo", category: .space, summary: "Tape-style echo: repeats get darker through a low-pass in the feedback path.", params: [78            EffectParamSpec("time", "Time", .beats, 0.0625, 4, 0.75, log: true, "Echo length in beats."),79            EffectParamSpec("feedback", "Feedback", .ratio, 0, 0.95, 0.5, "Amount of each repeat fed back."),80            EffectParamSpec("tone", "Tone", .hertz, 200, 12000, 4000, log: true, "Low-pass applied to every repeat."),81        ], defaultMix: 0.35),82        EffectDescriptor(kind: .flanger, displayName: "Flanger", category: .modulation, summary: "Short modulated delay with feedback (jet sweep).", params: [83            EffectParamSpec("rate", "Rate", .hertz, 0.02, 5, 0.25, log: true, "Sweep speed."),84            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 0.7, "Sweep range."),85            EffectParamSpec("feedback", "Feedback", .ratio, -0.95, 0.95, 0.5, "Resonance of the comb; negative inverts it."),86        ], defaultMix: 0.5),87        EffectDescriptor(kind: .phaser, displayName: "Phaser", category: .modulation, summary: "Six-stage all-pass phaser.", params: [88            EffectParamSpec("rate", "Rate", .hertz, 0.02, 5, 0.4, log: true, "Sweep speed."),89            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 0.8, "Sweep range."),90            EffectParamSpec("feedback", "Feedback", .ratio, 0, 0.9, 0.5, "Notch resonance."),91        ], defaultMix: 0.5),92        EffectDescriptor(kind: .chorus, displayName: "Chorus", category: .modulation, summary: "Three-voice stereo chorus.", params: [93            EffectParamSpec("rate", "Rate", .hertz, 0.05, 5, 0.8, log: true, "Modulation speed."),94            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 0.5, "Pitch modulation amount."),95        ], defaultMix: 0.5),96        EffectDescriptor(kind: .distortion, displayName: "Distortion", category: .distortion, summary: "Soft-clipping overdrive with tone control and level compensation.", params: [97            EffectParamSpec("drive", "Drive", .decibels, 0, 36, 12, "Gain into the clipper."),98            EffectParamSpec("tone", "Tone", .hertz, 500, 16000, 8000, log: true, "Low-pass after the clipper."),99        ], defaultMix: 1),100        EffectDescriptor(kind: .bitcrusher, displayName: "Bitcrusher", category: .distortion, summary: "Bit-depth and sample-rate reduction.", params: [101            EffectParamSpec("bits", "Bits", .number, 2, 16, 8, "Quantisation depth."),102            EffectParamSpec("downsample", "Downsample", .number, 1, 40, 4, "Sample-and-hold factor."),103        ], defaultMix: 1),104        EffectDescriptor(kind: .highpass, displayName: "High-pass", category: .filter, summary: "Resonant 12 dB/octave high-pass filter.", params: [105            EffectParamSpec("cutoff", "Cutoff", .hertz, 20, 20000, 200, log: true, "Corner frequency."),106            EffectParamSpec("resonance", "Resonance", .number, 0.5, 10, 0.707, log: true, "Filter Q."),107        ], defaultMix: 1),108        EffectDescriptor(kind: .lowpass, displayName: "Low-pass", category: .filter, summary: "Resonant 12 dB/octave low-pass filter.", params: [109            EffectParamSpec("cutoff", "Cutoff", .hertz, 20, 20000, 8000, log: true, "Corner frequency."),110            EffectParamSpec("resonance", "Resonance", .number, 0.5, 10, 0.707, log: true, "Filter Q."),111        ], defaultMix: 1),112        EffectDescriptor(kind: .bandpass, displayName: "Band-pass", category: .filter, summary: "Resonant band-pass filter.", params: [113            EffectParamSpec("cutoff", "Centre", .hertz, 20, 20000, 1000, log: true, "Centre frequency."),114            EffectParamSpec("resonance", "Resonance", .number, 0.5, 10, 1.2, log: true, "Filter Q (narrower as it grows)."),115        ], defaultMix: 1),116        EffectDescriptor(kind: .tremolo, displayName: "Tremolo", category: .rhythm, summary: "Beat-locked amplitude modulation.", params: [117            EffectParamSpec("rate", "Rate", .beats, 0.03125, 4, 0.25, log: true, "Length of one cycle in beats."),118            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 0.8, "Modulation depth."),119            EffectParamSpec("shape", "Shape", .ratio, 0, 1, 0, "0 = sine, 1 = square."),120        ], defaultMix: 1),121        EffectDescriptor(kind: .autopan, displayName: "Auto-pan", category: .rhythm, summary: "Beat-locked left/right panning.", params: [122            EffectParamSpec("rate", "Rate", .beats, 0.03125, 8, 1, log: true, "Length of one cycle in beats."),123            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 1, "Pan range."),124        ], defaultMix: 1),125        EffectDescriptor(kind: .gate, displayName: "Beat Gate", category: .rhythm, summary: "Rhythmic gate locked to the beat grid.", params: [126            EffectParamSpec("rate", "Rate", .beats, 0.03125, 4, 0.25, log: true, "Length of one gate cycle in beats."),127            EffectParamSpec("duty", "Duty", .ratio, 0.05, 0.95, 0.5, "Open fraction of each cycle."),128            EffectParamSpec("depth", "Depth", .ratio, 0, 1, 1, "Attenuation while closed."),129        ], defaultMix: 1),130        EffectDescriptor(kind: .compressor, displayName: "Compressor", category: .dynamics, summary: "Feed-forward stereo-linked compressor.", params: [131            EffectParamSpec("threshold", "Threshold", .decibels, -60, 0, -18, "Level above which gain reduction starts."),132            EffectParamSpec("ratio", "Ratio", .number, 1, 20, 4, log: true, "Compression ratio n:1."),133            EffectParamSpec("attack", "Attack", .milliseconds, 0.1, 200, 10, log: true, "Attack time."),134            EffectParamSpec("release", "Release", .milliseconds, 10, 2000, 150, log: true, "Release time."),135            EffectParamSpec("makeup", "Make-up", .decibels, 0, 24, 0, "Gain applied after compression."),136        ], defaultMix: 1),137        EffectDescriptor(kind: .limiter, displayName: "Limiter", category: .dynamics, summary: "Look-ahead peak limiter.", params: [138            EffectParamSpec("ceiling", "Ceiling", .decibels, -24, 0, -1, "Maximum output peak."),139            EffectParamSpec("release", "Release", .milliseconds, 10, 1000, 100, log: true, "Recovery time."),140        ], defaultMix: 1),141        EffectDescriptor(kind: .beatrepeat, displayName: "Beat Repeat", category: .rhythm, summary: "Captures the last slice and repeats it while enabled.", params: [142            EffectParamSpec("length", "Length", .beats, 0.03125, 4, 0.25, log: true, "Slice length in beats."),143        ], defaultMix: 1),144        EffectDescriptor(kind: .noise, displayName: "Noise Sweep", category: .generator, summary: "Filtered white noise added to the signal, for risers and sweeps.", params: [145            EffectParamSpec("level", "Level", .decibels, -60, 0, -18, "Noise level."),146            EffectParamSpec("cutoff", "Cutoff", .hertz, 100, 16000, 1000, log: true, "Band-pass centre of the noise."),147            EffectParamSpec("resonance", "Resonance", .number, 0.5, 10, 2, log: true, "Sharpness of the noise band."),148        ], defaultMix: 1),149    ]150151    private static let table: [EffectKind: EffectDescriptor] = Dictionary(uniqueKeysWithValues: all.map { ($0.kind, $0) })152}153
Files main
Menu

Theme