Tone.js icon indicating copy to clipboard operation
Tone.js copied to clipboard

please endcode fetch uris of sound samples

Open pm100 opened this issue 3 years ago • 0 comments

I just spent several hours debugging this

window.playPianoSeq = (notes, interval) => {
    console.log("piano");
    const sampler = new Tone.Sampler({
        urls: {
            "C4": "assets/C4.mp3",
            "D#4": "assets/D#4.mp3",
            "F#4": "assets/F#4.mp3",
            "A4": "assets/A4.mp3",
        },
        release: 1
 
    }).toDestination();

    Tone.loaded().then(() => {
        sampler.triggerAttackRelease(["Eb4", "G4", "Bb4"], 4);
    })
}

Finally it is obvious of course. The fetch url is sliced off at the # character. Whats needed is to do a encodeURIComponent the urls before sending

pm100 avatar Jan 31 '22 23:01 pm100