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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user