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
@@ -89,6 +89,7 @@ int64_t ver(const ToolboxSlot &s) { return (int64_t)(int32_t)s.version; }
|
||||
struct FxUnit {
|
||||
ToolboxSlot *slot;
|
||||
std::unique_ptr<Effect> effect;
|
||||
int slotIndex = -1; // slot->index, kept so viz readers never touch the project
|
||||
int64_t lastVersion = -1;
|
||||
float lastTempo = NaNf;
|
||||
};
|
||||
@@ -219,6 +220,10 @@ public:
|
||||
std::vector<RetiredList> retiredLists;
|
||||
void collectRetired();
|
||||
|
||||
// ---- effect visualisation (UI thread): readers in flight hold retired chains
|
||||
mutable std::atomic<int> vizReaders{0};
|
||||
const Effect *vizFor(const Chains *chains, int slotIndex) const;
|
||||
|
||||
// ---- AudioEngine
|
||||
SynthVoice &allocSynthVoice(int bus);
|
||||
SampleVoice &allocSampleVoice(int bus);
|
||||
@@ -348,8 +353,12 @@ Engine::Impl::~Impl() {
|
||||
|
||||
void Engine::Impl::collectRetired() {
|
||||
const uint64_t done = blocksDone.load();
|
||||
for (size_t i = 0; i < retiredChains.size();)
|
||||
if (done > retiredChains[i].at) retiredChains.erase(retiredChains.begin() + (long)i); else ++i;
|
||||
// A viz reader may still be walking a retired chain; keep them all until it's out.
|
||||
// (seq_cst: a reader that arrives after this check loads the current chains.)
|
||||
if (vizReaders.load() == 0) {
|
||||
for (size_t i = 0; i < retiredChains.size();)
|
||||
if (done > retiredChains[i].at) retiredChains.erase(retiredChains.begin() + (long)i); else ++i;
|
||||
}
|
||||
for (size_t i = 0; i < retiredLists.size();)
|
||||
if (done > retiredLists[i].at) retiredLists.erase(retiredLists.begin() + (long)i); else ++i;
|
||||
}
|
||||
@@ -442,7 +451,7 @@ void Engine::Impl::rebuildFxChains() {
|
||||
ToolboxSlot *slot = slotAt(*proj, slotIndex);
|
||||
if (!slot || slot->type.empty()) continue;
|
||||
if (auto fx = Effect::create(slot->type.c_str(), sampleRate)) {
|
||||
FxUnit u{slot, std::move(fx)};
|
||||
FxUnit u{slot, std::move(fx), slotIndex};
|
||||
next->ch[ch].push_back(std::move(u));
|
||||
}
|
||||
}
|
||||
@@ -1237,8 +1246,31 @@ float Engine::channelMeter(int ch) const {
|
||||
bool Engine::channelClipped(int ch) const {
|
||||
return ch >= 0 && ch < TRACK_COUNT && impl->chClipHold[ch].load(std::memory_order_relaxed) > 0;
|
||||
}
|
||||
int Engine::effectScope(int, float *, int) const { return -1; }
|
||||
float Engine::effectPlayhead(int) const { return -1.f; }
|
||||
/** AudioEngine.vizFor: the first effect of toolbox [slotIndex] in any channel's chain
|
||||
* that publishes a scope, or nullptr. */
|
||||
const Effect *Engine::Impl::vizFor(const Chains *chains, int slotIndex) const {
|
||||
if (!chains) return nullptr;
|
||||
for (const auto &ch : chains->ch)
|
||||
for (const FxUnit &u : ch)
|
||||
if (u.slotIndex == slotIndex && u.effect->hasScope()) return u.effect.get();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Engine::effectScope(int slotIndex, float *out, int capacity) const {
|
||||
impl->vizReaders.fetch_add(1);
|
||||
const Effect *e = impl->vizFor(impl->channelChains.load(), slotIndex);
|
||||
int n = e ? e->copyScope(out, capacity) : -1;
|
||||
impl->vizReaders.fetch_sub(1);
|
||||
return n;
|
||||
}
|
||||
|
||||
float Engine::effectPlayhead(int slotIndex) const {
|
||||
impl->vizReaders.fetch_add(1);
|
||||
const Effect *e = impl->vizFor(impl->channelChains.load(), slotIndex);
|
||||
float p = e ? e->playhead() : -1.f;
|
||||
impl->vizReaders.fetch_sub(1);
|
||||
return p;
|
||||
}
|
||||
|
||||
void Engine::setMidiOutEnabled(bool on) { impl->midiOutEnabled.store(on); }
|
||||
bool Engine::midiOutEnabled() const { return impl->midiOutEnabled.load(); }
|
||||
|
||||
Reference in New Issue
Block a user