Skip to content

Commit 889dafa

Browse files
committed
feat: OfflineContext returns a ToneAudioBuffer
instead of an AudioBuffer
1 parent e98545a commit 889dafa

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Tone/core/context/OfflineContext.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createOfflineAudioContext } from "../context/AudioContext";
22
import { Context } from "../context/Context";
33
import { Seconds } from "../type/Units";
44
import { isOfflineAudioContext } from "../util/AdvancedTypeCheck";
5+
import { ToneAudioBuffer } from "./ToneAudioBuffer";
56

67
/**
78
* Wrapper around the OfflineAudioContext
@@ -91,10 +92,11 @@ export class OfflineContext extends Context {
9192
* Render the output of the OfflineContext
9293
* @param async If the clock should be rendered asynchronously, which will not block the main thread, but be slightly slower.
9394
*/
94-
async render(asynchronous: boolean = true): Promise<AudioBuffer> {
95+
async render(asynchronous: boolean = true): Promise<ToneAudioBuffer> {
9596
await this.workletsAreReady();
9697
await this._renderClock(asynchronous);
97-
return this._context.startRendering();
98+
const buffer = await this._context.startRendering();
99+
return new ToneAudioBuffer(buffer);
98100
}
99101

100102
/**

test/helper/Offline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function Offline(
2828
}
2929
setContext(originalContext);
3030
const buffer = await offline.render();
31-
return new TestAudioBuffer(buffer);
31+
return new TestAudioBuffer(buffer.get() as AudioBuffer);
3232
}
3333

3434
export function whenBetween(value: Seconds, start: Seconds, stop: Seconds, callback: () => void): void {

0 commit comments

Comments
 (0)