v1.4.0 release: live-coding scratch editor, interpreted Graph DSL, ClosureSynthesizer + SampleLoop
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// SwapQuantizeTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@MainActor
|
||||
@Suite("SwapQuantize")
|
||||
struct SwapQuantizeTests {
|
||||
|
||||
/// Offline engine that never processes a block, so `clock.currentBeat`
|
||||
/// stays at 0 — target beats are then deterministic.
|
||||
private func makeClock(bpm: Double = 120) -> LyrebirdClock {
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: 64,
|
||||
controlBlockSize: 16,
|
||||
sampleRate: 48_000,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: 16,
|
||||
numControlBuses: 16,
|
||||
eventQueueCapacity: lyrebirdDefaultEventQueueCapacity,
|
||||
driver: OfflineDriver()
|
||||
)
|
||||
return LyrebirdClock(engine: engine, bpm: bpm)
|
||||
}
|
||||
|
||||
@Test func immediateHasNoTargetBeat() {
|
||||
#expect(SwapQuantize.immediate.targetBeat(clock: makeClock()) == nil)
|
||||
}
|
||||
|
||||
@Test func nextBeatTargetsUpcomingWholeBeat() {
|
||||
#expect(SwapQuantize.nextBeat.targetBeat(clock: makeClock()) == 1.0)
|
||||
}
|
||||
|
||||
@Test func nextBarTargetsUpcomingBarBoundary() {
|
||||
#expect(SwapQuantize.nextBar(beatsPerBar: 4).targetBeat(clock: makeClock()) == 4.0)
|
||||
}
|
||||
|
||||
@Test func nextBarClampsNonPositiveBeatsPerBar() {
|
||||
// beatsPerBar <= 0 clamps to 1, behaving like `.nextBeat`.
|
||||
#expect(SwapQuantize.nextBar(beatsPerBar: 0).targetBeat(clock: makeClock()) == 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user