下面列出了怎么用javax.sound.sampled.Mixer.Info的API类实例代码及写法,或者点击链接到github查看源代码。
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
@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;
}
}
@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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
private void initMixer() {
Info selected;
Info[] mixerInfo = AudioSystem.getMixerInfo();
if (mixerInfo == null || mixerInfo.length == 0) {
theMixer = null;
lineAvailable = false;
System.out.println("No sound mixer is available!");
return;
}
String mixer = preferredMixer.getValue();
selected = mixerInfo[0];
for (Info i : mixerInfo) {
if (i.getName().equalsIgnoreCase(mixer)) {
selected = i;
break;
}
}
theMixer = AudioSystem.getMixer(selected);
// for (Line l : theMixer.getSourceLines()) {
// l.close();
// }
lineAvailable = true;
}
protected void firstFrame() {
// load assets
audioSample = FileUtil.fileFromPath(FileUtil.getPath("audio/kit808/snare.wav"));
// store audio lines
linesOut = new ArrayList<Line.Info>();
mixers = new ArrayList<Mixer>();
// beads
// audioContext = new AudioContext();
// audioContext.postAudioFormatInfo();
// P.out("audioContext.out.getOuts()", audioContext.out.getOuts());
// audioContext.start();
printAllMixerNames();
P.out("=============");
getDeviceInfos("");
}
@Override
public Mixer getMixer(Info info) {
if( TGMixer.MIXER_INFO.equals(info) ) {
return new TGMixer();
}
return null;
}
public List<String> getMixers() {
final ArrayList<String> mixers = new ArrayList<>();
final Mixer.Info[] mInfos = AudioSystem.getMixerInfo();
if (mInfos != null) {
for (final Info mInfo : mInfos) {
final Line.Info lineInfo = new Line.Info(SourceDataLine.class);
final Mixer mixer = AudioSystem.getMixer(mInfo);
if (mixer.isLineSupported(lineInfo)) {
mixers.add(mInfo.getName());
}
}
}
return mixers;
}
public Mixer getMixer(final String name) {
Mixer mixer = null;
if (name != null) {
final Mixer.Info[] mInfos = AudioSystem.getMixerInfo();
if (mInfos != null) {
for (final Info mInfo : mInfos) {
if (mInfo.getName().equals(name)) {
mixer = AudioSystem.getMixer(mInfo);
break;
}
}
}
}
return mixer;
}
@Override
public LinkedHashMap<? extends String, String> getSelections() {
Info[] mixerInfo = AudioSystem.getMixerInfo();
LinkedHashMap<String, String> out = new LinkedHashMap<>();
for (Info i : mixerInfo) {
out.put(i.getName(), i.getName());
}
return out;
}
protected void printAllMixerNames() {
for(Mixer.Info info : AudioSystem.getMixerInfo()) {
P.out(info.getName(), " - ", info.getDescription());
Mixer m = AudioSystem.getMixer(info);
mixers.add(m);
UI.addButton(info.getName(), false);
}
}
protected void buildLinesFromCurMixer() {
Line.Info[] sourceInfos = curMixer().getSourceLineInfo();
for (int s = 0; s < sourceInfos.length; s++) {
P.out("=========================");
Line.Info lineInfo = sourceInfos[s];
linesOut.add(lineInfo);
P.out(" info: " + lineInfo);
try {
Line line = AudioSystem.getLine(lineInfo);
if (line instanceof SourceDataLine) {
Arrays.asList(((DataLine.Info) line.getLineInfo()).getFormats()).forEach(format -> {
P.out("#######");
P.out("Channels: " + format.getChannels());
P.out("Size in Bits: " + format.getSampleSizeInBits());
P.out("Frame Rate: " + format.getFrameRate());
P.out("Frame Size: " + format.getFrameSize());
P.out("Encoding: " + format.getEncoding());
P.out("Sample Rate: " + format.getSampleRate());
});
}
} catch (Exception ex) {
ex.printStackTrace();
}
P.out("=========================");
}
}
protected Clip clipFromDefault() {
try {
Line.Info lineInfo = new Line.Info(Clip.class);
Line line = AudioSystem.getLine(lineInfo);
Clip clip = (Clip)line;
return clip;
} catch (LineUnavailableException e) {
e.printStackTrace();
return null;
}
}
protected Clip clipFromLine() {
try {
// did this even work??
int lineIndex = UI.valueInt(LINE_INDEX);
lineIndex = P.constrain(lineIndex, 0, linesOut.size() - 1);
Line.Info lineInfo = linesOut.get(lineIndex);
Line line = AudioSystem.getLine(lineInfo);
Clip clip = (Clip)line;
return clip;
} catch (LineUnavailableException e) {
e.printStackTrace();
return null;
}
}
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}
@Override
public Info[] getMixerInfo() {
return new Info[] { SoftMixingMixer.info };
}