本文整理匯總了Java中javax.sound.sampled.Control.Type方法的典型用法代碼示例。如果您正苦於以下問題:Java Control.Type方法的具體用法?Java Control.Type怎麽用?Java Control.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.sampled.Control
的用法示例。
在下文中一共展示了Control.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printControls
import javax.sound.sampled.Control; //導入方法依賴的package包/類
/** @invisible
*
* Prints the available controls and their ranges to the console. Not all
* Controllers have all of the controls available on them so this is a way to find
* out what is available.
*
*/
public void printControls()
{
if (controls.length > 0)
{
System.out.println("Available controls are:");
for (int i = 0; i < controls.length; i++)
{
Control.Type type = controls[i].getType();
System.out.print(" " + type.toString());
if (type == VOLUME || type == GAIN || type == BALANCE || type == PAN)
{
FloatControl fc = (FloatControl) controls[i];
String shiftSupported = "does";
if (fc.getUpdatePeriod() == -1)
{
shiftSupported = "doesn't";
}
System.out.println(", which has a range of " + fc.getMaximum() + " to "
+ fc.getMinimum() + " and " + shiftSupported
+ " support shifting.");
}
else
{
System.out.println("");
}
}
}
else
{
System.out.println("There are no controls available.");
}
}
示例2: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
@Deprecated
public Control getControl(Control.Type type)
{
for(int i = 0; i < controls.length; i++)
{
if ( controls[i].getType().equals(type) )
{
return controls[i];
}
}
return null;
}
示例3: isControlSupported
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public final boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
return false;
}
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return true;
}
}
return false;
}
示例4: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public final Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return controls[i];
}
}
}
throw new IllegalArgumentException("Unsupported control type: " + controlType);
}
示例5: isControlSupported
import javax.sound.sampled.Control; //導入方法依賴的package包/類
@Override
public final boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
return false;
}
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return true;
}
}
return false;
}
示例6: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
@Override
public final Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return controls[i];
}
}
}
throw new IllegalArgumentException("Unsupported control type: " + controlType);
}
示例7: main
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception {
System.out.println();
System.out.println();
System.out.println("4629190: CompoundControl: getMemberControls() and toString() throw NullPointerException");
String firstControlTypeName = "first_Control_Type_Name";
String secondControlTypeName = "second_Control_Type_Name";
String thirdControlTypeName = "third_Control_Type_Name";
Control.Type firstControlType = new TestControlType(firstControlTypeName);
Control.Type secondControlType = new TestControlType(secondControlTypeName);
Control.Type thirdControlType = new TestControlType(thirdControlTypeName);
Control firstControl = new TestControl(firstControlType);
Control secondControl = new TestControl(secondControlType);
Control thirdControl = new TestControl(thirdControlType);
String testCompoundControlTypeName = "CompoundControl_Type_Name";
CompoundControl.Type testCompoundControlType
= new TestCompoundControlType(testCompoundControlTypeName);
Control[] setControls = { firstControl, secondControl, thirdControl };
CompoundControl testedCompoundControl
= new TestCompoundControl(testCompoundControlType, setControls);
// this may throw exception if bug applies
Control[] producedControls = testedCompoundControl.getMemberControls();
System.out.println("Got "+producedControls.length+" member controls.");
// this may throw exception if bug applies
String producedString = testedCompoundControl.toString();
System.out.println("toString() returned: "+producedString);
System.out.println("Test passed.");
}
示例8: isControlSupported
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
return false;
}
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return true;
}
}
return false;
}
示例9: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
for (int i = 0; i < controls.length; i++) {
if (controlType == controls[i].getType()) {
return controls[i];
}
}
}
throw new IllegalArgumentException("Unsupported control type: " + controlType);
}
示例10: printControls
import javax.sound.sampled.Control; //導入方法依賴的package包/類
/** @invisible
*
* Prints the available controls and their ranges to the console. Not all
* lines have all of the controls available on them so this is a way to find
* out what is available.
*
*/
public void printControls()
{
if (controls.length > 0)
{
System.out.println("Available controls are:");
for (int i = 0; i < controls.length; i++)
{
Control.Type type = controls[i].getType();
System.out.print(" " + type.toString());
if (type == VOLUME || type == GAIN || type == BALANCE || type == PAN)
{
FloatControl fc = (FloatControl) controls[i];
String shiftSupported = "does";
if (fc.getUpdatePeriod() == -1)
{
shiftSupported = "doesn't";
}
System.out.println(", which has a range of " + fc.getMaximum() + " to "
+ fc.getMinimum() + " and " + shiftSupported
+ " support shifting.");
}
else
{
System.out.println("");
}
}
}
else
{
System.out.println("There are no controls available for this line.");
}
}
示例11: rawplay
import javax.sound.sampled.Control; //導入方法依賴的package包/類
private void rawplay(AudioFormat trgFormat, AudioInputStream ain, float volume)
throws IOException, LineUnavailableException {
byte[] data = new byte[8192];
try {
clip = getLine(ain, trgFormat);
if (clip == null) {
return;
}
Control.Type vol1 = FloatControl.Type.VOLUME, vol2 = FloatControl.Type.MASTER_GAIN;
FloatControl c = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
float min = c.getMinimum();
float v = volume * (c.getMaximum() - min) / 100f + min;
if (this.clip.isControlSupported(vol1)) {
FloatControl volumeControl = (FloatControl) this.clip.getControl(vol1);
volumeControl.setValue(v);
} else if (this.clip.isControlSupported(vol2)) {
FloatControl gainControl = (FloatControl) this.clip.getControl(vol2);
gainControl.setValue(v);
}
clip.start();
int nBytesRead = 0;
while (isRunning && (nBytesRead != -1)) {
nBytesRead = ain.read(data, 0, data.length);
if (nBytesRead != -1) {
clip.write(data, 0, nBytesRead);
}
}
} finally {
clip.drain();
clip.stop();
clip.close();
ain.close();
}
}
示例12: TestControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
TestControl(Control.Type type) {
super(type);
}
示例13: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public Control getControl(Control.Type control) {
return null;
}
示例14: isControlSupported
import javax.sound.sampled.Control; //導入方法依賴的package包/類
public boolean isControlSupported(Control.Type control) {
return false;
}
示例15: getControl
import javax.sound.sampled.Control; //導入方法依賴的package包/類
@Override public Control getControl (Control.Type control)
{
return dataLine.getControl(control);
}