//___FILEHEADER___ import Foundation import AVFoundation import AudioToolbox import LyrebirdSynth // MARK: - ___FILEBASENAMEASIDENTIFIER___ /// Synthesizer driven by the AUv3 host. Each `@LiveParam` slot maps to an /// `AUParameter` exposed by the wrapper class below via /// `parameterMetadata()`. The host writes parameter values through the AU's /// `AUParameterTree`; `LyrebirdAudioUnit` forwards each write to the matching /// `@LiveParam` (atomic, RT-safe). public final class ___FILEBASENAMEASIDENTIFIER___: SynthesizerBase { /// Fundamental frequency in Hz. Range [20, 8000]. @LiveParam public var frequency: Double = 440.0 /// Output amplitude (linear gain). Range [0, 1]. @LiveParam public var amplitude: Double = 0.3 public override func build() { let osc = OscSin.Audio(freq: $frequency) let voice = osc * $amplitude // Mono → stereo for AUv3 host compatibility (most hosts negotiate // stereo output buses). output(bus: 0, source: voice) output(bus: 1, source: voice) } } // MARK: - ___FILEBASENAMEASIDENTIFIER___AudioUnit /// AUv3 wrapper. Subclasses `LyrebirdAudioUnit`, which handles render setup, /// parameter ramping, and CoreMIDI 2.0 input. Override only the two class /// methods below. /// /// To expose this AU to hosts (Logic, GarageBand, AUM, Loopy Pro, …): /// /// 1. Make the containing target an Audio Unit App Extension (`.appex`). /// 2. Add an `AudioComponents` array to the extension's Info.plist: /// - `type: aumu` (music device) — change to `aufx` for effects /// - `subtype: ABCD` — 4-char identifier you choose /// - `manufacturer: WXYZ` — 4-char identifier you choose /// - `name: ___FILEBASENAMEASIDENTIFIER___` /// - `factoryFunction: $(PRODUCT_MODULE_NAME).___FILEBASENAMEASIDENTIFIER___AudioUnit` /// - `version: 1` /// 3. Set the extension's `NSExtensionPrincipalClass` to an /// `AUViewController` that returns this AU from `createAudioUnit(with:)`. /// 4. After build, validate with: /// auval -v aumu ABCD WXYZ /// /// See `Demos/LyrebirdAUv3Demo/LyrebirdFMExtension/` for a complete working /// example with Info.plist, AUViewController, and a SwiftUI host app. public final class ___FILEBASENAMEASIDENTIFIER___AudioUnit: LyrebirdAudioUnit { public override class func makeSynthesizer() -> SynthesizerBase { ___FILEBASENAMEASIDENTIFIER___() } public override class func parameterMetadata() -> [String: LyrebirdAUParameterInfo] { [ "frequency": .init(min: 20, max: 8000, unit: .hertz, displayName: "Frequency"), "amplitude": .init(min: 0, max: 1, unit: .linearGain, displayName: "Amplitude"), ] } }