1.0.0 release
This commit is contained in:
Sources/LyrebirdCLI/Resources/XcodeTemplates/LyrebirdSpectralProcessor.xctemplate/TemplateInfo.plist
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>A SpectralProcessor — transforms a SpectralBuffer in-place after each FFT hop. Runs on the RT thread; mutate magnitude/phase per bin with no allocation, no locking. Use with SpectralChain.Audio as a .mono stage.</string>
|
||||
<key>Summary</key>
|
||||
<string>Lyrebird Spectral Processor (FFT-domain transform)</string>
|
||||
<key>SortOrder</key>
|
||||
<string>30</string>
|
||||
<key>AllowedTypes</key>
|
||||
<array>
|
||||
<string>public.swift-source</string>
|
||||
</array>
|
||||
<key>DefaultCompletionName</key>
|
||||
<string>MySpectralProcessor</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>SpectralProcessor name:</string>
|
||||
<key>Description</key>
|
||||
<string>Name of the SpectralProcessor class (also used as the file name).</string>
|
||||
<key>Type</key>
|
||||
<string>text</string>
|
||||
<key>Default</key>
|
||||
<string>MySpectralProcessor</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
//___FILEHEADER___
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// MARK: - ___FILEBASENAMEASIDENTIFIER___
|
||||
|
||||
/// One-line description of ___FILEBASENAMEASIDENTIFIER___.
|
||||
///
|
||||
/// A `SpectralProcessor` transforms the FFT-domain `SpectralBuffer`
|
||||
/// in-place after each forward-FFT hop. Wire it into a `SpectralChain.Audio`
|
||||
/// as a `.mono` stage:
|
||||
///
|
||||
/// ```swift
|
||||
/// let proc = ___FILEBASENAMEASIDENTIFIER___()
|
||||
/// let chain = SpectralChain.Audio(
|
||||
/// input: source,
|
||||
/// fftSize: 2048,
|
||||
/// stages: [.mono(proc)]
|
||||
/// )
|
||||
/// output(bus: 0, source: chain)
|
||||
/// ```
|
||||
///
|
||||
/// ## RT contract
|
||||
///
|
||||
/// `process(spectral:)` runs on the RT thread. It must:
|
||||
/// - Not allocate
|
||||
/// - Not lock
|
||||
/// - Not call into Foundation / Swift stdlib methods that may allocate
|
||||
///
|
||||
/// Read parameters from `@LiveParam` slots on a Synthesizer that owns this
|
||||
/// processor — those reads are atomic and RT-safe.
|
||||
public final class ___FILEBASENAMEASIDENTIFIER___: SpectralProcessor {
|
||||
|
||||
// MARK: - Configuration
|
||||
|
||||
/// Internal state that controls the spectral transform. Mutate from non-RT
|
||||
/// threads via atomic operations or `@LiveParam`-style projections.
|
||||
private var _someParameter: Double = 1.0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
public init() {
|
||||
// No allocation paths should run after this point on the RT thread.
|
||||
}
|
||||
|
||||
// MARK: - SpectralProcessor
|
||||
|
||||
public func process(spectral: SpectralBuffer, engine: SynthesisEngine) {
|
||||
// Walk every bin in the half-spectrum [0, binCount). DC and Nyquist
|
||||
// are real-only — phase at those bins is undefined.
|
||||
//
|
||||
// The starter body below applies a uniform magnitude scale to every
|
||||
// bin. Replace with your transform (spectral filtering, formant shift,
|
||||
// freezing, cross-synthesis, etc.). The subscripts compile to direct
|
||||
// memory reads/writes through the buffer's pre-allocated storage.
|
||||
for bin in 0..<spectral.binCount {
|
||||
let mag = spectral[magnitude: bin]
|
||||
spectral[magnitude: bin] = mag * Float(_someParameter)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user