// LyrebirdFMAudioUnitViewController.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import CoreAudioKit import AVFoundation /// AUv3 view controller + factory. /// /// `AUAudioUnitFactory` conformance is how AUv3 hosts instantiate the /// underlying `AUAudioUnit` — the host loads this view controller as the /// extension's `NSExtensionPrincipalClass`, calls /// `createAudioUnit(with:)`, and the resulting AU is what handles render. /// /// Ships an empty placeholder view. Drop in `LyrebirdSynthView` (from /// `LyrebirdUI`) to get a Mirror-driven SwiftUI parameter grid. public final class LyrebirdFMAudioUnitViewController: AUViewController, AUAudioUnitFactory { /// Strong reference to the AU once `createAudioUnit(with:)` builds it. /// The host keeps a separate reference; this is held so a SwiftUI view /// added on top can read parameters from the same instance. public private(set) var audioUnit: AUAudioUnit? public override func viewDidLoad() { super.viewDidLoad() // Empty stub — install a SwiftUI host (e.g. `LyrebirdSynthView`) here. } public func createAudioUnit( with componentDescription: AudioComponentDescription ) throws -> AUAudioUnit { let au = try LyrebirdFMAudioUnit(componentDescription: componentDescription) audioUnit = au return au } }