Processing stereo volume control using sound library

I want to control PC stereo volume control, the following code is doing the same but both the channels are taking the save volume gain.

Q: How do I change the volume of individual channels?

Processing Code:

import processing.sound.*;
SoundFile file;
Sound s;
float val = 0.0;
float phase = 1.0;

void setup() {
  size(640, 360);
  background(0);
    
  // Load a soundfile from the /data folder of the sketch and play it back
  file = new SoundFile(this, "song.mp3");
  file.play();
  
  s = new Sound(this);
}      

void draw() {
  s.volume(val);
  val = val + (phase*0.001);
  
  if (val > 1.0){
    phase = -1.0;
  }
  else if (val < 0.0){
    phase = 1.0;
  }
  delay(1);
}

processing SOUND lib might not have that feature now,
but check on MINIM
http://code.compartmental.net/minim/audioinput_method_setpan.html
also find:
/ Files / Examples / Contributed Libraries / Minim / Synthesis / panExample /

I agree that minim is the way to go for stereo.

For the Processing Sound library, according to the reference (untested), if your sound is mono, you can set the stereo ratio with pan:

https://processing.org/reference/libraries/sound/SoundFile_pan_.html

Thanks, good suggestion, Its working for me.

Thanks its good suggestion.