participate


Java Sound - Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)
<<   Back to Forum  |   Give us Feedback
4 Duke Stars available
This topic has 6 replies on 1 page.
wr34t
Posts:10
Registered: 6/21/06
Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
Apr 26, 2007 3:52 AM

 
I woul like to adjust mixers volume such Master Volume, Wave Volume, Mixer, Microphone.
How can I do it in Java Sound API?
Thanks.
 
Plumpaquatsch
Posts:35
Registered: 1/7/99
Re: Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
May 6, 2007 5:13 AM (reply 1 of 6)  (In reply to original post )

 
The audio sytem provides special port mixers with port lines.
You have to open this lines, get the controls and adjust them.

Here is a small program which prints the current values of the controls.
It may help you to learn how to access the controls.


import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.CompoundControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.EnumControl;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Port;
 
public class MixerTest {
 
	public MixerTest() throws LineUnavailableException {
		
		Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
		for (Mixer.Info mixerInfo:mixerInfos) {
			Mixer m = AudioSystem.getMixer(mixerInfo);
			Line.Info[] lineInfos = m.getSourceLineInfo();
			for (Line.Info li:lineInfos) {
				if (li instanceof Port.Info){
					Port.Info pi=(Port.Info)li;
					Line portLine=m.getLine(pi);
					printPortControls(portLine);
				}
			}
			lineInfos = m.getTargetLineInfo();
			for (Line.Info li:lineInfos) {
				if (li instanceof Port.Info){
					if (li instanceof Port.Info){
						Port.Info pi=(Port.Info)li;
						Line portLine=m.getLine(pi);
						printPortControls(portLine);
					}
				}
			}
		}
	}
	
	private void printPortControls(Line portLine) throws LineUnavailableException{
		portLine.open();
		Control[] pCtrls=portLine.getControls();
		for(Control memberControl:pCtrls){
			printControl(memberControl);
		}
		portLine.close();
	}
 
	public void printControl(Control memberControl) {
		if (memberControl instanceof BooleanControl) {
			BooleanControl bc = (BooleanControl) memberControl;
			System.out.println(bc + ": " + bc.getValue());
		} else if (memberControl instanceof FloatControl) {
			FloatControl fc = (FloatControl) memberControl;
			System.out.println(fc + ": " + fc.getValue());
 
		} else if (memberControl instanceof EnumControl) {
			EnumControl ec = (EnumControl) memberControl;
			System.out.println(ec + ": " + ec.getValue());
		} else if (memberControl instanceof CompoundControl) {
			CompoundControl cc = (CompoundControl) memberControl;
			System.out.println(cc);
			for (Control compControl:cc.getMemberControls()) {
				printControl(compControl);
			}
		}
	}
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			new MixerTest();
		} catch (LineUnavailableException e) {
			e.printStackTrace();
		}
 
	}
}
 
dkmorb
Posts:2
Registered: 5/7/07
Re: Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
May 7, 2007 9:35 AM (reply 2 of 6)  (In reply to #1 )

 
How can I change volume for RECORDING mixer?

Thanks in advance,
Pas.
 
Plumpaquatsch
Posts:35
Registered: 1/7/99
Re: Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
May 7, 2007 1:05 PM (reply 3 of 6)  (In reply to #2 )

 
JavaSound uses the terms SourceLine for playback lines and TargetLine for recording lines. Controls of target lines are responsible for recording.
The structure of Port lines and controls is similar to the structure of the OS audio mixer, because it depends on the audio hardware.
 
dkmorb
Posts:2
Registered: 5/7/07
Re: Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
May 8, 2007 1:22 AM (reply 4 of 6)  (In reply to #3 )

 
Hey, thank you, KlausJJ... I don't now TargetLine defines recording lines.

Bye,
dkmorb.
 
Lawrence_Soft
Posts:4
Registered: 11/1/07
Voice recognition   
Nov 1, 2007 1:50 AM (reply 5 of 6)  (In reply to #4 )

 
Hi friends,

I m trying to do voice recognition by using Java. First i want to get the i/p as voice then convert into text, after that it wil be transferred to another one computer. At there it should be happened vice versa...

Anyone give me a source code for this..........


Thanx in advance..............
 
Bikash
Posts:1
Registered: 11/16/07
Re: Adjust Mixers Volume (Master, Wave, Mixer, Microphone,)   
Nov 16, 2007 12:34 AM (reply 6 of 6)  (In reply to #1 )

 
Hello all,

I am very appriciate to see the Code but i can't understand from this code can U explain about this Briefly ..
 
This topic has 6 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 129

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums