C++ ports of the Kotlin effects, checked against audio the Kotlin code renders (25 scenarios, IosGoldenExport); an Objective-C++ AUv3 wrapper checked on the Mac against the core (parameters, presets, saved state); a container app that checks each plugin on the device. Built as a TrollStore .ipa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
202 lines
9.0 KiB
Plaintext
202 lines
9.0 KiB
Plaintext
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// The FX extension's principal class: the factory for every effect listed in
|
|
// components.txt (picked by subtype) and a generic editor for its parameters
|
|
// (sliders, segmented switches for short choice lists, menus for long ones).
|
|
// The card-style editors of the Android app come later; this keeps every
|
|
// parameter reachable meanwhile.
|
|
|
|
#import <CoreAudioKit/CoreAudioKit.h>
|
|
#import <UIKit/UIKit.h>
|
|
#import "Components.gen.h"
|
|
#import "SizzleEffectAU.h"
|
|
|
|
@interface SizzleFXViewController : AUViewController <AUAudioUnitFactory>
|
|
@end
|
|
|
|
static UIColor *Amber(void) { return [UIColor colorWithRed:0.96 green:0.76 blue:0.29 alpha:1]; }
|
|
static UIColor *Dim(void) { return [UIColor colorWithWhite:0.62 alpha:1]; }
|
|
|
|
@implementation SizzleFXViewController {
|
|
SizzleEffectAU *_au;
|
|
UIStackView *_stack;
|
|
NSMutableDictionary<NSNumber *, UIControl *> *_controls;
|
|
NSMutableDictionary<NSNumber *, UILabel *> *_valueLabels;
|
|
AUParameterObserverToken _token;
|
|
BOOL _built;
|
|
}
|
|
|
|
#pragma mark - factory
|
|
|
|
- (AUAudioUnit *)createAudioUnitWithComponentDescription:(AudioComponentDescription)desc error:(NSError **)error {
|
|
for (int i = 0; i < kSizzleComponentCount; ++i) {
|
|
if (kSizzleComponents[i].subtype == desc.componentSubType) {
|
|
_au = [[SizzleEffectAU alloc] initWithComponentDescription:desc
|
|
toolboxType:kSizzleComponents[i].toolboxType
|
|
displayName:@(kSizzleComponents[i].name)
|
|
error:error];
|
|
dispatch_async(dispatch_get_main_queue(), ^{ [self buildIfReady]; });
|
|
return _au;
|
|
}
|
|
}
|
|
if (error) *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_InvalidElement userInfo:nil];
|
|
return nil;
|
|
}
|
|
|
|
#pragma mark - view
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.preferredContentSize = CGSizeMake(520, 420);
|
|
self.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.08 blue:0.09 alpha:1];
|
|
UIScrollView *scroll = [UIScrollView new];
|
|
scroll.translatesAutoresizingMaskIntoConstraints = NO;
|
|
[self.view addSubview:scroll];
|
|
_stack = [UIStackView new];
|
|
_stack.axis = UILayoutConstraintAxisVertical;
|
|
_stack.spacing = 10;
|
|
_stack.translatesAutoresizingMaskIntoConstraints = NO;
|
|
[scroll addSubview:_stack];
|
|
UILayoutGuide *g = self.view.safeAreaLayoutGuide;
|
|
[NSLayoutConstraint activateConstraints:@[
|
|
[scroll.leadingAnchor constraintEqualToAnchor:g.leadingAnchor],
|
|
[scroll.trailingAnchor constraintEqualToAnchor:g.trailingAnchor],
|
|
[scroll.topAnchor constraintEqualToAnchor:g.topAnchor],
|
|
[scroll.bottomAnchor constraintEqualToAnchor:g.bottomAnchor],
|
|
[_stack.leadingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.leadingAnchor constant:14],
|
|
[_stack.trailingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.trailingAnchor constant:-14],
|
|
[_stack.topAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.topAnchor constant:12],
|
|
[_stack.bottomAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.bottomAnchor constant:-12],
|
|
[_stack.widthAnchor constraintEqualToAnchor:scroll.frameLayoutGuide.widthAnchor constant:-28],
|
|
]];
|
|
[self buildIfReady];
|
|
}
|
|
|
|
- (UILabel *)label:(NSString *)text size:(CGFloat)size color:(UIColor *)color {
|
|
UILabel *l = [UILabel new];
|
|
l.text = text;
|
|
l.font = [UIFont monospacedSystemFontOfSize:size weight:UIFontWeightRegular];
|
|
l.textColor = color;
|
|
return l;
|
|
}
|
|
|
|
- (void)buildIfReady {
|
|
if (_built || !_au || !_stack) return;
|
|
_built = YES;
|
|
_controls = [NSMutableDictionary dictionary];
|
|
_valueLabels = [NSMutableDictionary dictionary];
|
|
|
|
[_stack addArrangedSubview:[self label:_au.displayName.uppercaseString size:15 color:Amber()]];
|
|
|
|
if (_au.factoryPresets.count > 0) {
|
|
UIButton *presets = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
[presets setTitle:@"PRESET ▾" forState:UIControlStateNormal];
|
|
presets.titleLabel.font = [UIFont monospacedSystemFontOfSize:13 weight:UIFontWeightRegular];
|
|
presets.tintColor = Amber();
|
|
presets.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
NSMutableArray<UIAction *> *items = [NSMutableArray array];
|
|
__weak SizzleEffectAU *au = _au;
|
|
__weak UIButton *weakButton = presets;
|
|
for (AUAudioUnitPreset *p in _au.factoryPresets) {
|
|
[items addObject:[UIAction actionWithTitle:p.name image:nil identifier:nil handler:^(UIAction *a) {
|
|
au.currentPreset = p;
|
|
[weakButton setTitle:[NSString stringWithFormat:@"PRESET: %@ ▾", p.name] forState:UIControlStateNormal];
|
|
}]];
|
|
}
|
|
presets.menu = [UIMenu menuWithChildren:items];
|
|
presets.showsMenuAsPrimaryAction = YES;
|
|
[_stack addArrangedSubview:presets];
|
|
}
|
|
|
|
for (AUParameter *p in _au.parameterTree.allParameters) [self addRowFor:p];
|
|
|
|
__weak SizzleFXViewController *weakSelf = self;
|
|
_token = [_au.parameterTree tokenByAddingParameterObserver:^(AUParameterAddress address, AUValue value) {
|
|
dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf show:address value:value]; });
|
|
}];
|
|
}
|
|
|
|
- (void)addRowFor:(AUParameter *)p {
|
|
NSNumber *addr = @(p.address);
|
|
UIStackView *head = [UIStackView new];
|
|
head.axis = UILayoutConstraintAxisHorizontal;
|
|
[head addArrangedSubview:[self label:p.displayName.uppercaseString size:11 color:Dim()]];
|
|
UILabel *value = [self label:[_au stringForParameter:p value:p.value] size:11 color:UIColor.whiteColor];
|
|
value.textAlignment = NSTextAlignmentRight;
|
|
[head addArrangedSubview:value];
|
|
_valueLabels[addr] = value;
|
|
|
|
UIControl *control;
|
|
NSArray<NSString *> *choices = p.valueStrings;
|
|
NSUInteger chars = [[choices componentsJoinedByString:@""] length];
|
|
__weak SizzleFXViewController *weakSelf = self;
|
|
if (choices.count > 0 && choices.count <= 6 && chars <= 34) {
|
|
UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:choices];
|
|
seg.selectedSegmentIndex = (NSInteger)lroundf(p.value);
|
|
seg.selectedSegmentTintColor = Amber();
|
|
[seg addAction:[UIAction actionWithHandler:^(UIAction *a) {
|
|
[weakSelf set:p value:(AUValue)seg.selectedSegmentIndex];
|
|
}] forControlEvents:UIControlEventValueChanged];
|
|
control = seg;
|
|
} else if (choices.count > 0) {
|
|
UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
b.tintColor = Amber();
|
|
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
NSMutableArray<UIAction *> *items = [NSMutableArray array];
|
|
[choices enumerateObjectsUsingBlock:^(NSString *name, NSUInteger i, BOOL *stop) {
|
|
[items addObject:[UIAction actionWithTitle:name image:nil identifier:nil handler:^(UIAction *a) {
|
|
[weakSelf set:p value:(AUValue)i];
|
|
}]];
|
|
}];
|
|
b.menu = [UIMenu menuWithChildren:items];
|
|
b.showsMenuAsPrimaryAction = YES;
|
|
[b setTitle:[NSString stringWithFormat:@"%@ ▾", choices[(NSUInteger)lroundf(p.value)]] forState:UIControlStateNormal];
|
|
control = b;
|
|
} else {
|
|
UISlider *s = [UISlider new];
|
|
s.minimumValue = p.minValue;
|
|
s.maximumValue = p.maxValue;
|
|
s.value = p.value;
|
|
s.minimumTrackTintColor = Amber();
|
|
BOOL isInt = p.unit == kAudioUnitParameterUnit_Indexed;
|
|
[s addAction:[UIAction actionWithHandler:^(UIAction *a) {
|
|
AUValue v = isInt ? roundf(s.value) : s.value;
|
|
[weakSelf set:p value:v];
|
|
}] forControlEvents:UIControlEventValueChanged];
|
|
control = s;
|
|
}
|
|
_controls[addr] = control;
|
|
|
|
UIStackView *row = [[UIStackView alloc] initWithArrangedSubviews:@[head, control]];
|
|
row.axis = UILayoutConstraintAxisVertical;
|
|
row.spacing = 4;
|
|
[_stack addArrangedSubview:row];
|
|
}
|
|
|
|
- (void)set:(AUParameter *)p value:(AUValue)v {
|
|
[p setValue:v originator:_token];
|
|
[self show:p.address value:v];
|
|
}
|
|
|
|
- (void)show:(AUParameterAddress)address value:(AUValue)value {
|
|
AUParameter *p = [_au.parameterTree parameterWithAddress:address];
|
|
if (!p) return;
|
|
_valueLabels[@(address)].text = [_au stringForParameter:p value:value];
|
|
UIControl *c = _controls[@(address)];
|
|
if ([c isKindOfClass:[UISlider class]]) {
|
|
if (!c.isTracking) ((UISlider *)c).value = value;
|
|
} else if ([c isKindOfClass:[UISegmentedControl class]]) {
|
|
((UISegmentedControl *)c).selectedSegmentIndex = (NSInteger)lroundf(value);
|
|
} else if ([c isKindOfClass:[UIButton class]] && p.valueStrings.count) {
|
|
NSUInteger i = MIN((NSUInteger)lroundf(value), p.valueStrings.count - 1);
|
|
[(UIButton *)c setTitle:[NSString stringWithFormat:@"%@ ▾", p.valueStrings[i]] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
- (void)dealloc {
|
|
if (_token && _au) [_au.parameterTree removeParameterObserver:_token];
|
|
}
|
|
|
|
@end
|