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,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() } }
|
||||
}
|
||||
Reference in New Issue
Block a user