Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 693 Bytes

README_SOUND.md

File metadata and controls

28 lines (20 loc) · 693 Bytes

p5 Sound

You can add sound (p5Sound library) but this is currently an experimental and optional feature of this wrapper. You should not encounter any issue with single sketches, but currently multiple sketches might create errors.

Here how to use the sound library:

import { sketch } from 'p5js-wrapper';
import 'p5js-wrapper/sound';

import mysound from './mysound.mp3';

let soundEffect;

sketch.setup = function () {
  createCanvas(100, 100);
  soundEffect = loadSound(mysound);
};

sketch.draw = function () {
  background('#eeeeee');
};

// Play sound on click
sketch.mousePressed = function () {
  soundEffect.play();
};