iOS: TrollStore AUv3 spike (host app + sine AUv3 + App Group self-test)
Separate tree under ios/ with its own Makefile: XcodeGen project, unsigned device build ad-hoc signed with entitlements and packed as an .ipa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0c09c3a0f3
commit
77d6e459b2
@@ -0,0 +1,4 @@
|
||||
build/
|
||||
dist/
|
||||
# generated from spike/project.yml by `make project`
|
||||
*.xcodeproj/
|
||||
@@ -0,0 +1,69 @@
|
||||
# Sizzle for iOS/iPadOS — build entrypoint (separate from the Android Makefile).
|
||||
#
|
||||
# For now this tree holds only the TrollStore AUv3 spike (spike/): a host app plus
|
||||
# one sine-wave AUv3 instrument and an App Group, built to answer "do hosts see
|
||||
# AUv3 plugins from a TrollStore-installed app?" before any real porting.
|
||||
#
|
||||
# make help what each target does
|
||||
# make project generate spike/SizzleSpike.xcodeproj from spike/project.yml
|
||||
# make sim build the spike for the iOS Simulator
|
||||
# make sim-run install + launch it on a booted simulator (self-test runs at launch)
|
||||
# make ipa unsigned device build, ad-hoc signed with entitlements, packed as
|
||||
# dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa for TrollStore
|
||||
# make clean remove build/ and dist/
|
||||
#
|
||||
# Needs Xcode and XcodeGen (brew install xcodegen). Builds stay local (CLAUDE.md).
|
||||
|
||||
SHELL := /bin/sh
|
||||
SPIKE := spike
|
||||
PROJECT := $(SPIKE)/SizzleSpike.xcodeproj
|
||||
SCHEME := SizzleSpike
|
||||
APP_ID := cc.tiredsysadmin.ios.sizzlespike
|
||||
BUILD_NO := $(shell sed -n 's/^ *CURRENT_PROJECT_VERSION: *"\(.*\)"/\1/p' $(SPIKE)/project.yml)
|
||||
SOURCES := $(SPIKE)/project.yml $(wildcard $(SPIKE)/*/*.swift $(SPIKE)/*/*.plist $(SPIKE)/*/*.entitlements)
|
||||
|
||||
SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app
|
||||
DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app
|
||||
IPA := dist/$(APP_ID)_$(BUILD_NO).ipa
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
help:
|
||||
@sed -n 's/^# //p' Makefile
|
||||
|
||||
project: $(PROJECT)/project.pbxproj
|
||||
$(PROJECT)/project.pbxproj: $(SPIKE)/project.yml
|
||||
cd $(SPIKE) && xcodegen generate --spec project.yml --quiet
|
||||
|
||||
# Simulator: Xcode's "sign to run locally" (-) embeds the entitlements, so the
|
||||
# App Group works there too.
|
||||
sim: $(SIM_APP)
|
||||
$(SIM_APP): $(PROJECT)/project.pbxproj $(SOURCES)
|
||||
xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Debug \
|
||||
-sdk iphonesimulator -derivedDataPath build/sim \
|
||||
CODE_SIGN_IDENTITY=- CODE_SIGN_STYLE=Manual build
|
||||
|
||||
sim-run: $(SIM_APP)
|
||||
xcrun simctl install booted $(SIM_APP)
|
||||
xcrun simctl launch booted $(APP_ID)
|
||||
|
||||
# Device: build without signing, then ad-hoc sign inside-out (extension first)
|
||||
# with each target's entitlements. TrollStore re-signs at install time but keeps
|
||||
# the entitlements it finds, which is how the App Group survives.
|
||||
ipa: $(IPA)
|
||||
$(IPA): $(PROJECT)/project.pbxproj $(SOURCES)
|
||||
xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Release \
|
||||
-sdk iphoneos -derivedDataPath build/dev CODE_SIGNING_ALLOWED=NO build
|
||||
rm -rf build/Payload && mkdir -p build/Payload dist
|
||||
cp -R $(DEV_APP) build/Payload/
|
||||
codesign -f -s - --entitlements $(SPIKE)/AU/AU.entitlements \
|
||||
build/Payload/$(SCHEME).app/PlugIns/SizzleSpikeAU.appex
|
||||
codesign -f -s - --entitlements $(SPIKE)/App/App.entitlements \
|
||||
build/Payload/$(SCHEME).app
|
||||
rm -f $@ && cd build && zip -qr ../$@ Payload
|
||||
@echo "wrote $@"
|
||||
|
||||
clean:
|
||||
rm -rf build dist
|
||||
|
||||
.PHONY: help project sim sim-run ipa clean
|
||||
@@ -0,0 +1,81 @@
|
||||
# Sizzle for iOS/iPadOS — staging tree
|
||||
|
||||
This tree is separate from the Android app (its own Makefile, nothing shared yet).
|
||||
The plan is to ship every Sizzle instrument and effect as AUv3 plugins inside one
|
||||
app (iOS/iPadOS 15+), installed with TrollStore. Before porting anything, the
|
||||
**spike** in `spike/` answers the one question that could sink the plan: do hosts
|
||||
(AUM, GarageBand, Loopy…) list AUv3 plugins from a TrollStore-installed app, and do
|
||||
App Groups work there?
|
||||
|
||||
## The spike
|
||||
|
||||
| Piece | What it is |
|
||||
|---|---|
|
||||
| `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) |
|
||||
| `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike`; runs a self-test at launch |
|
||||
| `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter |
|
||||
| `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run |
|
||||
|
||||
The self-test shows three checks:
|
||||
|
||||
1. **[1] Registered components:** what `AVAudioUnitComponentManager` lists for
|
||||
`Tsys/sSpk`. That is the same registry hosts read, so a FAIL here means no host
|
||||
will see the plugin.
|
||||
2. **[2] Instantiated out of process / Rendered 1 s offline:** iOS launches the
|
||||
extension and its render block produces sound (silent, offline render; peak > 0.05).
|
||||
"Play tone (1 s)" does the same through the speaker.
|
||||
3. **[3] App Group:** the app writes `app.txt`, the extension writes `au.txt` when it is
|
||||
created (and `au-view.txt` when a host opens its view), and each side lists what's
|
||||
there. After [2], seeing `au.txt` in the app's list proves both sides share files,
|
||||
which is how the real port will hand samples and SF2 files to the plugins.
|
||||
|
||||
### Build
|
||||
|
||||
```sh
|
||||
make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_1.ipa
|
||||
```
|
||||
|
||||
Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out
|
||||
(extension first) with each target's entitlements, and zipped as `Payload/`.
|
||||
TrollStore re-signs at install time and keeps the entitlements it finds; ldid
|
||||
isn't needed. Checked on the Mac: arm64, minimum OS 15.0 for the app and the
|
||||
extension, App Group entitlement on both, extension entry point `NSExtensionMain`,
|
||||
extension point `com.apple.AudioUnit-UI`.
|
||||
|
||||
`make sim` / `make sim-run` build and run it in the Simulator, but no Simulator
|
||||
runtime was installed when the spike was written, so it hasn't been run there.
|
||||
|
||||
### Test on the iPad
|
||||
|
||||
1. AirDrop or copy `cc.tiredsysadmin.ios.sizzlespike_1.ipa` to the iPad, open it with
|
||||
TrollStore, install.
|
||||
2. Open **Sizzle Spike** and note [1]–[3] (screenshot the screen).
|
||||
3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look
|
||||
for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it
|
||||
lists the App Group files).
|
||||
4. Back in Sizzle Spike, **Run self-test** again: `au-view.txt` should now be listed.
|
||||
|
||||
What the outcomes mean:
|
||||
|
||||
- [1] PASS and the host lists it: the plan works as designed.
|
||||
- [1] PASS but no host lists it: hosts filter TrollStore apps somehow; investigate
|
||||
before porting.
|
||||
- [1] FAIL: iOS didn't register the extension (pluginkit); try re-launching the app,
|
||||
then a respring, then reinstall.
|
||||
- [3] NOT AVAILABLE: App Groups don't survive TrollStore signing. The fallback is
|
||||
passing sample data through the plugin's saved state, or having the plugin
|
||||
pick files with a document picker.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and
|
||||
review; the generated project is git-ignored.
|
||||
- **Swift render block in the spike:** good enough for one sine voice (no allocation
|
||||
or locks in the render block). The real port puts the DSP in a C++ core (see the
|
||||
conversation that planned it: Kotlin DSP → C++ verified against reference audio
|
||||
rendered by the Kotlin code).
|
||||
- **One extension, factory dispatch:** the real port will list many
|
||||
`AudioComponents` in one or a few extensions and pick the unit in
|
||||
`createAudioUnit(with:)` by subtype, instead of one extension per device.
|
||||
- **Versions:** the spike's version lives in `spike/project.yml`
|
||||
(`MARKETING_VERSION` 0.1.0, `CURRENT_PROJECT_VERSION` 1, which names the .ipa).
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.cc.tiredsysadmin.ios.sizzlespike</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,34 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import CoreAudioKit
|
||||
import UIKit
|
||||
|
||||
/// The extension's principal class: the AU factory and its (minimal) view.
|
||||
public final class AudioUnitViewController: AUViewController, AUAudioUnitFactory {
|
||||
private var audioUnit: AUAudioUnit?
|
||||
|
||||
public func createAudioUnit(with componentDescription: AudioComponentDescription) throws -> AUAudioUnit {
|
||||
let au = try SpikeAudioUnit(componentDescription: componentDescription, options: [])
|
||||
audioUnit = au
|
||||
return au
|
||||
}
|
||||
|
||||
public override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
preferredContentSize = CGSize(width: 400, height: 220)
|
||||
view.backgroundColor = UIColor(red: 0.08, green: 0.09, blue: 0.10, alpha: 1)
|
||||
let label = UILabel()
|
||||
label.numberOfLines = 0
|
||||
label.font = .monospacedSystemFont(ofSize: 12, weight: .regular)
|
||||
label.textColor = UIColor(red: 0.96, green: 0.76, blue: 0.29, alpha: 1)
|
||||
label.text = "Sizzle Spike Sine (AUv3)\nPlay notes from the host.\n\n" + Spike.probeGroup(as: "au-view")
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(label)
|
||||
NSLayoutConstraint.activate([
|
||||
label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 12),
|
||||
label.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -12),
|
||||
label.topAnchor.constraint(equalTo: view.topAnchor, constant: 12),
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Sizzle Spike AU</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>AudioComponents</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>description</key>
|
||||
<string>Sizzle Spike Sine</string>
|
||||
<key>factoryFunction</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).AudioUnitViewController</string>
|
||||
<key>manufacturer</key>
|
||||
<string>Tsys</string>
|
||||
<key>name</key>
|
||||
<string>Tired Sysadmin: Sizzle Spike Sine</string>
|
||||
<key>sandboxSafe</key>
|
||||
<true/>
|
||||
<key>subtype</key>
|
||||
<string>sSpk</string>
|
||||
<key>tags</key>
|
||||
<array>
|
||||
<string>Synthesizer</string>
|
||||
</array>
|
||||
<key>type</key>
|
||||
<string>aumu</string>
|
||||
<key>version</key>
|
||||
<integer>65536</integer>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.AudioUnit-UI</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).AudioUnitViewController</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,96 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import AudioToolbox
|
||||
import AVFoundation
|
||||
import Foundation
|
||||
|
||||
/// State the render block touches. Allocated before rendering starts; the render
|
||||
/// block only reads and writes these fields (no allocation, no locks).
|
||||
final class SineKernel {
|
||||
var sampleRate: Double = 44_100
|
||||
var phase: Double = 0
|
||||
var freq: Double = 440
|
||||
var env: Float = 0
|
||||
var gate = false
|
||||
var gain: Float = 0.3
|
||||
/// Our own output memory for hosts that pass buffers with nil mData.
|
||||
var scratch = UnsafeMutablePointer<Float>.allocate(capacity: 2 * 4096)
|
||||
deinit { scratch.deallocate() }
|
||||
}
|
||||
|
||||
/// The spike's instrument: one sine voice, MIDI note on/off, one Gain parameter.
|
||||
public final class SpikeAudioUnit: AUAudioUnit {
|
||||
private let kernel = SineKernel()
|
||||
private var outBus: AUAudioUnitBus!
|
||||
private var busses: AUAudioUnitBusArray!
|
||||
private var tree: AUParameterTree!
|
||||
|
||||
public override init(componentDescription: AudioComponentDescription,
|
||||
options: AudioComponentInstantiationOptions = []) throws {
|
||||
try super.init(componentDescription: componentDescription, options: options)
|
||||
let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)!
|
||||
outBus = try AUAudioUnitBus(format: format)
|
||||
outBus.maximumChannelCount = 2
|
||||
busses = AUAudioUnitBusArray(audioUnit: self, busType: .output, busses: [outBus])
|
||||
|
||||
let gain = AUParameterTree.createParameter(
|
||||
withIdentifier: "gain", name: "Gain", address: 0, min: 0, max: 1,
|
||||
unit: .linearGain, unitName: nil, flags: [.flag_IsReadable, .flag_IsWritable],
|
||||
valueStrings: nil, dependentParameters: nil)
|
||||
tree = AUParameterTree.createTree(withChildren: [gain])
|
||||
let k = kernel
|
||||
tree.implementorValueObserver = { p, v in if p.address == 0 { k.gain = v } }
|
||||
tree.implementorValueProvider = { p in p.address == 0 ? k.gain : 0 }
|
||||
maximumFramesToRender = 4096
|
||||
|
||||
// Prove the extension side can write the App Group too.
|
||||
_ = Spike.probeGroup(as: "au")
|
||||
}
|
||||
|
||||
public override var outputBusses: AUAudioUnitBusArray { busses }
|
||||
public override var parameterTree: AUParameterTree? { get { tree } set { } }
|
||||
|
||||
public override func allocateRenderResources() throws {
|
||||
try super.allocateRenderResources()
|
||||
kernel.sampleRate = outBus.format.sampleRate
|
||||
if maximumFramesToRender > 4096 {
|
||||
kernel.scratch.deallocate()
|
||||
kernel.scratch = .allocate(capacity: 2 * Int(maximumFramesToRender))
|
||||
}
|
||||
}
|
||||
|
||||
public override var internalRenderBlock: AUInternalRenderBlock {
|
||||
let k = kernel
|
||||
return { _, _, frameCount, _, outputData, eventList, _ in
|
||||
// MIDI (applied at the start of the block; good enough for a spike)
|
||||
var ev = eventList
|
||||
while let e = ev {
|
||||
if e.pointee.head.eventType == .MIDI {
|
||||
let m = e.pointee.MIDI
|
||||
let status = m.data.0 & 0xF0, note = m.data.1, vel = m.data.2
|
||||
if status == 0x90 && vel > 0 {
|
||||
k.freq = 440 * pow(2, (Double(note) - 69) / 12); k.gate = true
|
||||
} else if status == 0x80 || status == 0x90 {
|
||||
k.gate = false
|
||||
}
|
||||
}
|
||||
ev = UnsafePointer(e.pointee.head.next)
|
||||
}
|
||||
let abl = UnsafeMutableAudioBufferListPointer(outputData)
|
||||
for j in 0..<abl.count where abl[j].mData == nil {
|
||||
abl[j].mData = UnsafeMutableRawPointer(k.scratch + j * Int(frameCount))
|
||||
abl[j].mDataByteSize = frameCount * 4
|
||||
}
|
||||
let inc = 2 * Double.pi * k.freq / k.sampleRate
|
||||
for i in 0..<Int(frameCount) {
|
||||
k.env += ((k.gate ? 1 : 0) - k.env) * 0.002
|
||||
let s = Float(sin(k.phase)) * k.env * k.gain
|
||||
k.phase += inc
|
||||
if k.phase > 2 * Double.pi { k.phase -= 2 * Double.pi }
|
||||
for j in 0..<abl.count { abl[j].mData!.assumingMemoryBound(to: Float.self)[i] = s }
|
||||
}
|
||||
return noErr
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.cc.tiredsysadmin.ios.sizzlespike</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,30 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@StateObject private var test = SelfTest()
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Sizzle AUv3 spike").font(.system(.title2, design: .monospaced)).foregroundColor(.orange)
|
||||
Text("In AUM / GarageBand / Loopy look for\n\"Tired Sysadmin: Sizzle Spike Sine\" (instrument).")
|
||||
.font(.system(.footnote, design: .monospaced)).foregroundColor(.gray)
|
||||
HStack {
|
||||
Button("Run self-test") { Task { await test.run() } }
|
||||
Button("Play tone (1 s)") { Task { await test.playTone() } }
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
ScrollView {
|
||||
Text(test.lines.joined(separator: "\n"))
|
||||
.font(.system(.footnote, design: .monospaced))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.preferredColorScheme(.dark)
|
||||
.task { await test.run() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import AVFoundation
|
||||
import os
|
||||
|
||||
/// Answers the spike's questions on the device itself:
|
||||
/// 1. did iOS register the extension's Audio Unit (what hosts will list)?
|
||||
/// 2. does it load out of process and render sound?
|
||||
/// 3. can the app and the extension share files through the App Group?
|
||||
@MainActor
|
||||
final class SelfTest: ObservableObject {
|
||||
@Published var lines: [String] = []
|
||||
private let log = Logger(subsystem: "cc.tiredsysadmin.ios.sizzlespike", category: "selftest")
|
||||
private var liveEngine: AVAudioEngine?
|
||||
|
||||
private func say(_ s: String) {
|
||||
lines.append(s)
|
||||
log.notice("\(s, privacy: .public)")
|
||||
}
|
||||
|
||||
func run() async {
|
||||
lines = []
|
||||
let os = ProcessInfo.processInfo.operatingSystemVersionString
|
||||
say("iOS \(os)")
|
||||
|
||||
// 1. Registration
|
||||
let all = AVAudioUnitComponentManager.shared().components(matching: Spike.desc)
|
||||
say("[1] Registered components matching Tsys/sSpk: \(all.count) \(all.isEmpty ? "FAIL" : "PASS")")
|
||||
for c in all { say(" \(c.name) v\(c.versionString), type \(c.typeName)") }
|
||||
|
||||
// 3a. App Group from the app side (before the AU writes)
|
||||
say("[3] " + Spike.probeGroup(as: "app"))
|
||||
|
||||
// 2. Load out of process, render 1 s offline (silent), measure the peak
|
||||
do {
|
||||
let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess)
|
||||
say("[2] Instantiated \"\(unit.auAudioUnit.audioUnitName ?? "?")\" out of process: PASS")
|
||||
let engine = AVAudioEngine()
|
||||
let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)!
|
||||
try engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096)
|
||||
engine.attach(unit)
|
||||
engine.connect(unit, to: engine.mainMixerNode, format: format)
|
||||
try engine.start()
|
||||
(unit as? AVAudioUnitMIDIInstrument)?.startNote(69, withVelocity: 100, onChannel: 0)
|
||||
let buf = AVAudioPCMBuffer(pcmFormat: engine.manualRenderingFormat, frameCapacity: 4096)!
|
||||
var peak: Float = 0
|
||||
for _ in 0..<11 {
|
||||
_ = try engine.renderOffline(4096, to: buf)
|
||||
let ch = buf.floatChannelData![0]
|
||||
for i in 0..<Int(buf.frameLength) { peak = max(peak, abs(ch[i])) }
|
||||
}
|
||||
engine.stop()
|
||||
say(String(format: "[2] Rendered 1 s offline, peak %.3f: %@", peak, peak > 0.05 ? "PASS" : "FAIL"))
|
||||
} catch {
|
||||
say("[2] FAIL: \(error.localizedDescription) (\((error as NSError).code))")
|
||||
}
|
||||
|
||||
// 3b. The AU wrote au.txt when it was created; read it back from the app side
|
||||
say("[3] after AU load: " + Spike.probeGroup(as: "app"))
|
||||
}
|
||||
|
||||
/// Audible check through the speaker, using the same out-of-process AU.
|
||||
func playTone() async {
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback)
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess)
|
||||
let engine = AVAudioEngine()
|
||||
engine.attach(unit)
|
||||
engine.connect(unit, to: engine.mainMixerNode, format: nil)
|
||||
try engine.start()
|
||||
liveEngine = engine
|
||||
let inst = unit as? AVAudioUnitMIDIInstrument
|
||||
inst?.startNote(69, withVelocity: 100, onChannel: 0)
|
||||
try await Task.sleep(nanoseconds: 1_000_000_000)
|
||||
inst?.stopNote(69, onChannel: 0)
|
||||
try await Task.sleep(nanoseconds: 300_000_000)
|
||||
engine.stop()
|
||||
liveEngine = nil
|
||||
say("Played A4 for 1 s")
|
||||
} catch {
|
||||
say("Play FAIL: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SpikeApp: App {
|
||||
var body: some Scene { WindowGroup { ContentView() } }
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import AudioToolbox
|
||||
import Foundation
|
||||
|
||||
/// What the app and the extension agree on: the App Group and the AU's identity.
|
||||
enum Spike {
|
||||
static let group = "group.cc.tiredsysadmin.ios.sizzlespike"
|
||||
|
||||
/// 'aumu' / 'sSpk' / 'Tsys' — must match AU/Info.plist.
|
||||
static let desc = AudioComponentDescription(
|
||||
componentType: kAudioUnitType_MusicDevice,
|
||||
componentSubType: fourCC("sSpk"),
|
||||
componentManufacturer: fourCC("Tsys"),
|
||||
componentFlags: 0, componentFlagsMask: 0)
|
||||
|
||||
static func fourCC(_ s: String) -> FourCharCode {
|
||||
s.utf8.reduce(0) { ($0 << 8) | FourCharCode($1) }
|
||||
}
|
||||
|
||||
/// Writes `<who>.txt` into the App Group container and reports every file in it,
|
||||
/// so each side shows what the other one wrote.
|
||||
static func probeGroup(as who: String) -> String {
|
||||
guard let dir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group) else {
|
||||
return "App Group \(group): NOT AVAILABLE (entitlement missing or not honoured)"
|
||||
}
|
||||
let stamp = ISO8601DateFormatter().string(from: Date())
|
||||
let wrote = (try? "\(who) was here at \(stamp)\n".write(to: dir.appendingPathComponent("\(who).txt"),
|
||||
atomically: true, encoding: .utf8)) != nil
|
||||
var out = "App Group OK, \(who) write \(wrote ? "OK" : "FAILED")"
|
||||
let files = (try? FileManager.default.contentsOfDirectory(atPath: dir.path).sorted()) ?? []
|
||||
for f in files where f.hasSuffix(".txt") {
|
||||
let text = (try? String(contentsOf: dir.appendingPathComponent(f), encoding: .utf8)) ?? "?"
|
||||
out += "\n \(f): \(text.trimmingCharacters(in: .whitespacesAndNewlines))"
|
||||
}
|
||||
return out
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
# XcodeGen spec for the TrollStore AUv3 spike (see ios/README.md).
|
||||
# `make -C ios project` turns this into SizzleSpike.xcodeproj; never edit the
|
||||
# generated project by hand.
|
||||
name: SizzleSpike
|
||||
options:
|
||||
bundleIdPrefix: cc.tiredsysadmin.ios
|
||||
deploymentTarget:
|
||||
iOS: "15.0"
|
||||
settings:
|
||||
base:
|
||||
MARKETING_VERSION: "0.1.0"
|
||||
CURRENT_PROJECT_VERSION: "1"
|
||||
SWIFT_VERSION: "5.0"
|
||||
TARGETED_DEVICE_FAMILY: "1,2"
|
||||
ARCHS: arm64
|
||||
DEVELOPMENT_TEAM: ""
|
||||
targets:
|
||||
SizzleSpike:
|
||||
type: application
|
||||
platform: iOS
|
||||
sources: [App, Shared]
|
||||
dependencies:
|
||||
- target: SizzleSpikeAU
|
||||
embed: true
|
||||
codeSign: false
|
||||
settings:
|
||||
base:
|
||||
PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzlespike
|
||||
CODE_SIGN_ENTITLEMENTS: App/App.entitlements
|
||||
GENERATE_INFOPLIST_FILE: YES
|
||||
INFOPLIST_KEY_CFBundleDisplayName: Sizzle Spike
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation: YES
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
|
||||
INFOPLIST_KEY_UIBackgroundModes: audio
|
||||
SizzleSpikeAU:
|
||||
type: app-extension
|
||||
platform: iOS
|
||||
sources: [AU, Shared]
|
||||
settings:
|
||||
base:
|
||||
PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzlespike.au
|
||||
CODE_SIGN_ENTITLEMENTS: AU/AU.entitlements
|
||||
INFOPLIST_FILE: AU/Info.plist
|
||||
Reference in New Issue
Block a user