// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later import Foundation /// The live effect scope of a song slot (the Granular Glitch's), straight from the /// engine's channel chains: nil until the slot sits on a mixer channel's FX. extension SlotDataSource { func effectScope(capacity: Int) -> (samples: [Float], playhead: Float)? { guard capacity > 0 else { return nil } var buf = [Float](repeating: 0, count: capacity) let n = buf.withUnsafeMutableBufferPointer { p in session.copyEffectScope(ofSlot: slot, into: p.baseAddress!, capacity: p.count) } guard n >= 0 else { return nil } return (Array(buf.prefix(n)), session.effectPlayhead(ofSlot: slot)) } }