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:
co-authored by
Claude Opus 5.5
parent
3b035d6a7d
commit
435305e42a
@@ -6,6 +6,7 @@
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
|
||||
@@ -18,6 +19,9 @@ struct EffectKernel final : DeviceKernel {
|
||||
int channels = 0;
|
||||
std::atomic<bool> bypass{false};
|
||||
std::vector<float> inBuf[2];
|
||||
/// Held by the editor's scope reads and by (de)allocation, which replace fx[]:
|
||||
/// never by the render thread, so the audio path stays lock-free.
|
||||
std::mutex vizLock;
|
||||
|
||||
void apply(const Params &p, float tempoBpm) override {
|
||||
for (int c = 0; c < channels; ++c) fx[c]->update(p, tempoBpm);
|
||||
@@ -72,9 +76,12 @@ struct EffectKernel final : DeviceKernel {
|
||||
EffectKernel *k = self.fxKernel;
|
||||
int sr = (int)std::lround(_outBus.format.sampleRate);
|
||||
k->channels = (int)chOut;
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
k->fx[c] = c < k->channels ? Effect::create(k->type.c_str(), sr) : nullptr;
|
||||
k->inBuf[c].assign(self.maximumFramesToRender, 0.f);
|
||||
{
|
||||
std::lock_guard<std::mutex> g(k->vizLock);
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
k->fx[c] = c < k->channels ? Effect::create(k->type.c_str(), sr) : nullptr;
|
||||
k->inBuf[c].assign(self.maximumFramesToRender, 0.f);
|
||||
}
|
||||
}
|
||||
if (!k->fx[0]) {
|
||||
if (outError) *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_FailedInitialization userInfo:nil];
|
||||
@@ -85,10 +92,27 @@ struct EffectKernel final : DeviceKernel {
|
||||
}
|
||||
|
||||
- (void)deallocateRenderResources {
|
||||
for (auto &f : self.fxKernel->fx) f.reset();
|
||||
{
|
||||
std::lock_guard<std::mutex> g(self.fxKernel->vizLock);
|
||||
for (auto &f : self.fxKernel->fx) f.reset();
|
||||
}
|
||||
[super deallocateRenderResources];
|
||||
}
|
||||
|
||||
- (NSInteger)copyEffectScope:(float *)out capacity:(NSInteger)capacity {
|
||||
EffectKernel *k = self.fxKernel;
|
||||
std::lock_guard<std::mutex> g(k->vizLock);
|
||||
Effect *fx = k->fx[0].get();
|
||||
return fx && fx->hasScope() ? fx->copyScope(out, (int)capacity) : -1;
|
||||
}
|
||||
|
||||
- (float)effectPlayhead {
|
||||
EffectKernel *k = self.fxKernel;
|
||||
std::lock_guard<std::mutex> g(k->vizLock);
|
||||
Effect *fx = k->fx[0].get();
|
||||
return fx && fx->hasScope() ? fx->playhead() : -1.f;
|
||||
}
|
||||
|
||||
- (AUInternalRenderBlock)internalRenderBlock {
|
||||
EffectKernel *k = self.fxKernel;
|
||||
return ^AUAudioUnitStatus(AudioUnitRenderActionFlags *actionFlags, const AudioTimeStamp *timestamp,
|
||||
|
||||
Reference in New Issue
Block a user