Search in sources :

Example 1 with CompoundControl

use of javax.sound.sampled.CompoundControl in project Spark by igniterealtime.

the class JavaMixer method main.

public static void main(String[] args) {
    final JavaMixer sm = new JavaMixer();
    final JFrame jf = new JFrame("Mixer Test");
    final JPanel jp = new JPanel();
    jf.add(jp);
    jp.add(sm.getTree());
    jf.setSize(600, 500);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    sm.getTree().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            if (path.getLastPathComponent() instanceof JavaMixer.ControlNode) {
                JavaMixer.ControlNode controlNode = (JavaMixer.ControlNode) path.getLastPathComponent();
                if (!(controlNode.getControl() instanceof CompoundControl)) {
                    if (jp.getComponentCount() > 1)
                        jp.remove(1);
                    jp.add(controlNode.getComponent(), 1);
                    jp.repaint();
                }
            }
        }
    });
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedInputVolume());
    jp.repaint();
    sm.setMicrophoneInput();
    sm.setMuteForMicrophoneOutput();
}
Also used : JPanel(javax.swing.JPanel) CompoundControl(javax.sound.sampled.CompoundControl) TreePath(javax.swing.tree.TreePath) JFrame(javax.swing.JFrame) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 2 with CompoundControl

use of javax.sound.sampled.CompoundControl in project Spark by igniterealtime.

the class JavaMixer method createControlChildren.

private void createControlChildren(JavaMixer.ControlNode controlNode) {
    if (controlNode.getControl() instanceof CompoundControl) {
        CompoundControl control = (CompoundControl) controlNode.getControl();
        Control[] aControls = control.getMemberControls();
        for (Control con : aControls) {
            JavaMixer.ControlNode conNode = new JavaMixer.ControlNode(con);
            createControlChildren(conNode);
            controlNode.add(conNode);
        }
    }
}
Also used : CompoundControl(javax.sound.sampled.CompoundControl) BooleanControl(javax.sound.sampled.BooleanControl) FloatControl(javax.sound.sampled.FloatControl) CompoundControl(javax.sound.sampled.CompoundControl) Control(javax.sound.sampled.Control) EnumControl(javax.sound.sampled.EnumControl)

Aggregations

CompoundControl (javax.sound.sampled.CompoundControl)2 BooleanControl (javax.sound.sampled.BooleanControl)1 Control (javax.sound.sampled.Control)1 EnumControl (javax.sound.sampled.EnumControl)1 FloatControl (javax.sound.sampled.FloatControl)1 JFrame (javax.swing.JFrame)1 JPanel (javax.swing.JPanel)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 TreePath (javax.swing.tree.TreePath)1