# Get Mic Output Volume?

**URL:** <https://discourse.processing.org/t/get-mic-output-volume/41181>\
**Category:** Project Guidance\
**Created:** [March 7, 2023, 1:15pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181 "2023-03-07T13:15:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aryszin](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Post date:** [March 7, 2023, 1:15pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/1 "2023-03-07T13:15:21Z")

</div>

Can i get the microphone output volume, only the volume without a library? Arys

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [March 7, 2023, 4:57pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/2 "2023-03-07T16:57:32Z")

</div>

Hi @Aryszin,

You can use the java audio (Mixer Controls) if you not want to use any further library:

> **[AudioSystem (Java SE 19 & JDK 19)](https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/javax/sound/sampled/AudioSystem.html)**
>
> declaration: module: java.desktop, package: javax.sound.sampled, class: AudioSystem

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![Aryszin](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Post date:** [March 11, 2023, 2:37pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/3 "2023-03-11T14:37:00Z")

</div>

can you mabye make an example?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [March 12, 2023, 10:18am UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/4 "2023-03-12T10:18:21Z")

</div>

Hi @Aryszin,

Actually that’s not really a processing topic, but I don’t want to be too picky. 😉  
Below you find a code that should print out all available mixers for your system and their corresponding controls for it and the possible values the control can have.  
_(you are looking for s.th … like Master Gain/Float)_  
For detailed information about the meaning of the possible values look at the AudioSystem reference above.

Hope that helps…

Cheers  
— mnse

```auto
import javax.sound.sampled.*;
import javax.sound.sampled.Control.*;

void setup() {
  getSurface().setVisible(false);
  for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
    println("_".repeat(80));
    println("> [Mixer]: " + mi);
    Mixer mixer = AudioSystem.getMixer(mi);
    Line.Info[] srclineInfo = mixer.getSourceLineInfo();
    if (srclineInfo.length > 0) {
      for (Line.Info li : srclineInfo) {
        handleLine(mixer, li, "SourceLine");
      }
    } else {
      println(">> [SourceLine]: No SourceLine(s) provided");
    }
    println("");
    Line.Info[] tgtlineInfo = mixer.getTargetLineInfo();
    if (tgtlineInfo.length > 0) {
      for (Line.Info li : tgtlineInfo) {
        handleLine(mixer, li, "TargetLine");
      }
    } else {
      println(">> [TargetLine]: No TargetLine(s) provided");
    }
  }
  exit();
}

void handleLine(Mixer mixer, Line.Info lineInfo, String addonInfo) {
  try {
    println(">> ["+addonInfo+"]: " + lineInfo);
    Line l = mixer.getLine(lineInfo);
    try {
      l.open();
      Control[] ctrls = l.getControls();
      if (ctrls.length > 0) {
        for (Control ctrl : ctrls) {
          handleControl(ctrl, 3);
        }
      } else {
        println(">> ["+addonInfo+"]: No Controls(s) provided");
      }
      l.close();
    }
    catch(Exception e) {
      println(">> ["+addonInfo+"]: No Controls(s) provided");
    }
  }
  catch(Exception e) {
    println(">> ["+addonInfo+"]: no acces to Line:" + e);
  }
}

void handleControl(Control c, int d) {
  String prefix = ">".repeat(d);
  if (c instanceof BooleanControl) {
    BooleanControl b = (BooleanControl)c;
    println(prefix + " ["+b.getType()+"/Boolean]: " + b);
  } else if (c instanceof EnumControl) {
    EnumControl e = (EnumControl)c;
    println(prefix + " ["+e.getType()+"/Enum]: " + e);
  } else if (c instanceof FloatControl) {
    FloatControl f = (FloatControl)c;
    println(prefix + " ["+f.getType()+"/Float]: " + f);
  } else if (c instanceof CompoundControl) {
    CompoundControl cc = (CompoundControl)c;
    println(prefix + " ["+cc.getType()+"/Compound]: " + cc);
    for (Control ctrl : cc.getMemberControls()) {
      handleControl(ctrl, 4);
    }
  } else
    println(prefix + " [UnknownControl]: " + c);
}

```

Should print out s.th like the below …

```auto

________________________________________________________________________________
> [Mixer]: Port Lautsprecher (XXXXX SOUND CARD), version 10.0
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: SPEAKER target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [CD-Audio/Compound]: CD-Audio control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port G27F (XXXXXX High Definition Au, version 10.0
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [CD-Audio/Compound]: CD-Audio control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port G27F (XXXXXX High Definition Au, version 10.0
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [CD-Audio/Compound]: CD-Audio control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port SPDIF Out (XXXXX SOUND CARD), version 10.0
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [CD-Audio/Compound]: CD-Audio control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port Lautsprecher (XXXXX Wireless, version 118.87
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: SPEAKER target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [CD-Audio/Compound]: CD-Audio control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port Mikrofon (XXXXX SOUND CARD), version 10.0
>> [SourceLine]: MICROPHONE source port
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port Mikrofon (XXXXX Wireless Hea, version 118.87
>> [SourceLine]: MICROPHONE source port
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 0.8235294 (range: 0.0 - 1.0)

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 0.8235294 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 0.8235294 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port Line (XXXXX SOUND CARD), version 10.0
>> [SourceLine]: LINE_IN source port
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 1.0 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Port Mikrofon (XXXXX Webcam), version 3.23
>> [SourceLine]: MICROPHONE source port
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 0.76469064 (range: 0.0 - 1.0)

>> [TargetLine]: Master Volume target port
>>> [Mute/Boolean]: Mute control with current value: false
>>> [Volume/Float]: Volume control with current value: 0.76469064 (range: 0.0 - 1.0)
>>> [Master Volume/Compound]: Master Volume control containing [Mute, Volume] controls
>>>> [Mute/Boolean]: Mute control with current value: false
>>>> [Volume/Float]: Volume control with current value: 0.76469064 (range: 0.0 - 1.0)
________________________________________________________________________________
> [Mixer]: Primärer Soundtreiber, version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: Lautsprecher (XXXXX SOUND CARD), version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: G27F (XXXXXX High Definition Audio), version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: G27F (XXXXXX High Definition Audio), version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: SPDIF Out (XXXXX SOUND CARD), version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: Lautsprecher (XXXXX Wireless Headset), version Unknown Version
>> [SourceLine]: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>>> [Master Gain/Float]: Master Gain control with current value: 0.0 dB (range: -80.0 - 6.0206)
>>> [Mute/Boolean]: Mute control with current value: False
>>> [Balance/Float]: Balance control with current value: 0.0 (range: -1.0 - 1.0)
>>> [Pan/Float]: Pan control with current value: 0.0 (range: -1.0 - 1.0)
>> [SourceLine]: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
>> [SourceLine]: No Controls(s) provided

>> [TargetLine]: No TargetLine(s) provided
________________________________________________________________________________
> [Mixer]: Primary sound recording driver, version Unknown Version
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: interface TargetDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>> [TargetLine]: No Controls(s) provided
________________________________________________________________________________
> [Mixer]: Mikrofon (XXXXX Webcam), version Unknown Version
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: interface TargetDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>> [TargetLine]: No Controls(s) provided
________________________________________________________________________________
> [Mixer]: Mikrofon (XXXXX SOUND CARD), version Unknown Version
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: interface TargetDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>> [TargetLine]: No Controls(s) provided
________________________________________________________________________________
> [Mixer]: Mikrofon (XXXXX Wireless Hea, version Unknown Version
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: interface TargetDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>> [TargetLine]: No Controls(s) provided
________________________________________________________________________________
> [Mixer]: Line (XXXXX SOUND CARD), version Unknown Version
>> [SourceLine]: No SourceLine(s) provided

>> [TargetLine]: interface TargetDataLine supporting 8 audio formats, and buffers of at least 32 bytes
>> [TargetLine]: No Controls(s) provided

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 12, 2023, 12:59pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/5 "2023-03-12T12:59:49Z")

</div>

@mnse great work

Hi

Can you point or provide same but for microphone frequency reading ??

Thanks in advance

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [March 12, 2023, 2:06pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/6 "2023-03-12T14:06:22Z")

</div>

Hi @jafal,

don’t want to work out but you can check here … (FFT you need to apply for yourself) 🙂

> **[Java Sound API – Capturing Microphone | Baeldung](https://www.baeldung.com/java-sound-api-capture-mic)**
>
> Learn how to capture microphone input and save it to a file.

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 12, 2023, 2:09pm UTC](https://discourse.processing.org/t/get-mic-output-volume/41181/7 "2023-03-12T14:09:17Z")

</div>

@mnse thanks 🙏🙏 Alot Sir
