1.0.0 release
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
// LyrebirdAudioUnitEffectTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import AudioToolbox
|
||||
import AVFoundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
private final class PassthroughSynth: SynthesizerBase {
|
||||
override func build() {
|
||||
let left: AUInput.Audio = AUInput.Audio(channel: 0)
|
||||
let right: AUInput.Audio = AUInput.Audio(channel: 1)
|
||||
output(bus: 0, source: left)
|
||||
output(bus: 1, source: right)
|
||||
}
|
||||
}
|
||||
|
||||
private final class PassthroughEffectAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase {
|
||||
PassthroughSynth()
|
||||
}
|
||||
public override class var lyrebirdInputChannels: Int { 2 }
|
||||
public override class var lyrebirdOutputChannels: Int { 2 }
|
||||
}
|
||||
|
||||
private func makeEffectDescription() -> AudioComponentDescription {
|
||||
AudioComponentDescription(
|
||||
componentType: kAudioUnitType_Effect,
|
||||
componentSubType: 0x4C425046, // 'LBPF'
|
||||
componentManufacturer: 0x524C5A53, // 'RLZS'
|
||||
componentFlags: 0,
|
||||
componentFlagsMask: 0
|
||||
)
|
||||
}
|
||||
|
||||
@Suite("LyrebirdAudioUnit effect") struct LyrebirdAudioUnitEffectTests {
|
||||
|
||||
@Test func effectAUDeclaresInputAndOutputBuses() throws {
|
||||
let au: PassthroughEffectAU = try PassthroughEffectAU(componentDescription: makeEffectDescription())
|
||||
#expect(au.outputBusses.count == 1)
|
||||
#expect(au.inputBusses.count == 1)
|
||||
let inFormat: AVAudioFormat = au.inputBusses[0].format
|
||||
#expect(inFormat.channelCount == 2)
|
||||
}
|
||||
|
||||
@Test func effectAUEngineHasInputChannels() throws {
|
||||
let au: PassthroughEffectAU = try PassthroughEffectAU(componentDescription: makeEffectDescription())
|
||||
try au.allocateRenderResources()
|
||||
defer { au.deallocateRenderResources() }
|
||||
let engine: SynthesisEngine = try #require(au.engine)
|
||||
#expect(engine.numInputChannels == 2)
|
||||
#expect(engine.numOutputChannels == 2)
|
||||
}
|
||||
|
||||
@Test func instrumentAUEngineHasNoInputChannels() throws {
|
||||
// Sanity check the default — instrument AUs must not allocate input buses.
|
||||
final class StubSynth: SynthesizerBase {
|
||||
override func build() { output(bus: 0, source: 0.0) }
|
||||
}
|
||||
final class StubInstrumentAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { StubSynth() }
|
||||
}
|
||||
let desc: AudioComponentDescription = AudioComponentDescription(
|
||||
componentType: kAudioUnitType_MusicDevice,
|
||||
componentSubType: 0x53545542,
|
||||
componentManufacturer: 0x524C5A53,
|
||||
componentFlags: 0,
|
||||
componentFlagsMask: 0
|
||||
)
|
||||
let au: StubInstrumentAU = try StubInstrumentAU(componentDescription: desc)
|
||||
try au.allocateRenderResources()
|
||||
defer { au.deallocateRenderResources() }
|
||||
let engine: SynthesisEngine = try #require(au.engine)
|
||||
#expect(engine.numInputChannels == 0)
|
||||
#expect(au.inputBusses.count == 0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user