p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

setSource() doesn't seem to change source...

Open ffd8 opened this issue 4 years ago • 8 comments

Wondering why setSource() isn't changing the audioIn source? Example trying it based on the References... while in the console it tells me it changed sources, both in audio-reactivity and in upper corner w/ mic, still says internal microphone.

Just tested in Firefox (less of an issue, since they allow you to select/change mic), in Chrome – the option to change devices is always grayed out.. so it would be great to use this to manually select the source.

Still need to dig into source code... but curious if ths example above works for others? Or is it possible the method to select A/V sources ( demo + code ) has changed implemented?

ffd8 avatar Apr 21 '20 20:04 ffd8

I know this was a while ago, but I'm having the same issue and it's been preventing me from working on a couple of apps. setSource() just doesn't really work :/

Wondering if anyone has a fix or knows of a workaround?

jeffgord avatar Jan 17 '21 20:01 jeffgord

Same here. I can see the correct list of input devices with getSources() but setSource(0) has no effect, and the input remains the built-in mic, even though I set the default mic in the computer to my Yeti before getting into Chrome. I'm running a MacBook Pro 2018, OS 10.14.6. I'm running p5 in the p5.js Editor/Preview.

GenJamGuy avatar Jan 31 '21 03:01 GenJamGuy

Any update on this? I seem to have encountered the same issue on Ma Big Sur. Installed SoundFlower so I can "listen" to system sounds, but setSource doesn't work

paulcanning avatar Mar 16 '21 20:03 paulcanning

No progress to report, although I haven't tried much since my post. I'll check out SoundFlower. Thanks!

GenJamGuy avatar Mar 16 '21 21:03 GenJamGuy

@paulcanning + @GenJamGuy if you're using a newer operating system (10.14+, ie. big sur) you may want to switch to BlackHole for monitoring system sounds (then in Audio + Midi Setup, create a multi-output device with both speakers/headphones + blackhole).

In the meantime since I opened this issue, Chrome finally allows you to manually set the microphone input (using 89.0.4389.82 on 10.13.6) when you click on the Mic Icon -> 'Manage' (since the dropdown is deactived) -> then you can select mic input as wanted! Before this option, had to do crazy settings within AudioMidiSetup for sample rate to get Chrome to select the best/worst sound source... ugh.. anyways - so I can manually select it in the browser. Would still be niiiice if this setSource() would work...

ffd8 avatar Mar 16 '21 21:03 ffd8

Thanks. I'll give that a shot once I move to big sur (I use an app that hasn't made the jump yet).

GenJamGuy avatar Mar 17 '21 00:03 GenJamGuy

Has anyone made progress on this Issue? I can't seem to get p5.sound to use an external mic as an audio source, even when I use audioIn.setSource(). I am using a TTRS (three ring) cable into the headphone jack of my Macbook Pro 2020, software Monterey 12.4.

I have also gone into Chrome settings and changed the input from "Default" to be specifically "External mic" but p5.sound is still using the Macbook mic for audio. When I check System Preferences, the audio coming through the External Mic cable is showing on the Input bar, so I presume it is working on the hardware level. Just not in the browser when I'm using p5.sound

bendoesdata avatar Jul 06 '22 13:07 bendoesdata

I found a way, that worked for me:

var mic;

function setup() {
  mic = new p5.AudioIn();
  console.log(mic.getSources());

  mic.start(function () {
    mic.setSource(2);
  });

Set parameter of setSource() to the wanted input. You can find it with console.log(mic.getSources());

tari-w avatar Aug 06 '22 10:08 tari-w