Java Code Examples for javax.sound.sampled.AudioSystem#getMixerInfo()
The following examples show how to use
javax.sound.sampled.AudioSystem#getMixerInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataLine_ArrayIndexOutOfBounds.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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"); } }
Example 2
Source File: BufferSizeCheck.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 3
Source File: ClipDrain.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 4
Source File: ClipCloseLoss.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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) { } } 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"); } } }
Example 5
Source File: DataLine_ArrayIndexOutOfBounds.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); } }
Example 6
Source File: ClipSetEndPoint.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 7
Source File: JavaSoundAudioDevice.java From jsyn with Apache License 2.0 | 6 votes |
/** * Build device info and determine default devices. */ private void sniffAvailableMixers() { Mixer.Info[] mixers = AudioSystem.getMixerInfo(); for (int i = 0; i < mixers.length; i++) { DeviceInfo deviceInfo = new DeviceInfo(); deviceInfo.name = mixers[i].getName(); Mixer mixer = AudioSystem.getMixer(mixers[i]); Line.Info[] lines = mixer.getTargetLineInfo(); deviceInfo.maxInputs = scanMaxChannels(lines); // Remember first device that supports input. if ((defaultInputDeviceID < 0) && (deviceInfo.maxInputs > 0)) { defaultInputDeviceID = i; } lines = mixer.getSourceLineInfo(); deviceInfo.maxOutputs = scanMaxChannels(lines); // Remember first device that supports output. if ((defaultOutputDeviceID < 0) && (deviceInfo.maxOutputs > 0)) { defaultOutputDeviceID = i; } deviceRecords.add(deviceInfo); } }
Example 8
Source File: DataLine_ArrayIndexOutOfBounds.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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"); } }
Example 9
Source File: DataLine_ArrayIndexOutOfBounds.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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"); } }
Example 10
Source File: SDLLinuxCrash.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 11
Source File: DataLineInfoNegBufferSize.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 12
Source File: MediaTools.java From MyBox with Apache License 2.0 | 5 votes |
public static void audioSystem() { Mixer.Info[] infos = AudioSystem.getMixerInfo(); for (Mixer.Info info : infos) { logger.debug(info.getName() + " " + info.getVendor() + " " + info.getVersion() + " " + info.getDescription()); } AudioFileFormat.Type[] formats = AudioSystem.getAudioFileTypes(); logger.debug(Arrays.asList(formats)); }
Example 13
Source File: Has16and32KHz.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example 14
Source File: BasicPlayer.java From gama with GNU General Public License v3.0 | 5 votes |
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; }
Example 15
Source File: ChangingBuffer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void doAll(boolean bigEndian) throws Exception { AudioFormat pcm = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, samplerate, 16, 1, 2, samplerate, bigEndian); Mixer.Info[] mixers = AudioSystem.getMixerInfo(); for (int i=0; i<mixers.length; i++) { Mixer mixer = AudioSystem.getMixer(mixers[i]); makeBuffer(); if (doMixerClip(mixer, pcm)) checkBufferClip(); makeBuffer(); if (doMixerSDL(mixer, pcm)) checkBufferSDL(); } if (mixers.length==0) { System.out.println("No mixers available!"); } }
Example 16
Source File: DeviceEvaluator.java From stendhal with GNU General Public License v2.0 | 5 votes |
public DeviceEvaluator() { Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo(); mDevices = new ArrayList<Device>(mixerInfos.length); for(Mixer.Info info: mixerInfos) { mDevices.add(new Device(info.getName(), info.getDescription(), AudioSystem.getMixer(info))); } }
Example 17
Source File: BogusMixers.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { try { out("4667064: Java Sound provides bogus SourceDataLine and TargetDataLine"); Mixer.Info[] aInfos = AudioSystem.getMixerInfo(); out(" available Mixers:"); for (int i = 0; i < aInfos.length; i++) { if (aInfos[i].getName().startsWith("Java Sound Audio Engine")) { Mixer mixer = AudioSystem.getMixer(aInfos[i]); Line.Info[] tlInfos = mixer.getTargetLineInfo(); for (int ii = 0; ii<tlInfos.length; ii++) { if (tlInfos[ii].getLineClass() == DataLine.class) { throw new Exception("Bogus TargetDataLine with DataLine info present!"); } } } if (aInfos[i].getName().startsWith("WinOS,waveOut,multi threaded")) { throw new Exception("Bogus mixer 'WinOS,waveOut,multi threaded' present!"); } out(aInfos[i].getName()); } if (aInfos.length == 0) { out("[No mixers available] - not a failure of this test case."); } } catch (Exception e) { e.printStackTrace(); throw e; } out("Test passed"); }
Example 18
Source File: Demo_MultichannelAudio_NativeMultipleSoundcard.java From haxademic with MIT License | 5 votes |
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); } }
Example 19
Source File: JavaInfo.java From haxademic with MIT License | 4 votes |
public static void printAudioInfo() { P.out("----------------- printAudioInfo -------------------"); Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); for(int i = 0; i < mixerInfo.length; i++) { P.out("########## mixerInfo["+i+"]", mixerInfo[i].getName()); // Mixer mixer = AudioSystem.getMixer(null); // default mixer Mixer mixer = AudioSystem.getMixer(mixerInfo[i]); // default mixer try { mixer.open(); } catch (LineUnavailableException e) { e.printStackTrace(); } P.out("Supported SourceDataLines of default mixer (%s):\n\n", mixer.getMixerInfo().getName()); for(Line.Info info : mixer.getSourceLineInfo()) { if(SourceDataLine.class.isAssignableFrom(info.getLineClass())) { SourceDataLine.Info info2 = (SourceDataLine.Info) info; P.out(info2); System.out.printf(" max buffer size: \t%d\n", info2.getMaxBufferSize()); System.out.printf(" min buffer size: \t%d\n", info2.getMinBufferSize()); AudioFormat[] formats = info2.getFormats(); P.out(" Supported Audio formats: "); for(AudioFormat format : formats) { P.out(" "+format); System.out.printf(" encoding: %s\n", format.getEncoding()); System.out.printf(" channels: %d\n", format.getChannels()); System.out.printf(format.getFrameRate()==-1?"":" frame rate [1/s]: %s\n", format.getFrameRate()); System.out.printf(" frame size [bytes]: %d\n", format.getFrameSize()); System.out.printf(format.getSampleRate()==-1?"":" sample rate [1/s]: %s\n", format.getSampleRate()); System.out.printf(" sample size [bit]: %d\n", format.getSampleSizeInBits()); System.out.printf(" big endian: %b\n", format.isBigEndian()); Map<String,Object> prop = format.properties(); if(!prop.isEmpty()) { P.out(" Properties: "); for(Map.Entry<String, Object> entry : prop.entrySet()) { System.out.printf(" %s: \t%s\n", entry.getKey(), entry.getValue()); } } } P.out(); } else { P.out(info.toString()); } P.out(); } mixer.close(); } }
Example 20
Source File: PhantomMixers.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int SDLformats = 0; int TDLformats = 0; Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); for(int i=0; i<mixerInfo.length; i++){ Mixer.Info thisMixerInfo = mixerInfo[i]; System.out.println("Mixer #"+i+": " + thisMixerInfo.getName() + ": " + thisMixerInfo.getDescription()); Mixer mixer = AudioSystem.getMixer(thisMixerInfo); Line.Info[] srcLineInfo = mixer.getSourceLineInfo(); Line.Info[] dstLineInfo = mixer.getTargetLineInfo(); int count = srcLineInfo.length + dstLineInfo.length; System.out.print(" -> " + (srcLineInfo.length + dstLineInfo.length) + " line"); switch (count) { case 0: System.out.println("s"); break; case 1: System.out.println(""); break; default: System.out.println("s:"); break; } int l; for (l = 0; l < srcLineInfo.length; l++) { System.out.println(" "+srcLineInfo[l].toString()); if (srcLineInfo[l].getLineClass() == SourceDataLine.class && (srcLineInfo[l] instanceof DataLine.Info)) { SDLformats += ((DataLine.Info) srcLineInfo[l]).getFormats().length; } } for (l = 0; l < dstLineInfo.length; l++) { System.out.println(" "+dstLineInfo[l].toString()); if (dstLineInfo[l].getLineClass() == TargetDataLine.class && (dstLineInfo[l] instanceof DataLine.Info)) { TDLformats += ((DataLine.Info) dstLineInfo[l]).getFormats().length; } } } if (mixerInfo.length == 0) { System.out.println("[no mixers present]"); } System.out.println(""+SDLformats+" total formats for SourceDataLines"); System.out.println(""+TDLformats+" total formats for TargetDataLines"); System.out.println(""); System.out.println("If there are audio devices correctly installed on your"); System.out.println("system, you should see at least one Mixer, and in total"); System.out.println("at least each one SourceDataLine and TargetDataLine, both"); System.out.println("providing at least one format."); System.out.println(""); System.out.println("Now disable your soundcard and repeat the test."); System.out.println("The corresponding mixer(s) should not provide any formats"); System.out.println("anymore. If you disable all available soundcards"); System.out.println("on your computer, the number of formats above should be"); System.out.println("0 for both line types (although mixers are allowed to exist)."); }