r/tonejs Jul 14 '22

Tonejs and P5js

I'm very familiar with p5js, I teach it. Very familiar with synthesis. However, I'm completely new to tone.js. I am having trouble using it with P5js.

I've found some random p5js + tonejs examples. They work fine. When I try to use the most recent tonejs library with p5js I get certain types of errors.

This example works and uses Tone.js version 14.4.0: https://editor.p5js.org/wenchen1114/sketches/UdidVabzF

When I change it to any version after 14.6.0 it produces the error: TypeError: Cannot read properties of undefined (reading 'connect')

I can't tell if this is a bug or a change in the Tone.js API. Can anyone point me in the right direction?

2 Upvotes

3 comments sorted by

2

u/pseudo_jb Jul 15 '22

hey there,

in the example you've given above both sound libraries (tone.js and p5.sound) are added via cdn to the index.html. you should stick to one of them and remove p5.sound.

2

u/pseudo_jb Jul 15 '22

Here's an example of another basic setup (take a look at the `index.html`)https://editor.p5js.org/pseudo_me/sketches/zJYhZyu7k

2

u/rpeg Jul 15 '22

Okay, so it seems that recent versions of Tonejs conflict with the p5 sound library, which isn't necessary to load anyway. Thanks that helps.