Java examples for javax.sound.sampled:Control
get sound Volume Controls
/*// w w w . j av a 2s .co m * Copyright 2013 Daniel Baumann * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ //package com.java2s; import java.util.ArrayList; import java.util.List; import javax.sound.sampled.CompoundControl; import javax.sound.sampled.Control; import javax.sound.sampled.FloatControl; import javax.sound.sampled.Line; public class Main { public static List<FloatControl> getVolumeControls(Line line) { List<FloatControl> result = new ArrayList<FloatControl>(); for (Control c : line.getControls()) { result.addAll(getVolumeControls(c)); } return result; } private static List<FloatControl> getVolumeControls(Control control) { List<FloatControl> result = new ArrayList<FloatControl>(); if (control instanceof CompoundControl) { Control[] controls = ((CompoundControl) control) .getMemberControls(); for (Control c : controls) { result.addAll(getVolumeControls(c)); } } else if (control instanceof FloatControl) { FloatControl fc = (FloatControl) control; if (fc.getType() == FloatControl.Type.VOLUME) { result.add(fc); } } return result; } }