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>
19 lines
772 B
Swift
19 lines
772 B
Swift
// 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))
|
|
}
|
|
}
|