# P5js AudioIn function not working on instance mode

**URL:** https://discourse.processing.org/t/p5js-audioin-function-not-working-on-instance-mode/31179
**Category:** Libraries
**Created:** [July 11, 2021, 6:54pm UTC](https://discourse.processing.org/t/p5js-audioin-function-not-working-on-instance-mode/31179 "2021-07-11T18:54:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Seriously](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Seriously](https://discourse.processing.org/u/Seriously)
#### Post date: [July 11, 2021, 6:54pm UTC](https://discourse.processing.org/t/p5js-audioin-function-not-working-on-instance-mode/31179/1 "2021-07-11T18:54:58Z")

</div>

I was converting my p5js code to instance mode to run 2 canvases in the same DOM but my `p5.AudioIn()` function is not working. The error I get is referencing `Failed to construct 'AudioWorkletNode'` . I have uploaded a screenshot of the error below because it has more information about it. Why isn’t `AudioIn` not working when converted to instance mode but works on global mode. Any help is appreciated. Feel free to comment if you have any questions. Thanks in advance.

![tempCapture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5a99735a6548827a658e9947c9fbbe7ce5e67d15.png)

```auto
<html>

<head>
  <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 src="https://cdn.jsdelivr.net/npm/p5@1.4.0/lib/p5.js"></script>
</head>

<body>
</body>

</html>

```

```auto
let s2 = function(sketch) {
  sketch.quinnListenMic;

  sketch.setup = function() {
    let cnv = sketch.createCanvas(300, 300);
    cnv.mousePressed(sketch.userStartAudio);
    sketch.quinnListenMic = new p5.AudioIn(); //ERROR HERE
    sketch.quinnListenMic.start();
  }

  sketch.draw = function() {

    sketch.background(100)

    sketch.micLevel = quinnListenMic.getLevel();
    console.log(sketch.micLevel)

  }

}

var myp5_2 = new p5(s2);

```

---

<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: [July 18, 2021, 7:41pm UTC](https://discourse.processing.org/t/p5js-audioin-function-not-working-on-instance-mode/31179/2 "2021-07-18T19:41:16Z")

</div>

hi! welcome to the forum!

there are a bit weird things happening here. first with html file, you don’t need p5.dom anymore as it is integrated in p5.js. also you are loading p5.js twice. and you need double quotation marks around the url. you can use default file from the web editor

```auto
<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

```

in the sketch file you are missing `sketch` before `quinnListenMic` in draw - otherwise it should work.
