# Two microphone inputs

**URL:** <https://discourse.processing.org/t/two-microphone-inputs/14321>\
**Category:** Libraries\
**Created:** [September 30, 2019, 3:40pm UTC](https://discourse.processing.org/t/two-microphone-inputs/14321 "2019-09-30T15:40:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![l3ehfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/l3ehfar/32/4074_2.png) [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Post date:** [September 30, 2019, 3:40pm UTC](https://discourse.processing.org/t/two-microphone-inputs/14321/1 "2019-09-30T15:40:39Z")

</div>

I wanna know how to get two mic inputs in my p5js code. actually my sound card has two input channels and I wanna process each channel’s signal separated from the other in my code.

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [September 30, 2019, 10:52pm UTC](https://discourse.processing.org/t/two-microphone-inputs/14321/2 "2019-09-30T22:52:27Z")

</div>

Check out the example on the [getSources()](https://p5js.org/reference/#/p5.AudioIn/getSources) reference page. Not sure if it’s exactly what you’re looking for but hope it’s somewhere to start.

---

<div class="post-metadata">

**Author:** ![l3ehfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/l3ehfar/32/4074_2.png) [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Post date:** [October 11, 2019, 7:47pm UTC](https://discourse.processing.org/t/two-microphone-inputs/14321/3 "2019-10-11T19:47:00Z")

</div>

yeah but it discovers 3 input devices which all of them are the same! do you have any solution to define difference between them?

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [October 11, 2019, 8:40pm UTC](https://discourse.processing.org/t/two-microphone-inputs/14321/4 "2019-10-11T20:40:11Z")

</div>

You might have to do some trial and error to see which one is which. I think the extra one is your desktop audio. So that one would have sound on it if you played a video even if your computer is muted. It seems weird that the console log doesn’t have more information. But what’s behind it is the [`MediaDevices.getUserMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia). So you can do something like:

```auto
  audioGrab.getSources(function(deviceList) {
    console.log(deviceList);
    
    for (let i = 0; i < deviceList.length; i++) {
      console.log(deviceList[i].deviceId);
    }
    
    let micIndex = 0;
    let searchId = "ZiMU0uX4io0elNNAEpeif2qJd226nMu/fUsF2RZ8vbc=";
    for (let i = 0; i < deviceList.length; i++) {
      if (deviceList[i].deviceId === searchId) {
        console.log("Found Mic");
        micIndex = i;
      }
    }
    
    audioGrab.setSource(micIndex);
  });

```

Unfortunately I think you’d have to change the searchId depending on which computer it’s running on. Also I’d be interested to know if there’s a set order to devices. That way you could just select the microphones based on their order in the list once you find it out but I don’t know if that’s predictable or not.
