Skip to content

[p5.js 2.0 Bug Report]: loadSound() is not defined in p5.js v2.x (TypeError: Cannot read properties of undefined ‘pixels’) #7879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 17 tasks
lab-mediaArts opened this issue Jun 4, 2025 · 2 comments

Comments

@lab-mediaArts
Copy link

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.0.3

Web browser and version

Chrome 137.0.7151.57

Operating system

Windows

Steps to reproduce this

Steps:

  1. Opened project with sound that works in 1.x
  2. Changed version to 2.0.3
  3. Moved loadSound to function set up and changed function set up to async function set up.
  4. Added await before the loadSound function.
  5. Console reports TypeError: Cannot read properties of undefined (reading 'pixels') && ReferenceError: loadSound is not defined
    at setup (/sketch.js:9:3)

Snippet:

sketch.js

// Paste your code here :)
let note1, note2, note3, note4, note5, note6

async function setup() {
createCanvas(600, 400);
rectMode(CENTER)

soundFormats('mp3', 'ogg');
note1 = await loadSound('c.mp3')
note2 = await loadSound('d.mp3')
note3 = await loadSound('e.mp3')
note4 = await loadSound('f.mp3')
note5 = await loadSound('g.mp3')
note6 = await loadSound('a.mp3')
}

@perminder-17 perminder-17 changed the title [p5.js 2.0 Bug Report]: [p5.js 2.0 Bug Report]: loadSound() is not defined in p5.js v2.x (TypeError: Cannot read properties of undefined ‘pixels’) Jun 5, 2025
@limzykenneth
Copy link
Member

Hi @lab-mediaArts, can you confirm which version of p5.sound are you using? We have a new release of p5.sound.js while the older version has since been deprecated and it may not support 2.x of p5.js.

@lab-mediaArts
Copy link
Author

Ahh okay. I am attempting to update a 1.x program with sound to work in 2.x. I'm guessing there is a new script to replace in the index.html. I'll give that a try.

@ksen0 ksen0 moved this to Todo in p5.sound.js Jun 10, 2025
@ksen0 ksen0 moved this from Ready for Work to Bug/Investigation in p5.sound.js Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bug/Investigation
Development

No branches or pull requests

2 participants