b6fdee8bfc
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
// MouseDemoSynth.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import LyrebirdSynth
|
|
|
|
/// A sine tone driven entirely by the pointer via the `Mouse.*` control
|
|
/// generators — no `@UIParam`s. Horizontal position sets frequency, vertical
|
|
/// sets amplitude, so moving the pointer over the window sweeps the tone. Used
|
|
/// by `LYREBIRD_DEMO=mouse` to validate the Linux `MouseTracker` pointer source.
|
|
final class MouseDemoSynth: SynthesizerBase {
|
|
|
|
/// Frequency sweep range (Hz), mapped from `Mouse.X` (0…1).
|
|
private let freqBase: Double = 110.0
|
|
private let freqSpan: Double = 770.0 // → 110…880 Hz
|
|
|
|
/// Amplitude ceiling, mapped from `Mouse.Y` (0…1).
|
|
private let ampMax: Double = 0.3
|
|
|
|
override func build() {
|
|
let freq: any ValidGeneratorInput = Mouse.X.Control() * freqSpan + freqBase
|
|
let amp: any ValidGeneratorInput = Mouse.Y.Control() * ampMax
|
|
let osc: OscSin.Audio = OscSin.Audio(freq: freq)
|
|
output(bus: 0, source: Pan2(input: osc * amp))
|
|
}
|
|
}
|