v2.1.0 release: Swift 6.4 modernization

Typed throws across the closed-error-set APIs (OSC, MIDI, engine add/schedule,
bus/config/parameter, and the WAV/RF64/Spectral file codecs — source-compatible
narrowing, new .ioFailure cases), plus internal hardening: NSLock-guarded
scheduling/MIDI state moved to Mutex<State>, and the Spectral/FFT scratch owners
moved to a ~Copyable RTScratchBuffer RAII buffer. No API or behavioral change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 19:54:59 -07:00
parent 2c20b02e59
commit 844dc4d9cd
42 changed files with 835 additions and 640 deletions
@@ -33,7 +33,7 @@ public final class SpectralTilt: SpectralProcessor {
/// Per-bin gain table sized `halfSize + 1`. Index 0 = DC, halfSize = Nyquist,
/// 1..halfSize-1 = complex bins. Pre-computed at init.
private let _gainTable: UnsafeMutablePointer<Float>
private let _gainTable: RTScratchBuffer<Float>
/// - Parameters:
/// - fftSize: Must match the paired `SpectralChain.Audio.fftSize`. Power of two ≥ 4.
@@ -59,8 +59,7 @@ public final class SpectralTilt: SpectralProcessor {
_binCount = _halfSize - 1
let tableCount: Int = _halfSize + 1
_gainTable = UnsafeMutablePointer<Float>.allocate(capacity: tableCount)
_gainTable.initialize(repeating: 1, count: tableCount)
_gainTable = RTScratchBuffer<Float>(count: tableCount, repeating: 1)
// Build gain table.
// gain(f) = 2 ^ (slope/6 · log2(f / pivot)) = (f / pivot) ^ (slope/6).
@@ -78,10 +77,7 @@ public final class SpectralTilt: SpectralProcessor {
}
}
deinit {
_gainTable.deinitialize(count: _halfSize + 1)
_gainTable.deallocate()
}
// No deinit: each RTScratchBuffer frees its own allocation exactly once.
public func process(spectral: SpectralBuffer, engine: SynthesisEngine) {
guard spectral.fftSize == _fftSize else { return }
@@ -89,7 +85,7 @@ public final class SpectralTilt: SpectralProcessor {
// Complex bins: vDSP_vmul gain[1..halfSize-1] * mag[1..halfSize-1].
if _binCount > 0 {
let gainComplex: UnsafeMutablePointer<Float> = _gainTable.advanced(by: 1)
let gainComplex: UnsafeMutablePointer<Float> = _gainTable.baseAddress.advanced(by: 1)
spectral.withUnsafeMutableMagnitudePointer { mp in
vDSP_vmul(mp, 1, gainComplex, 1, mp, 1, vDSP_Length(_binCount))
}