Using speaker output as input for p5.sound.js

Hi there!

I want to analyze the songs I'm playing on my PC, for example, listening to something on Youtube and generating it's FFT. So that means I need to use the output (speakers) as an input for the FFT. I've been looking up the reference but I can't see how to access the output. In Minim for Processing the equivalent was Minim.STEREO.

Another thing I have realized, is that when running the sketch all audio I was playing in my browser goes quieter, like when I receive a Skype call. Is there a way to change this so it doesn't happen?

This is what I have so far but it doesn't work, any help would be greatly appreciated:

var audioSignal;

function setup() {


  audioSignal = new p5.AudioIn()

  fft = new p5.FFT();

  var spectrum = fft.analyze(); 


function draw() {



  • Hello SimplyEnvision !

    From what I've seen in the audioIn reference page you can't set a specific source in the code, it will be selected once the code execute and in different manners depending on the browser ( some browsers don't even support it ).

    I guess as a static solution ( if you want to run this only on a specific computer ) you could use the listSource() function to try and identify your speakers ID to use in setSource(ID).

  • Hey! Thank you for your help!

    What if the sound was playing in another browser window, would that change anything? Is there any way of accessing that audio easier?


Sign In or Register to comment.