Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting volume with java

Tags:

java

audio

volume

Good day!

I'm developing an application that plays a MIDI. It plays fine, but I often get quasi-bug reports: 'there is no sound playd'. The answer is always, to enter into volume controller and turn the synthesizer sound on (make it not muted).

The question is - how to change it automatically - by software? Till now I can only change the master volume and I couldn't really anywhere find how to change only for 'wave' 'SW synthesizer' etc...

I'm generally looking for platform indenpendent solutions (pure java), however solution only for Windows (all sorts of windows) are also welcomed ;) Thank you ahead!

Edit: Well, looking at the answers, I see, I should specify my question better. I append image. The control selected with green is what I can already do (i.e. as Cliff linked) however I need something for controls in red (the most important in my case is the 3rd from the left - synthesizer volume). Image is taken from win XP, but other operating systems (linux also) have similar controls. Java has to have such possibility. alt text

like image 464
parvuselephantus Avatar asked Nov 25 '10 18:11

parvuselephantus


People also ask

How can you change the system volume?

To access it, open the Control Panel, and go to Hardware and Sound. Then, in the Sound section, click or tap the “Adjust system volume” link. Use the Volume Mixer window that pops up to set the desired sound level for the speakers, system sounds, or any open Windows apps.

Can you play sounds in Java?

Java API Support for MP3 Format. Currently, both Clip and SourceDataLine can play audio files in AIFC, AIFF, AU, SND, and WAV formats. We can check the supported audio format using AudioSystem: Type[] list = AudioSystem.


1 Answers

I've looked in Ubuntu, Fedora, and Windows and the only commonalities across these OS's is the master volume and the alert (or "beep" on Windows) volume. This leads me to believe that there is no platform-independent way of doing this, meaning no standard Java way.

That being said, there is most likely APIs (probably different) for all of these OS's which allow you to control these finer-grain settings. If so, it will almost definitely require separate Java libraries for interacting with these APIs on each platform.

Sorry I can't point you in the right direction but I am hoping to at least help you eliminate the possibility of having a standardized way of doing this function. Good luck!

like image 130
Jesse Webb Avatar answered Oct 06 '22 20:10

Jesse Webb