本文整理匯總了Java中javax.sound.sampled.Mixer類的典型用法代碼示例。如果您正苦於以下問題:Java Mixer類的具體用法?Java Mixer怎麽用?Java Mixer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Mixer類屬於javax.sound.sampled包,在下文中一共展示了Mixer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMixer
import javax.sound.sampled.Mixer; //導入依賴的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;
}
示例2: getMixer
import javax.sound.sampled.Mixer; //導入依賴的package包/類
public Mixer getMixer(Info info) {
if (!(info == null || info == SoftMixingMixer.info)) {
throw new IllegalArgumentException("Mixer " + info.toString()
+ " not supported by this provider.");
}
synchronized (mutex) {
if (lockthread != null)
if (Thread.currentThread() == lockthread)
throw new IllegalArgumentException("Mixer "
+ info.toString()
+ " not supported by this provider.");
if (globalmixer == null)
globalmixer = new SoftMixingMixer();
return globalmixer;
}
}
示例3: getMixer
import javax.sound.sampled.Mixer; //導入依賴的package包/類
public Mixer getMixer(Mixer.Info info) {
synchronized (DirectAudioDeviceProvider.class) {
// if the default device is asked, we provide the mixer
// with SourceDataLine's
if (info == null) {
for (int i = 0; i < infos.length; i++) {
Mixer mixer = getDevice(infos[i]);
if (mixer.getSourceLineInfo().length > 0) {
return mixer;
}
}
}
// otherwise get the first mixer that matches
// the requested info object
for (int i = 0; i < infos.length; i++) {
if (infos[i].equals(info)) {
return getDevice(infos[i]);
}
}
}
throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider.");
}
示例4: main
import javax.sound.sampled.Mixer; //導入依賴的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");
}
}
示例5: getMixer
import javax.sound.sampled.Mixer; //導入依賴的package包/類
@Override
public Mixer getMixer(Mixer.Info info) {
synchronized (DirectAudioDeviceProvider.class) {
// if the default device is asked, we provide the mixer
// with SourceDataLine's
if (info == null) {
for (int i = 0; i < infos.length; i++) {
Mixer mixer = getDevice(infos[i]);
if (mixer.getSourceLineInfo().length > 0) {
return mixer;
}
}
}
// otherwise get the first mixer that matches
// the requested info object
for (int i = 0; i < infos.length; i++) {
if (infos[i].equals(info)) {
return getDevice(infos[i]);
}
}
}
throw new IllegalArgumentException(
String.format("Mixer %s not supported by this provider", info));
}
示例6: getMixer
import javax.sound.sampled.Mixer; //導入依賴的package包/類
@Override
public Mixer getMixer(Info info) {
if (!(info == null || info == SoftMixingMixer.info)) {
throw new IllegalArgumentException("Mixer " + info.toString()
+ " not supported by this provider.");
}
synchronized (mutex) {
if (lockthread != null)
if (Thread.currentThread() == lockthread)
throw new IllegalArgumentException("Mixer "
+ info.toString()
+ " not supported by this provider.");
if (globalmixer == null)
globalmixer = new SoftMixingMixer();
return globalmixer;
}
}
示例7: AbstractMixer
import javax.sound.sampled.Mixer; //導入依賴的package包/類
/**
* Constructs a new AbstractMixer.
* @param mixerInfo the mixer with which this line is associated
* @param controls set of supported controls
*/
protected AbstractMixer(Mixer.Info mixerInfo,
Control[] controls,
Line.Info[] sourceLineInfo,
Line.Info[] targetLineInfo) {
// Line.Info, AbstractMixer, Control[]
super(new Line.Info(Mixer.class), null, controls);
// setup the line part
this.mixer = this;
if (controls == null) {
controls = new Control[0];
}
// setup the mixer part
this.mixerInfo = mixerInfo;
this.sourceLineInfo = sourceLineInfo;
this.targetLineInfo = targetLineInfo;
}
示例8: isSoundcardInstalled
import javax.sound.sampled.Mixer; //導入依賴的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;
}
示例9: isSoundcardInstalled
import javax.sound.sampled.Mixer; //導入依賴的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;
}
示例10: main
import javax.sound.sampled.Mixer; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
if (isSoundcardInstalled()) {
bais.mark(0);
run(null);
Mixer.Info[] infos = AudioSystem.getMixerInfo();
for (int i = 0; i<infos.length; i++) {
try {
Mixer m = AudioSystem.getMixer(infos[i]);
run(m);
} catch (Exception e) {
}
}
if (success > 0) {
out("No crash -> Test passed");
} else {
System.err.println("Test could not execute: please install an audio device");
}
}
}
示例11: isSoundcardInstalled
import javax.sound.sampled.Mixer; //導入依賴的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;
}
示例12: main
import javax.sound.sampled.Mixer; //導入依賴的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");
}
}
示例13: testMixers
import javax.sound.sampled.Mixer; //導入依賴的package包/類
private static boolean testMixers(Mixer.Info[] infos,
String providerClassName) {
boolean allOk = true;
for (int i = 0; i < infos.length; i++) {
Mixer mixer = null;
try {
mixer = AudioSystem.getMixer(infos[i]);
} catch (NullPointerException e) {
out("Exception thrown; Test NOT failed.");
e.printStackTrace();
}
for (int j = 0; j < lineClasses.length; j++) {
if (mixer.isLineSupported(new Line.Info(lineClasses[j]))) {
allOk &= testMixer(mixer, lineClasses[j],
providerClassName);
}
}
}
return allOk;
}
示例14: doMixerClip
import javax.sound.sampled.Mixer; //導入依賴的package包/類
private static void doMixerClip(Mixer mixer, AudioFormat format) {
if (mixer==null) return;
try {
System.out.println("Clip from mixer "+mixer+":");
System.out.println(" "+mixer.getMixerInfo());
DataLine.Info info = new DataLine.Info(
Clip.class,
format);
if (mixer.isLineSupported(info)) {
Clip clip = (Clip) mixer.getLine(info);
doLine1(clip, format);
} else {
System.out.println(" - Line not supported");
}
} catch (Throwable t) {
System.out.println(" - Caught exception. Not failed.");
System.out.println(" - "+t.toString());
}
}
示例15: doMixerSDL
import javax.sound.sampled.Mixer; //導入依賴的package包/類
private static void doMixerSDL(Mixer mixer, AudioFormat format) {
if (mixer==null) return;
try {
System.out.println("SDL from mixer "+mixer+":");
DataLine.Info info = new DataLine.Info(
SourceDataLine.class,
format);
if (mixer.isLineSupported(info)) {
SourceDataLine sdl = (SourceDataLine) mixer.getLine(info);
doLine1(sdl, format);
doLine2(sdl, format);
} else {
System.out.println(" - Line not supported");
}
} catch (Throwable t) {
System.out.println(" - Caught exception. Not failed.");
System.out.println(" - "+t.toString());
}
}