javax.sound.sampled cannot change volume of clip (part 2, closed before properly testing)

oops. go here for what I have so far: https://discordapp.com/channels/648956210850299986/1204195625168805898 The summary is that I can control one or two things in my audio clip, but they don't seem to change anything. Also, volume, the one I want, is still unsupported. Here's what the code looks like currently:
public void play(float volume) {
try {
AudioInputStream stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(file));
DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat());
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(stream);
clip.start();
((FloatControl) clip.getControl(FloatControl.Type.VOLUME)).setValue(volume);
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
e.printStackTrace();
}
}
public void play(float volume) {
try {
AudioInputStream stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(file));
DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat());
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(stream);
clip.start();
((FloatControl) clip.getControl(FloatControl.Type.VOLUME)).setValue(volume);
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
e.printStackTrace();
}
}
Stuff like master gain works, but again, doesn't change anything. Putting before starting makes them all unsupported. Help?
16 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @The Typhothanian! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
The Typhothanian
The TyphothanianOP10mo ago
@dan1st | Daniel closed before properly testing, issue is not resolved. Help pls?
JavaBot
JavaBot10mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
dan1st
dan1st10mo ago
Does the master gain thing work?
The Typhothanian
The TyphothanianOP10mo ago
Not sure what it does, but don't hear any changes It doesn't crash tho
dan1st
dan1st10mo ago
make sure to use the correct value
The Typhothanian
The TyphothanianOP10mo ago
Yeah, also pan works
dan1st
dan1st10mo ago
? I think it's in decibel
The Typhothanian
The TyphothanianOP10mo ago
Well, it doesn't crash, but no audible effect (i think) k one sec Okay it might change it a little But not much and its 0 to 1
dan1st
dan1st10mo ago
it isn't a value between 0 and 1
The Typhothanian
The TyphothanianOP10mo ago
It says no if I do 10 Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Requested value 10.0 exceeds allowable maximum value 1.0. at java.desktop/javax.sound.sampled.FloatControl.setValue(FloatControl.java:199) at java.desktop/com.sun.media.sound.DirectAudioDevice$DirectDL$Pan.setValueImpl(DirectAudioDevice.java:873) at java.desktop/com.sun.media.sound.DirectAudioDevice$DirectDL$Pan.setValue(DirectAudioDevice.java:868) at net.typho.utils.resources.AudioFile.play(AudioFile.java:43)
dan1st
dan1st10mo ago
oh ok maybe use one of the other controls?
The Typhothanian
The TyphothanianOP10mo ago
well balance works as well but they don't change anything balance is also 0-1 pan and balance allow me to do before starting it but volume still nope hmm?
dan1st
dan1st10mo ago
I don't know, that's why I didn't respond
The Typhothanian
The TyphothanianOP10mo ago
me neither
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server