P5 Sound Issues

Hi can anyone tell me where I am going wrong here? It appears that the p5 sound library is not being read - hence it doesn’t understand things like loop. However it is linked to in the HTML as a default and Ive not changed that. Ive also loaded a version of it into the folder as a local file and linked to that as well… Im using the online p5 editor. Any help would be greatly appreciated

Code: https://editor.p5js.org/seanzshow/sketches/j-_VtQpD5

1 Like

p5js.org/reference/#/p5/preload

Hi thanks for the reply.

I presume you are suggesting to move the loadSound bit into a preload function?

The issues above still remain in that addPhrase and loop functions are undefined.

I am quite new to coding but I can find reference to both of these in the p5 sound js file so it seems that what is happening is the sketch cant find the library…however I may be wrong.

Cheers

  • It’s not the methods which are undefined, but the variable drums itself!
  • You only declare it globally: let drums;
  • But you had never initialized it anywhere!
3 Likes

Ahh Ok that makes sense.

Ive added drums = new p5.Part(); into the setup and that works fine now.

Thanks for the help :slight_smile: