1.0.0 release
This commit is contained in:
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTD/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Kind</key>
|
||||
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
|
||||
<key>Platforms</key>
|
||||
<array>
|
||||
<string>com.apple.platform.macosx</string>
|
||||
<string>com.apple.platform.iphoneos</string>
|
||||
</array>
|
||||
<key>Description</key>
|
||||
<string>Top-level main.swift that renders a Lyrebird Synthesizer to disk via NRTDriver. NRT mode renders the full duration synchronously inside engine.start(). Drop this into the Sources directory of an executableTarget — Synthesizers must be added BEFORE start().</string>
|
||||
<key>Summary</key>
|
||||
<string>Lyrebird NRT Render (main.swift offline driver)</string>
|
||||
<key>SortOrder</key>
|
||||
<string>25</string>
|
||||
<key>AllowedTypes</key>
|
||||
<array>
|
||||
<string>public.swift-source</string>
|
||||
</array>
|
||||
<key>DefaultCompletionName</key>
|
||||
<string>main</string>
|
||||
<key>MainTemplateFile</key>
|
||||
<string>___FILEBASENAME___.swift</string>
|
||||
<key>Options</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Identifier</key>
|
||||
<string>productName</string>
|
||||
<key>Required</key>
|
||||
<true/>
|
||||
<key>Name</key>
|
||||
<string>File name:</string>
|
||||
<key>Description</key>
|
||||
<string>File name. Conventional Swift entry-point name is "main" for executableTargets.</string>
|
||||
<key>Type</key>
|
||||
<string>text</string>
|
||||
<key>Default</key>
|
||||
<string>main</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
//___FILEHEADER___
|
||||
//
|
||||
// Top-level main.swift — drop this into an executableTarget's Sources directory.
|
||||
// NRT mode renders synchronously inside engine.start(); the call blocks until
|
||||
// `duration` seconds of audio have been written to `outputURL`.
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// MARK: - Synthesizer
|
||||
|
||||
/// Replace this with your own Synthesizer. NRT renders whatever is in the engine
|
||||
/// at the moment `start()` is called — Synthesizers added later via
|
||||
/// `engine.add(_:)` will not be heard because the render loop has already exited.
|
||||
final class ___FILEBASENAMEASIDENTIFIER______Synth: SynthesizerBase {
|
||||
override func build() {
|
||||
let env = EnvelopeGen.Audio(
|
||||
envelope: Envelope(
|
||||
levels: [0.0, 1.0, 0.6, 0.0],
|
||||
durations: [0.02, 0.46, 0.5],
|
||||
curves: [.lin, .exponential, .exponential]
|
||||
),
|
||||
doneAction: .freeNode
|
||||
)
|
||||
let osc = OscSin.Audio(freq: 440.0) * env * 0.3
|
||||
output(bus: 0, source: Pan2(input: osc))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Render
|
||||
|
||||
let outputURL: URL = URL(fileURLWithPath: "output.caf")
|
||||
let renderDuration: Double = 4.0
|
||||
let blockSize: Int = 512
|
||||
let sampleRate: Double = 44100
|
||||
let numOutputChannels: Int = 2
|
||||
|
||||
let engine = SynthesisEngine(
|
||||
blockSize: blockSize,
|
||||
sampleRate: sampleRate,
|
||||
numOutputChannels: numOutputChannels,
|
||||
numInputChannels: 0,
|
||||
driver: NRTDriver(outputURL: outputURL, duration: renderDuration)
|
||||
)
|
||||
|
||||
// Synthesizers must be added BEFORE start() — NRTDriver renders the full
|
||||
// duration synchronously inside start() and returns once the file is closed.
|
||||
do {
|
||||
try engine.add(___FILEBASENAMEASIDENTIFIER______Synth())
|
||||
try engine.start()
|
||||
print("Rendered \(renderDuration)s → \(outputURL.path)")
|
||||
} catch {
|
||||
fputs("Render failed: \(error)\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user