mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
asserts that the buffer should be loaded when trying to slice
addresses #886
This commit is contained in:
parent
f724be916e
commit
c8ec4d75d1
1 changed files with 1 additions and 0 deletions
|
@ -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
|
* @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 {
|
slice(start: Seconds, end: Seconds = this.duration): ToneAudioBuffer {
|
||||||
|
assert(this.loaded, "Buffer is not loaded");
|
||||||
const startSamples = Math.floor(start * this.sampleRate);
|
const startSamples = Math.floor(start * this.sampleRate);
|
||||||
const endSamples = Math.floor(end * this.sampleRate);
|
const endSamples = Math.floor(end * this.sampleRate);
|
||||||
assert(startSamples < endSamples, "The start time must be less than the end time");
|
assert(startSamples < endSamples, "The start time must be less than the end time");
|
||||||
|
|
Loading…
Reference in a new issue