# Get error message withP5.dom.min.js and min.js

**URL:** <https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075>\
**Category:** Libraries\
**Created:** [May 13, 2021, 1:28am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075 "2021-05-13T01:28:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://discourse.processing.org/u/momo)\
**Post date:** [May 13, 2021, 1:28am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/1 "2021-05-13T01:28:48Z")

</div>

Hi, I’m using various js like P5.sound.js and dom js in my Html, try to work on show the sound wave on the page, and got errors: 1.amplitude is not defined 2.d.\_validateParameters is not a function #5242 please help me!

 ![截屏2021-05-13 上午1.57.53](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0a49c7f4d8214abe13579da43a6ef266535df9f4.jpeg)

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [May 13, 2021, 4:00am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/2 "2021-05-13T04:00:27Z")

</div>

Not possible to debug without at least seeing your `main.js`.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [May 13, 2021, 10:30am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/3 "2021-05-13T10:30:35Z")

</div>

Hi! Welcome to the forum!

As KumuPaul said please post your code, and the html file would be helpful too because p5.dom.js is currently integrated in p5.js and no longer exists, so maybe you have a mixup of libraries.

---

<div class="post-metadata">

**Author:** ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://discourse.processing.org/u/momo)\
**Post date:** [May 13, 2021, 10:59am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/4 "2021-05-13T10:59:42Z")

</div>

Thanks for your kindly remind. I will post them! I was constantly meet those issues. The bugs were happening whenever I wanted to initial the camera in my sketch, but it worked well when they were in a separate sketch. A new issue is I want to use p5.speech.js, but I find I can’t reference it. Any thoughts?  
this is the code from HTML:

```
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>p5.js example</title>
    <style>
      body {
        padding: 0;
        margin: 0;
      }
    </style>
     <script src="lib/p5.js"></script>
     <!-- <script src="lib/p5.dom.min.js"></script> -->
     <script src="lib/p5.sound.js"></script>
     <script src="lib/p5.speech.js"></script>
     <script src="lib/p5.speech.js"></script>
     <script src="lib/scenemanager.js"></script>
  </head>

```

```
  <script src=gamejs/main.js></script>
  <script src=gamejs/scene01_intro.js></script>
  <script src=gamejs/scene02_question.js></script>
  <!-- <script src=gamejs/scene02.js></script>
  <script src=gamejs/scene03.js></script> -->

```

this is the main.js

```auto
//scene manager

let mgr;

//video

```

```auto
let video;

let font;

let polygons;

let polygonsX = [];

let polygonsY = [];

var fontfile = "data/Krungthep.otf";

//sound array

let mySounds = [];

let mySound1;

let mySound2;

let mySound3;

// let mySound4;

// let mySound5;

// let mySound6;

// let mySound7;

// let mySound8;

// let mySound9;

// let mySound10;

//sound wave

let f1 = 20;

let f2 = 51;

let size = 600;

fft = new p5.FFT();

function preload() {

font = loadFont(fontfile);

//sound

//mySound1 = loadSound('../text-confirm.mp3');

mySound1 = loadSound('../01-12ft-intro.mp3');

mySound2 = loadSound('../02-12ft-question1.mp3');

mySound3 = loadSound('../03-systemerror.mp3');

//剩下的sound都在这里

}

function setup() {

createCanvas(windowWidth, windowHeight);

textFont(font);

frameRate(60);

amplitude = new p5.Amplitude();

//create sound array

mySounds = [mySound1, mySound2, mySound3]

// , mySound4, mySound5, mySound6, mySound7, mySound8, mySound9, mySound10]

//scence manager

mgr = new SceneManager();

mgr.showScene(intro);

// mgr.showNextScene();

}

// On window resize, update the canvas size

function windowResized() {

resizeCanvas(windowWidth, windowHeight);

}

// Render loop that draws shapes with p5

function draw() {

// scene

mgr.draw();

}

```

this is scene02.js. which need use camera

```auto
function question() {
    console.log('iam here');
    
    var video;
    var snapshot = [];
    this.enter = function(){
        video = createCapture(VIDEO);
        video.size(640, 480);
        video.hide();
        setTimeout(askQuestion, 5000);
        setTimeout(systemText, 10000);
        setTimeout(systemError, 10000);
    }

    function askQuestion() {
        //alex introduces itself, 15 sec audio
        mySound2.play();
    }

    function systemError(){
        mySound3.play();
    }

    function systemText(){
        textSize(50);         
        noStroke();
        fill("#ffb0ea");
        textAlign(CENTER, CENTER);
        text("system error/n the next programe will be excuted ", width / 2, height / 2);
    }
}

```

this is current console:

 ![截屏2021-05-13 下午8.30.37](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c3e47e2786cd41fb0e4291be71fc81aa8a650d1f.jpeg)

---

<div class="post-metadata">

**Author:** ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://discourse.processing.org/u/momo)\
**Post date:** [May 13, 2021, 12:37pm UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/5 "2021-05-13T12:37:33Z")

</div>

Hey, thanks for the infomation! i comment the reference of dom.min.js out, but still got errors.

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [May 13, 2021, 7:37pm UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/6 "2021-05-13T19:37:00Z")

</div>

Sorry, @momo, but there is still insufficient code here to reproduce whatever error you are encountering. Fortunately I figured out that [SceneManager is a public library](https://github.com/mveteanu/p5.SceneManager). I still had to do a bit of inference because of missing code, but what you’ve shared so far is basically workable.

Live version: [https://openprocessing.org/sketch/1194051](https://openprocessing.org/sketch/1194051)

```auto
let video;
let font;
let polygons;
let polygonsX = [];
let polygonsY = [];

var fontfile = "Oswald.ttf";

//sound array
let mySounds = [];
let mySound1;
let mySound2;
let mySound3;

let f1 = 20;
let f2 = 51;
let size = 600;

// This isn't used, but it might be better to initialize this in the setup
// function. Some p5 library resource may not be declared at the time your
// script is evaluated.
// Also you should use let here.
fft = new p5.FFT();

function preload() {
  font = loadFont(fontfile);

  //sound
  mySound1 = loadSound('TADA.WAV');
  mySound2 = loadSound('CHIMES.WAV');
  mySound3 = loadSound('CHORD.WAV');
  //剩下的sound都在这里
}

function setup() {
  createCanvas(windowWidth, windowHeight);
  textFont(font);
  frameRate(60);

  // Not used, but this ought to be declared with let somewhere
  // global variables are bad practice
  amplitude = new p5.Amplitude();

  //create sound array
  mySounds = [mySound1, mySound2, mySound3];

  //scence manager
  mgr = new SceneManager();
  mgr.showScene(intro);
  // I added this because otherwise there was no reference to the question scene
  mgr.addScene(question);

  // mgr.showNextScene();
}

// Added a way to move to the next scene for testing
function doubleClicked() {
  mgr.showNextScene();
}

// On window resize, update the canvas size
function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

// Render loop that draws shapes with p5
function draw() {
  // scene
  mgr.draw();
}

function intro() {
  this.draw = function() {
    background(255);
    noFill();
    let i = floor(millis() / 2000) % 2;
    let angle1 = map(millis() % 1000, 0, 1000, 0, TWO_PI);
    let angle2 = map(millis() % 2000, 0, 2000, 0, TWO_PI);
    arc(width / 2, height / 2, 200, 200, i == 0 ? angle1 : angle2, i == 0 ? angle2 : angle1);
  };
}

function question() {
  console.log('iam here');

  var video;
  var snapshot = [];
  this.enter = function() {
    // added background to make the scene transition obvious
    background('gray');
    video = createCapture(VIDEO);
    video.size(640, 480);
    video.hide();
    setTimeout(askQuestion, 5000);
    setTimeout(systemText, 10000);
    setTimeout(systemError, 10000);
  }
  
  this.draw = function() {
    image(video, 10, 10, 128, 96);
  }

  function askQuestion() {
    //alex introduces itself, 15 sec audio
    mySound2.play();
  }

  function systemError() {
    mySound3.play();
  }

  function systemText() {
    textSize(50);
    noStroke();
    fill("#ffb0ea");
    textAlign(CENTER, CENTER);
    text("system error\n the next programe will be excuted ", width / 2, height / 2);
  }
}

```

---

<div class="post-metadata">

**Author:** ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://discourse.processing.org/u/momo)\
**Post date:** [May 14, 2021, 3:15am UTC](https://discourse.processing.org/t/get-error-message-withp5-dom-min-js-and-min-js/30075/7 "2021-05-14T03:15:14Z")

</div>

Thank you so much, I followed your comments adjust my codes, another step is important that I found I’m not referenced the newest p5.js, after I redo this step, createVideo issus was solved.
