Minim setting volume of an audioPlayer

Hi,

Quick question

It’s been a long time I didn’t use sound with processing. I wanted to play a file and setting his volume, and I discovered the Sound libraries aren’t working with windows anymore. So I decided to go back to Minim, but I can’t manage to set the volume or the gain.

What can I do ? :thinking:

Here is the message I get :

=== Minim Error ===
=== Volume is not supported.

and here is a sample of my code :

import ddf.minim.*;
 
Minim minim;
AudioPlayer player;


void setup() {
  
  minim = new Minim(this);
   
  player = minim.loadFile("walk.wav");
  player.play();
  player.setVolume(0); 
  
}
1 Like

I looked online and found this:

Setting the volume with gain, instead of with the setVolume() function which I hear has some issues with some versions of Processing. Read about that here.

Gain should be able to work though. Hopefully this helps,

EnhancedLoop7

1 Like

Hi @EnhancedLoop7, thanks for your answer.
On my mac os 10.13.4 the setGain fonction is not working either since I can still hear the sound, but the error message has changed

==== JavaSound Minim Error ====
==== Error reading from the file - Stream closed

Here is the code

import ddf.minim.*;
 
Minim minim;
AudioPlayer player;

void setup() {
  
  minim = new Minim(this);
  player = minim.loadFile("walk.wav");
  player.setGain(0); 
  player.play();
  
}

Is there a setGain() function? Forgive me if I’m mistaken but I haven’t really heard of it. Maybe you can try shifting the gain like shown in the link I sent? Hopefully that works,

EnhancedLoop7

I’m using this doc http://code.compartmental.net/minim/
Is it outdated ?

Anyway the following works. The second error was due to the play() function called in the setup().

Minim minim;
AudioPlayer player;
static final int FADE = 2500;


void setup() {
  
  minim = new Minim(this);
  player = minim.loadFile("walk.wav");

}

void draw() {
  
  player.play();
  player.shiftGain(player.getGain(),-80,FADE);
  
}
1 Like

Glad that that got taken care of :smiley:

EnhancedLoop7