1.0.0 release
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSDesktopFolderUsageDescription</key>
|
||||
<string>LyrebirdNRTDemo writes rendered audio files to the Desktop.</string>
|
||||
<key>NSDocumentsFolderUsageDescription</key>
|
||||
<string>LyrebirdNRTDemo writes rendered audio files to Documents.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<false/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,50 @@
|
||||
// FMTone.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// FM tone with an ASR envelope and stereo panning.
|
||||
///
|
||||
/// A sine modulator at `modFreq` drives the carrier frequency, producing
|
||||
/// classic FM timbre. The `pan` argument places the voice in the stereo field
|
||||
/// (-1 = hard left, 0 = centre, 1 = hard right).
|
||||
final class FMTone: SynthesizerBase {
|
||||
let carrierFreq: Double
|
||||
let modFreq: Double
|
||||
let modIndex: Double
|
||||
let amp: Double
|
||||
let pan: Double
|
||||
let envelope: Envelope
|
||||
|
||||
init(carrierFreq: Double,
|
||||
modFreq: Double = 220.0,
|
||||
modIndex: Double = 3.0,
|
||||
amp: Double = 0.18,
|
||||
pan: Double = 0.0,
|
||||
envelope: Envelope = Envelope(
|
||||
levels: [0, 1, 0.7, 0],
|
||||
durations: [0.02, 1.5, 0.5],
|
||||
curves: [2, 0, -3.5]
|
||||
)
|
||||
) {
|
||||
self.carrierFreq = carrierFreq
|
||||
self.modFreq = modFreq
|
||||
self.modIndex = modIndex
|
||||
self.amp = amp
|
||||
self.pan = pan
|
||||
self.envelope = envelope
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func build() {
|
||||
let env = EnvelopeGen.Control(
|
||||
envelope: envelope
|
||||
)
|
||||
let mod = OscSin.Audio(freq: modFreq) * (carrierFreq * modIndex)
|
||||
let sig = OscSin.Audio(freq: carrierFreq + mod) * env * amp
|
||||
output(bus: 0, source: Pan2(input: sig, pan: pan))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// main.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// Output to the Desktop — triggers the NSDesktopFolderUsageDescription TCC prompt on first run.
|
||||
let outputURL = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent("Desktop/nrt_output.caf")
|
||||
|
||||
// Render parameters.
|
||||
let sampleRate: Double = 48000
|
||||
let blockSize: Int = 512
|
||||
let attackTime: Double = 0.02
|
||||
let sustainTime: Double = 1.5
|
||||
let releaseTime: Double = 0.5
|
||||
let voiceLength: Double = attackTime + sustainTime + releaseTime
|
||||
|
||||
// Six FM voices — carrier frequencies, mod ratios, panning positions, start times.
|
||||
struct VoiceSpec {
|
||||
var carrier: Double
|
||||
var modFreq: Double
|
||||
var pan: Double
|
||||
var start: Double
|
||||
}
|
||||
|
||||
let voices: [VoiceSpec] = [
|
||||
VoiceSpec(carrier: 110.0, modFreq: 55.0, pan: -0.6, start: 0.0),
|
||||
VoiceSpec(carrier: 220.0, modFreq: 110.0, pan: 0.4, start: 0.25),
|
||||
VoiceSpec(carrier: 330.0, modFreq: 220.0, pan: -0.2, start: 0.5),
|
||||
VoiceSpec(carrier: 440.0, modFreq: 330.0, pan: 0.6, start: 0.75),
|
||||
VoiceSpec(carrier: 550.0, modFreq: 110.0, pan: -0.8, start: 1.0),
|
||||
VoiceSpec(carrier: 660.0, modFreq: 440.0, pan: 0.2, start: 1.25),
|
||||
]
|
||||
|
||||
let sustainLevel: Double = 1.0 / 2.0.squareRoot() // -3 dBFS (1/√2 ≈ sustainLevel)
|
||||
let interSetDelay: Double = 1.0
|
||||
let tailDuration: Double = 0.1
|
||||
|
||||
let lastStart = voices.map(\.start).max() ?? 0.0
|
||||
let totalDur = lastStart + interSetDelay + voiceLength + tailDuration
|
||||
|
||||
let driver = NRTDriver(outputURL: outputURL, duration: totalDur)
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: blockSize,
|
||||
sampleRate: sampleRate,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
driver: driver
|
||||
)
|
||||
|
||||
do {
|
||||
for v in voices {
|
||||
try engine.schedule(
|
||||
FMTone(carrierFreq: v.carrier, modFreq: v.modFreq, pan: v.pan,
|
||||
envelope: Envelope(
|
||||
levels: [0.0, 1.0, sustainLevel, 0.0],
|
||||
durations: [attackTime, sustainTime, releaseTime],
|
||||
curves: [4.0, -4.0, -10.0])
|
||||
),
|
||||
after: v.start
|
||||
)
|
||||
}
|
||||
|
||||
for v in voices {
|
||||
try engine.schedule(
|
||||
FMTone(carrierFreq: v.carrier * 1.2, modFreq: v.modFreq, pan: v.pan,
|
||||
envelope: Envelope(
|
||||
levels: [0.0, 1.0, sustainLevel, 0.0],
|
||||
durations: [attackTime, sustainTime, releaseTime],
|
||||
curves: [4.0, -4.0, -10.0])
|
||||
),
|
||||
after: v.start + interSetDelay
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
fputs("engine.schedule failed: \(error)\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
print("Rendering \(String(format: "%.2f", totalDur)) s → \(outputURL.path)")
|
||||
|
||||
do {
|
||||
try engine.start()
|
||||
print("Done.")
|
||||
} catch {
|
||||
fputs("Render failed: \(error)\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user