Skip to content

Commit 23e8e3b

Browse files
authored
Merge pull request #27 from MartinColja/fix-clear-buffer-in-callback-instrument
Clear output buffer during CallbackInstrument DSP
2 parents cb1a127 + 361777c commit 23e8e3b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Sources/CAudioKitEX/Nodes/CallbackInstrumentDSP.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
}
3737

3838
void process(FrameRange range) override {
39+
zeroOutput(range.count, range.start);
40+
3941
count += range.count;
4042
if (updateTime) {
4143
lastFrameCount = count;

Tests/AudioKitEXTests/CallbackInstrumentTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,20 @@ class CallbackInstrumentTests: XCTestCase {
6666
/// If the callback does get called, this will fail our test, adding insult to injury
6767
XCTAssertEqual(data, expectedData)
6868
}
69+
70+
func testClearsBuffer() {
71+
let input = PlaygroundOscillator(waveform: Table([1, 1]))
72+
let callback = CallbackInstrument()
73+
74+
let engine = AudioEngine()
75+
let mixer = Mixer(input, callback)
76+
engine.output = mixer
77+
78+
input.start()
79+
let audio = engine.startTest(totalDuration: 1.0)
80+
audio.append(engine.render(duration: 1.0))
81+
82+
XCTAssertTrue(audio.toFloatChannelData()!.flatMap { $0 }.allSatisfy { $0 == 1 })
83+
}
6984
}
7085
#endif

0 commit comments

Comments
 (0)