Forum Stats

  • 3,722,431 Users
  • 2,244,306 Discussions
  • 7,849,829 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

getControl(...MUTE) throws exception

29c5fec5-d639-4e48-b3ff-9be9dfc1b335
edited February 2015 in Java Sound

Hello,

I want to control the volume of the line input of my audio card.

Here is my code:

////////////////////////////////////////

...

portMixer.open();

Port LineIn = (Port) portMixer.getLine(Port.Info.LINE_IN);

LineIn.open();

Control[] controls = LineIn.getControls();

for (i=0; i<controls.length; i++)

{

  System.out.println(controls[i].toString());

}

BooleanControl Mute = (BooleanControl) LineIn.getControl(BooleanControl.Type.MUTE);

////////////////////////////////////////

The output from the println command is:

"Hauptlautstärke Control containing Mute, and Volume Controls."

Therefore I assumed that "MUTE" or "VOLUME" should be possible for a .getControl(...) call.

But .getControl(BooleanControl.Type.MUTE) throws an exception: "Unsupported control type: Mute"

Does anybody know, why this happens?

Regards,

Uwe

P.S.:

FloatControl Vol = (FloatControl) LineIn.getControl(FloatControl.Type.VOLUME); throws the exception: "Unsupported control type: Volume"

Answers

  • PhHein
    PhHein Member, Moderator Posts: 7,147 Silver Trophy
    edited February 2015

    Hi Uwe,

    first of all I have never used the sound API, but

    Port LineIn = (Port) portMixer.getLine(Port.Info.LINE_IN);

    This is a line IN. Why should a Line IN support Volume and Mute? Have you tried this with a speaker or line OUT?

  • 29c5fec5-d639-4e48-b3ff-9be9dfc1b335
    edited February 2015

    Hi,

    I havent't tried on a speaker or Line Out.

    As I wrote, I want to control the Volume for the input.

    BTW, if the port does not support Volume or Mute, why does it claim the opposite?

    Regards,

    Uwe

  • PhHein
    PhHein Member, Moderator Posts: 7,147 Silver Trophy
    edited February 2015

    Isn't there an isSupported method or something, you could use find out before getting the exception?

  • 29c5fec5-d639-4e48-b3ff-9be9dfc1b335
    edited February 2015

    Now I have tested the output.

    With success.

    .getControls() delivers now:

    "Mute Control with current value: false

    Volume with current value: 1.0  (range: 0.0 - 1.0)

    CD-Audio Control containing Mute, and Volume Controls.

    Hauptlautstärke Control containing Mute, and Volume Controls."

    instead of just

    "Hauptlautstärke Control containing Mute, and Volume Controls."

    in the case of LINE_IN.

    (BTW "Hauptlautstärke" is german and reads "main volume" in english)

    Looks like that "Mute" or "Volume" has a single entry in the control array, if really present.

    So my assumption that "Main Volume Control containing Mute, and Volume Controls" includes mute and volume was plain wrong.

    Would be great if somebody can confirm this.

    I testted a microphone from another audio device but that also just delivers

    "Hauptlautstärke Control containing Mute, and Volume Controls."

    and nothing else(and also generates an exception on each control type I tried to get)

    ... what corroborates my hypothesis.

    Regards,

    Uwe

This discussion has been closed.