P5 loadSound not defined

I keep getting an error saying loadSound is not defined here is my code if anyone can help me out.

index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Server</title>

  <scirpt src="./p5/addons/p5.sound.js"></scirpt>
  <script src="./p5/p5.js"></script>
  <scirpt src="./p5/addons/p5.dom.min.js"></scirpt>
  <script src="./sketch.js"></script>

  <style>
    body {
      overflow: hidden;
      margin: 0px;
      padding: 0px;
    }
  </style>
</head>

<body>

</body>

</html>

the js code

var song, analyzer, fft, peakDetect, peaks;
var timestamp = new Date().getTime();
var canvas;

function preload() {
  song = loadSound("song.mp3");
  song.play();
}

function draw() {
  background(51);
}

function setup() {
  canvas = createCanvas(windowWidth, windowHeight);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

any idea why i keep getting this error all libraries are up to date

1 Like

This “index.html” file below should work for your “sketch.js” file: :construction_worker_man:

“index.html”:

<!DOCTYPE html>

<meta charset=utf-8>
<meta name=viewport content=width=device-width,initial-scale=1>

<script defer src=https://cdn.JsDelivr.net/npm/p5></script>
<script defer src=https://cdn.JsDelivr.net/npm/p5/lib/addons/p5.dom.min.js></script>
<script defer src=https://cdn.JsDelivr.net/npm/p5/lib/addons/p5.sound.min.js></script>

<script defer src=sketch.js></script>
1 Like

it worked thanks! is there a reason why importing localy won’t work?

Nope, not at all! :sunglasses:
But after a 2nd glance on your own “index.html”, I can see those “.js” files are loaded outta order! :cold_sweat:

Always keep in mind the library file “p5.js” is the main 1. :spiral_calendar:
And the other “p5.some_addon_lib.js” files depend on it. :bowing_man: