/**
* 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;
}
java类javax.sound.sampled.Mixer的实例源码
StreamPlayer.java 文件源码
项目:java-stream-player
阅读 23
收藏 0
点赞 0
评论 0
SoftMixingMixerProvider.java 文件源码
项目:OpenJSharp
阅读 23
收藏 0
点赞 0
评论 0
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;
}
}
Record.java 文件源码
项目:rcom
阅读 37
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws Exception {
AudioFormat format=ManualTestEchoCancel.getFormat();
final Mixer mixer = AudioSystem.getMixer(null);
Mic m=new Mic(mixer, format, ManualTestEchoCancel.frameSamples);
m.start();
try(Scanner br=new Scanner(System.in))
{
System.out.println("Press ENTER to start recording");
br.nextLine();
try(FileOutputStream fos=new FileOutputStream("/tmp/out.sw"))
{
m.setRecord(fos);
System.out.println("Press ENTER to stop recording");
br.nextLine();
m.setRecord(null);
}
}
System.exit(0);
}
DirectAudioDeviceProvider.java 文件源码
项目:jdk8u-jdk
阅读 23
收藏 0
点赞 0
评论 0
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.");
}
SoftMixingMixerProvider.java 文件源码
项目:jdk8u-jdk
阅读 26
收藏 0
点赞 0
评论 0
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;
}
}
DataLine_ArrayIndexOutOfBounds.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
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");
}
}
DirectAudioDeviceProvider.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
@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));
}
SoftMixingMixerProvider.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
@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;
}
}
AbstractMixer.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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;
}
ExtraCharInSoundbank.java 文件源码
项目:openjdk-jdk10
阅读 28
收藏 0
点赞 0
评论 0
/**
* 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;
}
FloatControlBug.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
ClipSetEndPoint.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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;
}
ClipFlushCrash.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
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");
}
}
}
ClipCloseLoss.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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;
}
ClipDuration.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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;
}
ClipLinuxCrash2.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
SDLLinuxCrash.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
DefaultMixers.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
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");
}
}
DefaultMixers.java 文件源码
项目:openjdk-jdk10
阅读 30
收藏 0
点赞 0
评论 0
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;
}
LineDefFormat.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
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());
}
}
LineDefFormat.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
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());
}
}
LineDefFormat.java 文件源码
项目:openjdk-jdk10
阅读 29
收藏 0
点赞 0
评论 0
private static void doMixerTDL(Mixer mixer, AudioFormat format) {
if (mixer==null) return;
try {
System.out.println("TDL from mixer "+mixer+":");
DataLine.Info info = new DataLine.Info(
TargetDataLine.class,
format);
if (mixer.isLineSupported(info)) {
TargetDataLine tdl = (TargetDataLine) mixer.getLine(info);
doLine1(tdl, format);
doLine2(tdl, format);
} else {
System.out.println(" - Line not supported");
}
} catch (Throwable t) {
System.out.println(" - Caught exception. Not failed.");
System.out.println(" - "+t.toString());
}
}
Replay.java 文件源码
项目:rcom
阅读 21
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws IOException, LineUnavailableException {
File folder=new File("/home/rizsi/tmp/video");
byte[] data=UtilFile.loadFile(new File(folder, "remote.sw"));
byte[] data2=UtilFile.loadFile(new File(folder, "local.sw"));
System.out.println("remote.sw max: "+measureMax(data));
System.out.println("local.sw max: "+measureMax(data2));
byte[] data3=sum(data, data2);
UtilFile.saveAsFile(new File(folder, "rawmic.sw"), data3);
AudioFormat format=ManualTestEchoCancel.getFormat();
final Mixer mixer = AudioSystem.getMixer(null);
Play p=new Play(mixer, format, ManualTestEchoCancel.frameSamples)
{
@Override
protected void switchBuffer() {
if(getSample()==data)
{
setSample(data2);
}else if(getSample()==data2)
{
setSample(data3);
}
}
};
p.start();
p.setSample(data);
}
DataLineInfoNegBufferSize.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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;
}
DataLine_ArrayIndexOutOfBounds.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
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");
}
}
BufferSizeCheck.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
StreamPlayer.java 文件源码
项目:java-stream-player
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
BothEndiansAndSigns.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
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");
}
}
BothEndiansAndSigns.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
public static void checkLines(Mixer mixer, Line.Info[] infos) {
for (int i = 0; i<infos.length; i++) {
try {
if (infos[i] instanceof DataLine.Info) {
DataLine.Info info = (DataLine.Info) infos[i];
System.out.println(" Line "+info+" (max. "+mixer.getMaxLines(info)+" simultaneously): ");
AudioFormat[] formats = info.getFormats();
for (int f = 0; f < formats.length; f++) {
try {
AudioFormat otherEndianOrSign = getOtherEndianOrSign(formats[f]);
if (otherEndianOrSign != null) {
checkFormat(formats, otherEndianOrSign);
}
} catch (Exception e1) {
out(" Unexpected exception when getting a format: "+e1);
}
}
}
} catch (Exception e) {
out(" Unexpected exception when getting a line: "+e);
}
}
}
Minim.java 文件源码
项目:romanov
阅读 23
收藏 0
点赞 0
评论 0
/**
* When using the JavaSound implementation of Minim, this sets the JavaSound Mixer
* that will be used for obtaining input sources such as AudioInputs.
* THIS METHOD WILL BE REPLACED IN A FUTURE VERSION.
*
* @param mixer
* The Mixer we should try to acquire inputs from.
*/
@Deprecated
public void setInputMixer(Mixer mixer)
{
if ( mimp instanceof JSMinim )
{
( (JSMinim)mimp ).setInputMixer( mixer );
}
}