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

Open
@lab-mediaArts

Description

@lab-mediaArts

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Bug/Investigation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions