Skip to content

Changing version to 1.11.11 breaks p5.sound #3728

@sidwellr

Description

@sidwellr

p5.js version

1.11.11

What is your operating system?

Linux

Web browser and version

Brave 1.83.112

Actual Behavior

TypeError: p5.MonoSynth is not a constructor

Expected Behavior

Play a sound when the box is clicked

Steps to reproduce

Steps:

  1. New sketch
  2. Use Library Management to change version to 1.11.10, ensure p5.sound.js is On
  3. Paste the Snippet (which is the example code from the p5.MonoSynth reference page)
  4. Click Play and click in the "tap to play" box a few times; observe correct behavior of a tone playing
  5. Use Library Management to change version to 1.11.11, ensure p5.sound.js is still On
  6. Click Play and observe error message

Note that a new sketch will start with version 1.11.11, and it will work fine. It's only when changing to a different version and back to 1.11.11 that doesn't work.

Snippet:

let monoSynth;

function setup() {
  let cnv = createCanvas(100, 100);
  cnv.mousePressed(playSynth);
  background(220);
  textAlign(CENTER);
  text('tap to play', width/2, height/2);

  monoSynth = new p5.MonoSynth();
}

function playSynth() {
  userStartAudio();

  let note = random(['Fb4', 'G4']);
  // note velocity (volume, from 0 to 1)
  let velocity = random();
  // time from now (in seconds)
  let time = 0;
  // note duration (in seconds)
  let dur = 1/6;

  monoSynth.play(note, velocity, time, dur);
}

Metadata

Metadata

Assignees

Labels

BugError or unexpected behaviorsReady for WorkIssue is ready for development work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions