find Audio Control - Java javax.sound.sampled

Java examples for javax.sound.sampled:Audio

Description

find Audio Control

Demo Code


//package com.java2s;

import javax.sound.sampled.CompoundControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.Control.Type;

public class Main {
    private static Control findControl(Type type, Control... controls) {
        if (controls == null || controls.length == 0)
            return null;
        for (Control control : controls) {
            if (control.getType().equals(type))
                return control;
            if (control instanceof CompoundControl) {
                CompoundControl compoundControl = (CompoundControl) control;
                Control member = findControl(type,
                        compoundControl.getMemberControls());
                if (member != null)
                    return member;
            }/*from  w w  w.j  a  v  a2  s.  c  o m*/
        }
        return null;
    }
}

Related Tutorials