本文整理汇总了Java中javax.sound.sampled.AudioSystem.getMixerInfo方法的典型用法代码示例。如果您正苦于以下问题:Java AudioSystem.getMixerInfo方法的具体用法?Java AudioSystem.getMixerInfo怎么用?Java AudioSystem.getMixerInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.AudioSystem
的用法示例。
在下文中一共展示了AudioSystem.getMixerInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out("4936397: Verify that there'll for a given endianness, there's also the little endian version");
out(" and the same for signed'ness for 8-bit formats");
Mixer.Info[] aInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < aInfos.length; i++) {
try {
Mixer mixer = AudioSystem.getMixer(aInfos[i]);
out("Mixer "+aInfos[i]);
checkLines(mixer, mixer.getSourceLineInfo());
checkLines(mixer, mixer.getTargetLineInfo());
} catch (Exception e) {
out("Unexpected exception when getting a mixer: "+e);
}
}
if (testedFormats == 0) {
out("[No appropriate lines available] - cannot exercise this test.");
} else {
if (failed) {
throw new Exception("Test FAILED!");
}
out("Test passed");
}
}
示例2: isSoundcardInstalled
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Returns true if at least one soundcard is correctly installed
* on the system.
*/
public static boolean isSoundcardInstalled() {
boolean result = false;
try {
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
if (mixers.length > 0) {
result = AudioSystem.getSourceDataLine(null) != null;
}
} catch (Exception e) {
System.err.println("Exception occured: "+e);
}
if (!result) {
System.err.println("Soundcard does not exist or sound drivers not installed!");
System.err.println("This test requires sound drivers for execution.");
}
return result;
}
示例3: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Mixer.Info[] infos = AudioSystem.getMixerInfo();
log("" + infos.length + " mixers detected");
for (int i=0; i<infos.length; i++) {
Mixer mixer = AudioSystem.getMixer(infos[i]);
log("Mixer " + (i+1) + ": " + infos[i]);
try {
mixer.open();
for (Scenario scenario: scenarios) {
testSDL(mixer, scenario);
testTDL(mixer, scenario);
}
mixer.close();
} catch (LineUnavailableException ex) {
log("LineUnavailableException: " + ex);
}
}
if (failed == 0) {
log("PASSED (" + total + " tests)");
} else {
log("FAILED (" + failed + " of " + total + " tests)");
throw new Exception("Test FAILED");
}
}
示例4: getMixers
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Returns all available mixers.
*
* @return A List of available Mixers
*/
public List<String> getMixers() {
List<String> mixers = new ArrayList<>();
// Obtains an array of mixer info objects that represents the set of
// audio mixers that are currently installed on the system.
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
if (mixerInfos != null)
Arrays.stream(mixerInfos).forEach(mInfo -> {
// line info
Line.Info lineInfo = new Line.Info(SourceDataLine.class);
Mixer mixer = AudioSystem.getMixer(mInfo);
// if line supported
if (mixer.isLineSupported(lineInfo))
mixers.add(mInfo.getName());
});
return mixers;
}
示例5: isSoundcardInstalled
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Returns true if at least one soundcard is correctly installed
* on the system.
*/
public static boolean isSoundcardInstalled() {
boolean result = false;
try {
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
if (mixers.length > 0) {
result = AudioSystem.getSourceDataLine(null) != null;
}
} catch (Exception e) {
System.err.println("Exception occured: " + e);
}
if (!result) {
System.err.println(
"Soundcard does not exist or sound drivers not installed!");
System.err.println(
"This test requires sound drivers for execution.");
}
return result;
}
示例6: isSoundcardInstalled
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Returns true if at least one soundcard is correctly installed
* on the system.
*/
public static boolean isSoundcardInstalled() {
boolean result = false;
try {
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
if (mixers.length > 0) {
result = AudioSystem.getSourceDataLine(null) != null;
}
} catch (Exception e) {
System.err.println("Exception occured: "+e);
}
if (!result) {
System.err.println("Soundcard does not exist or sound drivers not installed!");
System.err.println("This test requires sound drivers for execution.");
}
return result;
}
示例7: getMixer
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Returns the mixer with this name.
*
* @param name
* the name
* @return The Mixer with that name
*/
private Mixer getMixer(String name) {
Mixer mixer = null;
// Obtains an array of mixer info objects that represents the set of
// audio mixers that are currently installed on the system.
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
if (name != null && mixerInfos != null)
for (int i = 0; i < mixerInfos.length; i++)
if (mixerInfos[i].getName().equals(name)) {
mixer = AudioSystem.getMixer(mixerInfos[i]);
break;
}
return mixer;
}
示例8: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean allOk = true;
Mixer.Info[] infos;
out("Testing Mixers retrieved via AudioSystem");
infos = AudioSystem.getMixerInfo();
allOk &= testMixers(infos, null);
out("Testing MixerProviders");
List providers = JDK13Services.getProviders(MixerProvider.class);
for (int i = 0; i < providers.size(); i++) {
MixerProvider provider = (MixerProvider) providers.get(i);
infos = provider.getMixerInfo();
allOk &= testMixers(infos, provider.getClass().getName());
}
if (! allOk) {
throw new Exception("Test failed");
} else {
out("Test passed");
}
}
示例9: getSelectedMixer
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
/**
* Gets the Mixer to use. Depends upon selectedMixerIndex being defined.
*
* @see #newProperties
*/
private Mixer getSelectedMixer() {
if (selectedMixerIndex.equals("default")) {
return null;
} else {
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
if (selectedMixerIndex.equals("last")) {
return AudioSystem.getMixer(mixerInfo[mixerInfo.length - 1]);
} else {
int index = Integer.parseInt(selectedMixerIndex);
return AudioSystem.getMixer(mixerInfo[index]);
}
}
}
示例10: ListAudioInputDevices
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public List<String> ListAudioInputDevices() {
List<String> returnList = new ArrayList<String>();
mixerInfo = AudioSystem.getMixerInfo();
System.out.println("Available mixers:");
for (int cnt = 0; cnt < mixerInfo.length; cnt++) {
Mixer currentMixer = AudioSystem.getMixer(mixerInfo[cnt]);
// Because this is for a recording application, we only care about
// audio INPUT so we just
// care if TargetDataLine is supported.
// currentMixer.isLineSupported(targetDLInfo) &&
// currentMixer.isLineSupported(portInfo)
if (currentMixer.isLineSupported(targetDLInfo)) {
// if( currentMixer.isLineSupported(portInfo) ) {
System.out.println("mixer name: " + mixerInfo[cnt].getName() + " index:" + cnt);
returnList.add(mixerInfo[cnt].getName());
// }
}
}
// Save the valid list of mixers
SavedValidRecordingDevList = returnList;
// Automatically start listening on the first item
// StartMonitoringLevelsOnMixer(returnList.get(0));
return returnList;
}
示例11: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String argv[]) throws Exception {
boolean success = true;
Mixer.Info [] infos = AudioSystem.getMixerInfo();
for (int i=0; i<infos.length; i++) {
Mixer mixer = AudioSystem.getMixer(infos[i]);
System.out.println("Mixer is: " + mixer);
Line.Info [] target_line_infos = mixer.getTargetLineInfo();
for (int j = 0; j < target_line_infos.length; j++) {
try {
System.out.println("Trying to get:" + target_line_infos[j]);
mixer.getLine(target_line_infos[j]);
} catch (IllegalArgumentException iae) {
System.out.println("Unexpected IllegalArgumentException raised:");
iae.printStackTrace();
success = false;
} catch (LineUnavailableException lue) {
System.out.println("Unexpected LineUnavailableException raised:");
lue.printStackTrace();
success = false;
}
}
}
if (success) {
System.out.println("Test passed");
} else {
throw new Exception("Test FAILED");
}
}
示例12: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (isSoundcardInstalled()) {
bais.mark(0);
Mixer.Info[] infos = AudioSystem.getMixerInfo();
for (int sleep = 0; sleep < 100; ++sleep) {
run(null, sleep);
for (int i = 0; i < infos.length; i++) {
try {
Mixer m = AudioSystem.getMixer(infos[i]);
run(m, sleep);
} catch (Exception e) {
}
}
}
out("Waiting 1 second to dispose of all threads");
Thread.sleep(1000);
if (getClipThreadCount() > 0) {
out("Unused clip threads exist! Causes test failure");
failed = true;
}
if (failed) throw new Exception("Test FAILED!");
if (success > 0) {
out("Test passed.");
} else {
System.err.println("Test could not execute: please install an audio device");
}
}
}
示例13: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean res=true;
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
System.out.println(mixerInfo.length+" mixers on system.");
if (mixerInfo.length == 0) {
System.out.println("Cannot execute test. Not Failed!");
} else {
for (int i = 0; i < mixerInfo.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
System.out.println();
System.out.println(mixer+":");
showMixerLines(mixer.getSourceLineInfo());
showMixerLines(mixer.getTargetLineInfo());
}
res=ok16 && ok32;
}
if (res) {
System.out.println("Test passed");
} else {
System.out.println("Test failed");
throw new Exception("Test failed");
}
//ystem.exit(res?0:1);
}
示例14: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (isSoundcardInstalled()) {
int res=0;
int count = 0;
Mixer.Info[] infos = AudioSystem.getMixerInfo();
for (int i = -1; i<infos.length; i++) {
try {
Mixer m;
if (i == -1) {
m = null;
} else {
m = AudioSystem.getMixer(infos[i]);
}
int r = run(m, AudioSystem.NOT_SPECIFIED);
// only continue if successful
if (r == 0) {
count++;
r = run(m, -2);
if (r == 1) {
// only fail if IAE was thrown
System.out.println("#FAILED: using -2 for buffer size does not work!");
res = 1;
}
}
} catch (Exception e) {
}
}
if (res!=1) {
System.out.println("Test passed");
} else {
if (count == 0) {
System.err.println("Test could not execute -- no suitable mixers installed. NOT failed");
}
throw new Exception("Test FAILED!");
}
}
}
示例15: main
import javax.sound.sampled.AudioSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
println("This is an interactive test for DirectAudio.");
println("If it's impossible to play data after an underun, the test fails.");
println("");
println("Make sure that you have speakers connected");
println("and that the system mixer is not muted.");
println("Also stop all other programs playing sounds:");
println("It has been seen that it alters the results.");
println("");
println("Press a key to start the test.");
key();
Mixer.Info[] mixers=null;
println(" ...using self-generated sine wave for playback");
audioFormat = new AudioFormat((float)sampleRate, 8, 1, true, true);
for (int i=0; i<audioData.length; i++) {
audioData[i] = (byte)(Math.sin(RAD*frequency/sampleRate*i)*127.0);
}
info = new DataLine.Info(SourceDataLine.class, audioFormat);
mixers = AudioSystem.getMixerInfo();
int succMixers = 0;
for (int i=0; i<mixers.length; i++) {
println(""+mixers[i]+":");
if ((mixers[i].getName()+mixers[i].getDescription()+mixers[i].getVendor()).indexOf("Direct") < 0) {
println(" ->not a DirectAudio Mixer!");
} else {
try {
Mixer mixer = AudioSystem.getMixer(mixers[i]);
if (!mixer.isLineSupported(info)) {
println(" ->doesn't support SourceDataLine!");
} else {
succMixers++;
println(" -> is getting tested.");
play(mixer);
}
} catch (Exception e) {
println(" -> Exception occured: "+e);
e.printStackTrace();
}
}
}
if (succMixers == 0) {
println("No DirectAudio mixers available! ");
println("Cannot run test.");
}
}