iOS 0.5.0: hand-built editors (Tape Delay, Tape Engine, Mix Tightener, Granular scope, Wavetable tables, Grain Cloud source)

Effect visualisation through the C++ effect, engine and AU; custom wavetables and
grain sources load and persist with the song; the app's slot editor hosts the
file picker for bespoke views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 10:01:14 +01:00
co-authored by Claude Opus 5.5
parent 3b035d6a7d
commit 435305e42a
34 changed files with 1514 additions and 38 deletions
+1
View File
@@ -1,4 +1,5 @@
#import "SizzleDeviceAU.h"
#import "SizzleDeviceAU+Sources.h"
#import "SizzleSession.h"
#import "SnapshotComponents.h"
#import "SizzleSession+Tracker.h"
+1
View File
@@ -1,2 +1,3 @@
#import "SizzleDeviceAU.h"
#import "SizzleDeviceAU+Sources.h"
#import "SnapshotComponents.h"
+34 -3
View File
@@ -15,7 +15,9 @@
// 4. zero-copy input: calling the render block directly with an upstream that
// points the input buffers at its own memory instead of filling ours. Real
// hosts do that out of process; AVAudioEngine in-process copies, which is why
// 0.1.0 passed here and was silent on the iPad.
// 0.1.0 passed here and was silent on the iPad;
// 6. effect scope (the Granular's VizEffect): -1 before audio, then once audio
// has passed through, the same scope and playhead as the core effect.
#import <AVFoundation/AVFoundation.h>
#include <cmath>
@@ -24,6 +26,7 @@
#include <vector>
#import "Components.gen.h"
#import "SizzleDeviceAU.h"
#import "SizzleEffectAU.h"
#import "SizzleInstrumentAU.h"
#include "sizzle/Instrument.hpp"
#include "sampler/SampleStore.hpp"
@@ -100,7 +103,8 @@ static std::vector<float> renderCore(const char *type, const Params &p, const st
/// Render [in] through the AU's render block at 44.1 kHz in 512-frame blocks. The
/// upstream hands over its own buffers (mData replaced, ours untouched); with
/// [inPlace] the output buffers are null too, as hosts may pass them.
static void renderZeroCopy(AUAudioUnit *au, const std::vector<float> &in, bool inPlace, std::vector<float> &L, std::vector<float> &R) {
static void renderZeroCopy(AUAudioUnit *au, const std::vector<float> &in, bool inPlace, std::vector<float> &L, std::vector<float> &R,
bool deallocate = true) {
au.maximumFramesToRender = 4096;
NSError *err = nil;
if (![au allocateRenderResourcesAndReturnError:&err]) { std::printf("allocate: %s\n", err.localizedDescription.UTF8String); return; }
@@ -137,7 +141,7 @@ static void renderZeroCopy(AUAudioUnit *au, const std::vector<float> &in, bool i
L.insert(L.end(), l, l + n);
R.insert(R.end(), r, r + n);
}
[au deallocateRenderResources];
if (deallocate) [au deallocateRenderResources];
}
static double maxDiff(const std::vector<float> &a, const std::vector<float> &b) {
@@ -310,6 +314,33 @@ int main(int argc, char **argv) {
inPlace ? ", in-place output" : "", zl, zr);
check(zl < 1e-6 && zr < 1e-6, msg, sc.name);
}
// 6. effect scope: none before audio; after it, the core effect's own
{
SizzleEffectAU *fau = (SizzleEffectAU *)instantiate(d).AUAudioUnit;
float scope[128], want[128];
check([fau copyEffectScope:scope capacity:128] == -1 && fau.effectPlayhead == -1.f,
"scope: none before render resources", sc.name);
Params dp; dp.fill(*spec);
std::vector<float> zin(in.begin(), in.begin() + 44032), zL, zR;
renderZeroCopy(fau, zin, false, zL, zR, false);
auto fx = Effect::create(sc.toolboxType, 44100);
fx->update(dp, 120.f);
for (float x : zin) fx->process(x);
NSInteger n = [fau copyEffectScope:scope capacity:128];
int wn = fx->copyScope(want, 128);
if (fx->hasScope()) {
bool same = n == wn && n > 0 && !memcmp(scope, want, (size_t)n * 4) && fau.effectPlayhead == fx->playhead();
float peak = 0; for (NSInteger i = 0; i < n; ++i) peak = std::max(peak, std::fabs(scope[i]));
snprintf(msg, sizeof msg, "scope after audio: %ld samples (peak %.2f), playhead %.3f, == core",
(long)n, peak, fau.effectPlayhead);
check(same && peak > 0.f && fau.effectPlayhead >= 0.f && fau.effectPlayhead <= 1.f, msg, sc.name);
} else {
check(n == -1 && fau.effectPlayhead == -1.f, "scope: none (not a scope effect)", sc.name);
}
[fau deallocateRenderResources];
check([fau copyEffectScope:scope capacity:128] == -1, "scope: none after deallocation", sc.name);
}
}
std::printf("\n%s (%d failures)\n", failures ? "FAILED" : "all passed", failures);
}