From c8ec4d75d170479a369e1dd580a682949ccb41a7 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Sun, 2 May 2021 22:16:04 -0400 Subject: [PATCH] asserts that the buffer should be loaded when trying to slice addresses #886 --- Tone/core/context/ToneAudioBuffer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/Tone/core/context/ToneAudioBuffer.ts b/Tone/core/context/ToneAudioBuffer.ts index 237f4d00..af309208 100644 --- a/Tone/core/context/ToneAudioBuffer.ts +++ b/Tone/core/context/ToneAudioBuffer.ts @@ -240,6 +240,7 @@ export class ToneAudioBuffer extends Tone { * @param end The end time to slice. If none is given will default to the end of the buffer */ slice(start: Seconds, end: Seconds = this.duration): ToneAudioBuffer { + assert(this.loaded, "Buffer is not loaded"); const startSamples = Math.floor(start * this.sampleRate); const endSamples = Math.floor(end * this.sampleRate); assert(startSamples < endSamples, "The start time must be less than the end time");