1 year ago

#174274

test-img

Vee

Tone.js: Tone.start is not a function

I'm struggling to simply get Tone.js to work at all. At first I realized I needed to activate the web audio context on a button click. However, now I'm running into this issue: Tone.start is not a function.

My code is the simplest, shortest possible I could get it:

index.html:

<!DOCTYPE html>
<html>
    <head>
        <title>Tone.js</title>
        <meta charset="utf-8" />

        <script type="module" src="app.js"></script>
    </head>
    <body>
        <button>Start</button>
    </body>
</html>

App.js:


import * as Tone from './node_modules/tone/build/Tone.js'

window.onload = function() {

    document.getElementsByTagName('button')[0].addEventListener('click', startTone);
}

async function startTone() {
    await Tone.start();

}

This is based on the official documentation, under "Starting Audio". Also for reference I'm running this in Chrome.

javascript

html

tonejs

0 Answers

Your Answer

Accepted video resources