8519cabe42
Additive conveniences to the macOS-only Live Scratch editor. No changes to existing public API. - Run Selection (⌘E): evaluate just the highlighted text, additively. - Graceful slot release: context.release(slot:) / free(slot:). - Engine panel: live oscilloscope (ScopeCapture) + CPU avg/peak + counts. - Reset Session / Restart to Reclaim Memory. - Always-open console panel (report messages + errors with line:col). - Faster typing: debounced highlight, updateNSView fast-path, publish guards. - Manual code completion (Esc / F5), no auto-trigger on `.`; completion replaces the partial word, not the receiver expression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
64 lines
2.0 KiB
Swift
64 lines
2.0 KiB
Swift
// ScopeAttachTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#if os(macOS)
|
|
import Testing
|
|
import LyrebirdSynth
|
|
@testable import LyrebirdLiveCompile
|
|
|
|
@MainActor
|
|
@Suite("LiveSession scope attach")
|
|
struct ScopeAttachTests {
|
|
|
|
private func makeEngine(outChannels: Int = 2) -> SynthesisEngine {
|
|
SynthesisEngine(
|
|
blockSize: 64,
|
|
controlBlockSize: 16,
|
|
sampleRate: 48_000,
|
|
numOutputChannels: outChannels,
|
|
numInputChannels: 0,
|
|
numAudioBuses: 16,
|
|
numControlBuses: 16,
|
|
eventQueueCapacity: lyrebirdDefaultEventQueueCapacity,
|
|
driver: OfflineDriver()
|
|
)
|
|
}
|
|
|
|
@Test func attachesStereoScopeByDefault() {
|
|
let engine: SynthesisEngine = makeEngine(outChannels: 2)
|
|
let session: LiveSession = LiveSession(engine: engine)
|
|
let scope: ScopeCapture? = session.scope
|
|
#expect(scope != nil)
|
|
#expect(scope?.buses == [0, 1])
|
|
// Installed on the engine so the RT thread writes to it.
|
|
#expect(engine.scopeTap === scope)
|
|
}
|
|
|
|
@Test func attachScopeFalseInstallsNothing() {
|
|
let engine: SynthesisEngine = makeEngine()
|
|
let session: LiveSession = LiveSession(engine: engine, attachScope: false)
|
|
#expect(session.scope == nil)
|
|
#expect(engine.scopeTap == nil)
|
|
}
|
|
|
|
@Test func monoEngineTapsOneBus() {
|
|
let engine: SynthesisEngine = makeEngine(outChannels: 1)
|
|
let session: LiveSession = LiveSession(engine: engine)
|
|
#expect(session.scope?.buses == [0])
|
|
}
|
|
|
|
@Test func reusesExistingTapRatherThanReplacing() {
|
|
let engine: SynthesisEngine = makeEngine()
|
|
let existing: ScopeCapture = ScopeCapture(buses: [0], bufferSize: 256)
|
|
engine.scopeTap = existing
|
|
let session: LiveSession = LiveSession(engine: engine) // attach on, but a tap exists
|
|
#expect(session.scope === existing)
|
|
#expect(engine.scopeTap === existing)
|
|
}
|
|
}
|
|
|
|
#endif
|