1.2.1 release to support some ShoeGaze features
This commit is contained in:
@@ -114,6 +114,44 @@ struct PlayBufferTests {
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
// MARK: - loopLength narrowing
|
||||
|
||||
@Test func narrowedLoopLengthWrapsWithinBoundNotFullBuffer() throws {
|
||||
// 32-frame buffer, loopLength narrowed to 8 — loop:true should wrap every
|
||||
// 8 frames instead of every 32.
|
||||
let engine: SynthesisEngine = try makeEngine(blockSize: 16)
|
||||
let graph: SynthGraph = makeSynthGraph(engine: engine)
|
||||
|
||||
let buf: LyrebirdBuffer = makeRampBuffer(frames: 32)
|
||||
let narrowedLength: Int = 8
|
||||
buf.setLoopLength(narrowedLength)
|
||||
let player: PlayBuffer.Audio = PlayBuffer.Audio(buffer: buf, loop: true, interpolation: .none)
|
||||
|
||||
let out: [[Double]] = player.calculatedSamples(graph: graph, count: 16)
|
||||
|
||||
// Frames 0–7 then 0–7 again (loopLength == 8), not 0–15 (full buffer.count).
|
||||
let expected: [Double] = [0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7]
|
||||
for i: Int in 0..<16 {
|
||||
#expect(abs(out[0][i] - expected[i]) < 1e-9,
|
||||
"sample \(i): expected \(expected[i]), got \(out[0][i])")
|
||||
}
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
@Test func narrowedLoopLengthClampsWithoutLoop() throws {
|
||||
// 32-frame buffer, loopLength narrowed to 8, loop:false — non-interpolated reads
|
||||
// must clamp to loopLength - 1 (frame 7), not buffer.count - 1 (frame 31).
|
||||
let buf: LyrebirdBuffer = makeRampBuffer(frames: 32)
|
||||
let narrowedLength: Int = 8
|
||||
buf.setLoopLength(narrowedLength)
|
||||
|
||||
let result: Double = lyrebirdBufferRead(
|
||||
buf, channel: 0, phase: 100.0, interpolation: .none, loop: false
|
||||
)
|
||||
#expect(abs(result - Double(narrowedLength - 1)) < 1e-9,
|
||||
"clamped read should hold at loopLength-1 (\(narrowedLength - 1)), got \(result)")
|
||||
}
|
||||
|
||||
// MARK: - doneAction
|
||||
|
||||
@Test func doneActionFreeNodeSetsNeedsFree() throws {
|
||||
|
||||
Reference in New Issue
Block a user