SoundApp Test Utility
Relevant source files
The following files were used as context for generating this wiki page:
soundapp is a minimal, auxiliary AppKit-based application designed to play audio within an isolated window environment during integration testing. The utility helps validate application-scoped audio isolation and target-window filtering inside the kilde project.
Sources: scripts/soundapp.swift:1-25, scripts/integration-test.sh:101-143
Introduction
The soundapp utility initializes an on-screen window target and continuously loops a specified audio file via AVAudioPlayer. This behavior allows validation tools to verify that ScreenCaptureKit (SCK) isolates audio belonging only to specific targeted windows.
Sources: scripts/soundapp.swift:6-18, scripts/integration-test.sh:101-143
Architecture and Execution Flow
soundapp executes as a regular AppKit process. The shell script compiles it dynamically using swiftc prior to execution.
Sources: scripts/integration-test.sh:82-84
Process Lifecycle and Interactions
This sequence shows how the integration test launches soundapp to create an isolated target window, plays audio, conducts the window capture validation, and cleans up the background process.
Sources: scripts/soundapp.swift:6-24, scripts/integration-test.sh:51-61, scripts/integration-test.sh:101-143
Components and Window Management
soundapp instantiates specific Cocoa elements to establish a valid target window system.
Sources: scripts/soundapp.swift:6-18
Window Configuration
The window setup uses specific identifiers and parameters:
- Title: Set to
"SpikeSoundWindow". This exact string is evaluated by the testing harness using the--matchoption inspike rec-windowandspike rec-audio-only. - Dimensions: Formed at position
x: 400, y: 500with a width of300and a height of180. - Style Mask: Utilizes
[.titled, .closable]to make it register as an on-screen independent desktop window.
Sources: scripts/soundapp.swift:7-13, scripts/integration-test.sh:105, scripts/integration-test.sh:129, Sources/Spike/RecWindowCmd.swift:34-40
Configuration Parameters
| Configuration Property | Type / Value | Target Object | Operational Effect |
|---|---|---|---|
window.title | "SpikeSoundWindow" | NSWindow | Provides the target lookup identifier for string matches. |
player.numberOfLoops | -1 | AVAudioPlayer | Drives endless playback loop for continuous test capture. |
player.volume | 0.8 | AVAudioPlayer | Establishes explicit audio generation levels for automated RMS validation. |
Timer interval | 90 seconds | Timer | Executes automatic self-termination to avoid orphaned background processes. |
Sources: scripts/soundapp.swift:13-23, scripts/integration-test.sh:105
Integration with Testing Harness
The integration testing harness exercises window audio capture isolation using soundapp across multiple validation checkpoints.
Sources: scripts/integration-test.sh:101-143
The flowchart describes the verification workflow used to prove that audio capture scopes do not leak audio samples across unrelated desktop window bounds.
Sources: scripts/integration-test.sh:25-33, scripts/integration-test.sh:101-137
Validated Commands
- Positive Test (T6):
spike rec-window --match SpikeSoundWindow --duration 6 --output t6.movcaptures the targeted utility and confirms that the output file contains valid recorded audio (RMS threshold $> 0.005$).
Sources: scripts/integration-test.sh:101-112 - Negative Test (T7):
spike rec-window --match <unrelated>attempts a capture session whilesoundappplays audio in the background. It ensures that the target audio fromsoundappstays excluded (RMS threshold $< 0.00005$).
Sources: scripts/integration-test.sh:114-137 - Audio-Only Application Filter (T8):
spike rec-audio-only --match SpikeSoundWindowevaluates if ScreenCaptureKit isolates app-scoped stream payloads when requested without active video inputs.
Sources: scripts/integration-test.sh:139-143, Sources/Spike/RecAudioOnlyCmd.swift:30-41
Implementation Reference
The implementation file contains the following complete routine:
import AppKit
import AVFoundation
let app = NSApplication.shared
let window = NSWindow(
contentRect: NSRect(x: 400, y: 500, width: 300, height: 180),
styleMask: [.titled, .closable],
backing: .buffered,
defer: false
)
window.title = "SpikeSoundWindow"
window.orderFrontRegardless()
let player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: CommandLine.arguments[1]))
player.numberOfLoops = -1
player.volume = 0.8
player.play()
Timer.scheduledTimer(withTimeInterval: 90, repeats: false) { _ in
NSApp.terminate(nil)
}
app.run()
Sources: scripts/soundapp.swift:1-25
Conclusion
soundapp provides a lightweight, clean background process for window-isolated integration tests. By generating dedicated audio playback tied directly to an explicit window instance name, it acts as a test oracle for kilde's advanced application-scoped and window-scoped capture layers.
Sources: scripts/soundapp.swift:6-18, scripts/integration-test.sh:101-143