Skip to content

Commit

Permalink
feat: OfflineContext returns a ToneAudioBuffer
Browse files Browse the repository at this point in the history
instead of an AudioBuffer
  • Loading branch information
tambien committed Oct 3, 2019
1 parent e98545a commit 889dafa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Tone/core/context/OfflineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createOfflineAudioContext } from "../context/AudioContext";
import { Context } from "../context/Context";
import { Seconds } from "../type/Units";
import { isOfflineAudioContext } from "../util/AdvancedTypeCheck";
import { ToneAudioBuffer } from "./ToneAudioBuffer";

/**
* Wrapper around the OfflineAudioContext
Expand Down Expand Up @@ -91,10 +92,11 @@ export class OfflineContext extends Context {
* Render the output of the OfflineContext
* @param async If the clock should be rendered asynchronously, which will not block the main thread, but be slightly slower.
*/
async render(asynchronous: boolean = true): Promise<AudioBuffer> {
async render(asynchronous: boolean = true): Promise<ToneAudioBuffer> {
await this.workletsAreReady();
await this._renderClock(asynchronous);
return this._context.startRendering();
const buffer = await this._context.startRendering();
return new ToneAudioBuffer(buffer);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/helper/Offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function Offline(
}
setContext(originalContext);
const buffer = await offline.render();
return new TestAudioBuffer(buffer);
return new TestAudioBuffer(buffer.get() as AudioBuffer);
}

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

0 comments on commit 889dafa

Please sign in to comment.