question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use p5.sound.js as an npm library

See original GitHub issue

I would like to know how to use the sound library in the p5 npm module. I know the code is in there in a sub-folder called ‘addons’, but don’t know how to import or use it.

Currently I have import p5 from 'p5' and that works completely fine, I can do all the standard p5 things. But I have not been able to get it to work for any of the sound libraries.

Using the files directly from the p5js.org website import p5 from './p5/p5.js' works completely fine. But I have had no success with import Oscillator from './p5/addons/p5.sound' (or other such variants).

Any help will be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14

github_iconTop GitHub Comments

10reactions
JasoonScommented, Oct 17, 2016

I found the solution! It’s very simple. The following should do the trick.

import ‘p5/lib/addons/p5.sound’; import ‘p5/lib/addons/p5.dom’;

4reactions
conc2304commented, Apr 21, 2020

I found a somewhat hacky solution. My issues was that p5 was not defined when loading the p5 sound module. So after googleing the entire internet with no solution, I decided to try something dumb. I added import p5 from "p5"; to the top of “p5/lib/addons/p5.sound”;

then imported them as normal into my components import p5 from "p5"; import "p5/lib/addons/p5.sound";

and it’s working so far

**update ** just kidding, only works in development since its already installed ended up loading both p5 and p5.sound as script tags in the head not ideal but after multiple hours of trying it the npm way this was the only thing that worked

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't seem to play sounds in javascript using p5.js - Libraries
I am new to Js, and p5 and I was trying to play a mp3 from my computer, but I continually get this...
Read more >
P5.js not loading sound - Stack Overflow
Strange, the Sound: Load and Play Sound example seems to work fine. The error seems to point to on an XHR load error,...
Read more >
p5 - npm
Install · Repository · Homepage · Weekly Downloads · Version · License · Unpacked Size · Total Files.
Read more >
17.1: Loading and Playing - p5.js Sound Tutorial - YouTube
In this new video series, I discuss the p5. js sound library to work with audio. In this first part, I demonstrate how...
Read more >
reference - P5.js
sound library. p5.sound extends p5 with Web Audio functionality including audio input, playback, analysis and synthesis. p5.SoundFile: Load and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found