本文整理了Java中javax.sound.sampled.Mixer.getLine()
方法的一些代码示例,展示了Mixer.getLine()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mixer.getLine()
方法的具体详情如下:
包路径:javax.sound.sampled.Mixer
类名称:Mixer
方法名:getLine
暂无
代码示例来源:origin: stackoverflow.com
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (Mixer.Info info: mixerInfos){
Mixer m = AudioSystem.getMixer(info);
Line.Info[] lineInfos = m.getSourceLineInfo();
for (Line.Info lineInfo:lineInfos){
System.out.println (info.getName()+"---"+lineInfo);
Line line = m.getLine(lineInfo);
System.out.println("\t-----"+line);
}
lineInfos = m.getTargetLineInfo();
for (Line.Info lineInfo:lineInfos){
System.out.println (m+"---"+lineInfo);
Line line = m.getLine(lineInfo);
System.out.println("\t-----"+line);
}
}
代码示例来源:origin: marytts/marytts
/**
* Try to get a line for output to the speaker. The line is not yet opened with a specific format.
*
* @return a line object, or null if the line could not be created.
*/
public SourceDataLine getSpeakerOutputLine() {
Object audioDescriptor = cbSpeakerOutput.getSelectedItem();
assert audioDescriptor instanceof Mixer.Info;
Mixer.Info mixerInfo = (Mixer.Info) audioDescriptor;
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info[] lineInfos = mixer.getSourceLineInfo();
assert lineInfos.length > 0 : "Strange, there are no more source lines for mixer: " + mixer;
Line.Info lineInfo = lineInfos[0];
SourceDataLine line = null;
try {
line = (SourceDataLine) mixer.getLine(lineInfo);
} catch (LineUnavailableException e) {
e.printStackTrace();
}
return line;
}
代码示例来源:origin: marytts/marytts
/**
* Try to get a line for output to the expert. The line is not yet opened with a specific format.
*
* @return a line object, or null if the line could not be created.
*/
public SourceDataLine getExpertOutputLine() {
Object audioDescriptor = cbExpertOutput.getSelectedItem();
assert audioDescriptor instanceof Mixer.Info;
Mixer.Info mixerInfo = (Mixer.Info) audioDescriptor;
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info[] lineInfos = mixer.getSourceLineInfo();
assert lineInfos.length > 0 : "Strange, there are no more source lines for mixer: " + mixer;
Line.Info lineInfo = lineInfos[0];
SourceDataLine line = null;
try {
line = (SourceDataLine) mixer.getLine(lineInfo);
} catch (LineUnavailableException e) {
e.printStackTrace();
}
return line;
}
代码示例来源:origin: cmusphinx/sphinx4
audioLine = (TargetDataLine) AudioSystem.getLine(info);
} else {
audioLine = (TargetDataLine) selectedMixer.getLine(info);
代码示例来源:origin: marytts/marytts
targetDataLine = (TargetDataLine) mixer.getLine(info);
} else {
if (DEBUG) {
代码示例来源:origin: marytts/marytts
assert lineInfos.length > 0 : "Strange, there is no more line info for mixer: " + mixer;
Line.Info lineInfo = lineInfos[0];
targetDataLine = (TargetDataLine) mixer.getLine(lineInfo);
} else {
assert ((String) audioDescriptor).equals("AudioSystem");
代码示例来源:origin: marytts/marytts
targetDataLine = (TargetDataLine) mixer.getLine(info);
} else {
if (DEBUG) {
代码示例来源:origin: marytts/marytts
targetDataLine = (TargetDataLine) mixer.getLine(info);
} else {
if (DEBUG) {
代码示例来源:origin: marytts/marytts
targetDataLine = (TargetDataLine) mixer.getLine(info);
} else {
if (DEBUG) {
代码示例来源:origin: magefree/mage
public LinePool(AudioFormat audioFormat, int size, int alwaysActive) {
this.alwaysActive = alwaysActive;
mixer = AudioSystem.getMixer(null);
DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);
for (int i = 0; i < size; i++) {
try {
SourceDataLine line = (SourceDataLine) mixer.getLine(lineInfo);
freeLines.add(line);
} catch (LineUnavailableException e) {
log.warn("Failed to get line from mixer", e);
}
}
new Timer("Line cleanup", true).scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
synchronized (LinePool.this) {
for (SourceDataLine sourceDataLine : freeLines) {
if (sourceDataLine.isOpen()) {
sourceDataLine.close();
log.debug("Closed line {}", sourceDataLine);
}
}
}
}
}, LINE_CLEANUP_INTERVAL, LINE_CLEANUP_INTERVAL);
}
代码示例来源:origin: stackoverflow.com
System.out.println(" Line.Info: " + lineInfo);
try {
Line line = mixer.getLine(lineInfo);
FloatControl volCtrl = (FloatControl)line.getControl(
FloatControl.Type.MASTER_GAIN);
代码示例来源:origin: stackoverflow.com
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
// Look through and select a mixer here, different mixers should be different inputs
int selectedMixerIndex = 0;
Mixer mixer = AudioSystem.getMixer(mixerInfo[ selectedMixerIndex ]);
TargetDataLine line = (TargetDataLine) mixer.getLine(dataLineInfo);
代码示例来源:origin: stackoverflow.com
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
Mixer mixer = AudioSystem.getMixer(mixerinfo);
return (TargetDataLine) mixer.getLine(info);
代码示例来源:origin: stackoverflow.com
Port lineIn;
FloatControl volCtrl;
try {
Mixer mixer = AudioSystem.getMixer(null);
lineIn = (Port)mixer.getLine(Port.Info.LINE_IN);
lineIn.open();
volCtrl = (FloatControl) lineIn.getControl(
FloatControl.Type.VOLUME);
// Assuming getControl call succeeds,
// we now have our LINE_IN VOLUME control.
} catch (Exception e) {
System.out.println("Failed trying to find LINE_IN"
+ " VOLUME control: exception = " + e);
}
代码示例来源:origin: IanWraith/DMRDecode
/**
* Gets a data line for the specified mixer
* @param mix
* @return
*/
public Line getDataLineForMixer(){
TargetDataLine line = null;
try {
line = (TargetDataLine) this.mixer.getLine(getDataLineInfo());
} catch (LineUnavailableException e) {
System.out.println("Error getting mix line:" + e.getMessage());
}
return line;
}
代码示例来源:origin: net.sf.phat/phat-audio
private SourceDataLine getSourceDataLine(DataLine.Info dataLineInfo) {
SourceDataLine sdl = null;
for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
Mixer m = AudioSystem.getMixer(mi);
if (m.isLineSupported(dataLineInfo)) {
try {
Line line = m.getLine(dataLineInfo);
if (line instanceof SourceDataLine) {
Logger.getLogger(
PCSpeaker.class.getName()).log(Level.INFO, "Mixer={0}", m.getMixerInfo().getName());
sdl = (SourceDataLine) line;
break;
}
} catch (LineUnavailableException ex) {
Logger.getLogger(PCSpeaker.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
return sdl;
}
代码示例来源:origin: robo-code/robocode
private void mixerComboBoxActionPerformed() {
Mixer mixer = AudioSystem.getMixer((Mixer.Info) mixerComboBox.getSelectedItem());
Line.Info lineInfo = mixer.getSourceLineInfo(new Line.Info(Clip.class))[0];
boolean volumeSupported;
boolean panSupported;
try {
Line line = mixer.getLine(lineInfo);
volumeSupported = line.isControlSupported(FloatControl.Type.MASTER_GAIN);
panSupported = line.isControlSupported(FloatControl.Type.PAN);
} catch (LineUnavailableException e) {
volumeSupported = false;
panSupported = false;
}
enableMixerVolumeCheckBox.setEnabled(volumeSupported);
enableMixerPanCheckBox.setEnabled(panSupported);
}
代码示例来源:origin: robo-code/robocode
private ClipClones(Mixer mixer, SoundData soundData, int size) throws LineUnavailableException {
idx = 0;
clips = new Clip[size];
DataLine.Info info = new DataLine.Info(Clip.class, soundData.format);
if (!AudioSystem.isLineSupported(info)) {
throw new LineUnavailableException("Required data line is not supported by the audio system");
}
for (int i = 0; i < size; i++) {
clips[i] = (Clip) mixer.getLine(info);
clips[i].open(soundData.format, soundData.byteData, 0, soundData.length);
}
}
代码示例来源:origin: stackoverflow.com
int duration = 5; // sample for 5 seconds
TargetDataLine line = null;
// find a DataLine that can be read
// (maybe hardcode this if you have multiple microphones)
Info[] mixerInfo = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfo.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
Line.Info[] targetLineInfo = mixer.getTargetLineInfo();
if (targetLineInfo.length > 0) {
line = (TargetDataLine) mixer.getLine(targetLineInfo[0]);
break;
}
}
if (line == null)
throw new UnsupportedOperationException("No recording device found");
AudioFormat af = new AudioFormat(11000, 8, 1, true, false);
line.open(af);
line.start();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[(int)af.getSampleRate() * af.getFrameSize()];
long end = System.currentTimeMillis() + 1000 * duration;
int len;
while (System.currentTimeMillis() < end && ((len = line.read(buf, 0, buf.length)) != -1)) {
baos.write(buf, 0, len);
}
line.stop();
line.close();
baos.close();
代码示例来源:origin: ddf/Minim
line = (TargetDataLine)inputMixer.getLine(info);
内容来源于网络,如有侵权,请联系作者删除!