Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

Buffer.slice() not working (as I thought it would?) #886

Closed gyudisanyi closed 3 years ago

gyudisanyi commented 3 years ago

Hello!

A new Tone.Buffer('url').slice(1, 5) is supposed to return a ToneBuffer of 4 seconds starting at 1s of the source in the url, right?

I must be making some stupid syntax mistake, but it doesn't seem to pass it right - errors with "Failed to construct 'AudioBuffer': The number of channels provided (0) is outside the range [1, 32]."

However original (unsliced) buffer does have 2 channels and can be used any way I like.

Also if I don't set an end time, it doesn't default to the end time as it is supposed to, errors with 'The start time must be less than the end time' - maybe the problem is related.

Thank you for your help, it must be so basic it explains why I can't find the solution otherwise :)

S

gyudisanyi commented 3 years ago

goes deeper than that sorry :)

tambien commented 3 years ago

the issue is likely at the the url wasn't loaded. I pushed a commit which hopefully provides a better error message when this happens.

gyudisanyi commented 3 years ago

yess, thanks!