// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later #import "SizzleSession+Viz.h" #import "SizzleSession+Internal.h" #import using namespace sizzle; static char kVizEngineKey; @implementation SizzleSession (Viz) /// The engine, without the song lock: polling under it at display rate would make /// the audio thread (which only try-locks) drop a block now and then. The engine is /// created once with the session and lives as long as it, so its address is fetched /// once under the lock and kept; Engine::effectScope / effectPlayhead are lock-free. - (const engine::Engine *)vizEngine { NSValue *v = objc_getAssociatedObject(self, &kVizEngineKey); if (!v) { __block const engine::Engine *e = nullptr; [self read:^(const model::Project &, const engine::Engine &eng) { e = ŋ }]; v = [NSValue valueWithPointer:e]; objc_setAssociatedObject(self, &kVizEngineKey, v, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } return (const engine::Engine *)v.pointerValue; } - (NSInteger)copyEffectScopeOfSlot:(NSInteger)slot into:(float *)out capacity:(NSInteger)capacity { return self.vizEngine->effectScope((int)slot, out, (int)capacity); } - (float)effectPlayheadOfSlot:(NSInteger)slot { return self.vizEngine->effectPlayhead((int)slot); } @end