v2.4.1 release: scratchpad polish + demo cleanup
Maintenance release, no framework API changes. Scratchpad: Kill All Sound (⌘K) rename, mode-switch desync fix, code-completion prefix filtering restored (⌃Space Show Completions). Demos: GUIDemo voices + CLI EventPattern BlipVoice moved into Synthesizers/, EventPattern demo split into makeLead/makeBass, GUIDemo doc drift fixed (conductor default). LyrebirdScratch gains a SwiftPM package so the workspace shows it like GUIDemo (.xcodeproj kept for distribution). Linux live-coding scratchpad documented.
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
// ConductorDemoVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A gated sine voice for the conductor demo. ``EventPattern`` holds its gate open for the note's
|
||||
/// sustain, then closes it; the envelope plays its release and frees the voice, so a part that is
|
||||
/// toggled off rings out cleanly instead of being cut.
|
||||
final class ConductorDemoVoice: SynthesizerBase, EventGated {
|
||||
|
||||
/// Envelope attack length in seconds.
|
||||
nonisolated static let attackSeconds: Double = 0.01
|
||||
|
||||
/// Envelope release length in seconds — how long a note rings after its gate closes.
|
||||
nonisolated static let releaseSeconds: Double = 0.3
|
||||
|
||||
/// Oscillator frequency in Hz. Bound per event by the pattern.
|
||||
@LiveParam var freq: Double = 440.0
|
||||
|
||||
/// Linear output gain, 0...1. Bound per event by the pattern.
|
||||
@LiveParam var amp: Double = 0.2
|
||||
|
||||
/// Envelope gate. Open by default so the attack fires when the voice is added.
|
||||
@LiveParam var gate: Double = 1.0
|
||||
|
||||
var eventGate: ParameterNode { $gate }
|
||||
|
||||
override func build() {
|
||||
let envelope: Envelope = Envelope(
|
||||
levels: [0.0, 1.0, 0.0],
|
||||
durations: [ConductorDemoVoice.attackSeconds, ConductorDemoVoice.releaseSeconds],
|
||||
curves: [.welch, .welch],
|
||||
releaseNode: 1
|
||||
)
|
||||
let shaped: EnvelopeGen.Audio = EnvelopeGen.Audio(
|
||||
envelope: envelope,
|
||||
gate: $gate,
|
||||
doneAction: .freeNode
|
||||
)
|
||||
let source: OscSin.Audio = OscSin.Audio(freq: $freq, mul: $amp)
|
||||
let mono: any ValidGeneratorInput = source * shaped
|
||||
output(bus: 0, source: Pan2(input: mono, pan: 0.0))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SineToneUI.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A stereo sine tone whose frequency, amplitude, and pan are live-controllable
|
||||
/// from the UI. The `@UIParam` slots are the same model both the SwiftUI (macOS)
|
||||
/// and SwiftOpenUI (Linux) controls bind to — one synthesizer, two front ends.
|
||||
public final class SineToneUI: SynthesizerBase {
|
||||
|
||||
/// Frequency in Hz. Slider range: 440–880 Hz.
|
||||
@UIParam public var frequency: Double = 440.0
|
||||
|
||||
/// Output amplitude (linear gain). Knob range: 0–1.
|
||||
@UIParam public var amplitude: Double = 0.25
|
||||
|
||||
/// Stereo pan position. Knob range: -1 (hard left) … 0 (center) … +1 (hard right).
|
||||
@UIParam public var pan: Double = 0.0
|
||||
|
||||
public override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override func build() {
|
||||
let osc: OscSin.Audio = OscSin.Audio(freq: $frequency)
|
||||
output(bus: 0, source: Pan2(input: osc * $amplitude, pan: $pan))
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// VectorOscillatorUI.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A stereo vector oscillator whose XY position, frequency, and amplitude are
|
||||
/// live-controllable from the UI.
|
||||
///
|
||||
/// Four corner wavetables are crossfaded on a 2D XY plane:
|
||||
///
|
||||
/// C (triangle) ── D (Hanning) (y = 1)
|
||||
/// │ │
|
||||
/// A (sine) ──── B (saw-ish) (y = 0)
|
||||
/// x=0 x=1
|
||||
///
|
||||
/// Moving X blends A↔B (and C↔D); moving Y blends the AB mix into the CD mix.
|
||||
public final class VectorOscillatorUI: SynthesizerBase {
|
||||
|
||||
/// X-axis blend position. 0 = corner A/C, 1 = corner B/D. Normalized [0, 1].
|
||||
@UIParam public var x: Double = 0.5
|
||||
|
||||
/// Y-axis blend position. 0 = bottom (A, B), 1 = top (C, D). Normalized [0, 1].
|
||||
@UIParam public var y: Double = 0.5
|
||||
|
||||
/// Oscillator frequency in Hz. Slider range: 40–2000 Hz.
|
||||
@UIParam public var frequency: Double = 220.0
|
||||
|
||||
/// Output amplitude (linear gain). Knob range: 0–1.
|
||||
@UIParam public var amplitude: Double = 0.25
|
||||
|
||||
private let bufferA: LyrebirdBuffer // corner A: sine
|
||||
private let bufferB: LyrebirdBuffer // corner B: 16-partial saw-ish
|
||||
private let bufferC: LyrebirdBuffer // corner C: triangle
|
||||
private let bufferD: LyrebirdBuffer // corner D: Hanning window shape
|
||||
|
||||
public override init() {
|
||||
let tableSize: Int = lyrebirdDefaultTableSize
|
||||
|
||||
let a: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
a.fillSine()
|
||||
|
||||
let b: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
b.fill(partials: 16)
|
||||
|
||||
let c: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
c.fillTriangle()
|
||||
|
||||
let d: LyrebirdBuffer = LyrebirdBuffer(count: tableSize)
|
||||
d.fillHanning()
|
||||
|
||||
self.bufferA = a
|
||||
self.bufferB = b
|
||||
self.bufferC = c
|
||||
self.bufferD = d
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override func build() {
|
||||
let osc: VectorOscillator.Audio = VectorOscillator.Audio(
|
||||
bufferA: bufferA,
|
||||
bufferB: bufferB,
|
||||
bufferC: bufferC,
|
||||
bufferD: bufferD,
|
||||
freq: $frequency,
|
||||
x: $x,
|
||||
y: $y,
|
||||
mul: $amplitude
|
||||
)
|
||||
output(bus: 0, source: Pan2(input: osc, pan: 0.0))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user