// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later // The extension's principal class: the factory for every device listed in // components.txt (picked by subtype; instruments and effects), and its editor: // the SwiftUI card editor (Editor/DeviceEditor.swift), as in the Android app. // The app hosts the same editor for the devices it plays itself. #import #import #import "SizzleFXViewController.h" // The Swift side's generated header: named after the target that compiles this file. #if __has_include("SizzleFX-Swift.h") #import "SizzleFX-Swift.h" #else #import "Sizzle-Swift.h" #endif @implementation SizzleFXViewController { SizzleDeviceAU *_au; BOOL _built; } - (AUAudioUnit *)createAudioUnitWithComponentDescription:(AudioComponentDescription)desc error:(NSError **)error { _au = [[[SizzleDeviceAU classForComponentType:desc.componentType] alloc] initWithComponentDescription:desc options:0 error:error]; if (_au) dispatch_async(dispatch_get_main_queue(), ^{ [self buildIfReady]; }); return _au; } - (void)attachAudioUnit:(SizzleDeviceAU *)au { _au = au; [self buildIfReady]; } - (void)viewDidLoad { [super viewDidLoad]; self.preferredContentSize = CGSizeMake(560, 460); self.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.08 blue:0.09 alpha:1]; [self buildIfReady]; } - (void)buildIfReady { if (_built || !_au || !self.isViewLoaded) return; _built = YES; UIViewController *editor = [SizzleEditorFactory makeEditorFor:_au]; [self addChildViewController:editor]; editor.view.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:editor.view]; UILayoutGuide *g = self.view.safeAreaLayoutGuide; [NSLayoutConstraint activateConstraints:@[ [editor.view.leadingAnchor constraintEqualToAnchor:g.leadingAnchor], [editor.view.trailingAnchor constraintEqualToAnchor:g.trailingAnchor], [editor.view.topAnchor constraintEqualToAnchor:g.topAnchor], [editor.view.bottomAnchor constraintEqualToAnchor:g.bottomAnchor], ]]; [editor didMoveToParentViewController:self]; } @end