processing / processing/p5.js

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

Open
#7,879 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

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')
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied sketch.js reproduction, focusing on async setup(), soundFormats(), and each loadSound() call in p5.js 2.0.3. Reproduce the reported errors in the stated Chrome environment, then trace the sound-loading entry point to determine the expected migration behavior and verify that the example loads all six sounds without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
audio-video-rtc, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.