javax.sound.sampled.Line.Info Java Examples
The following examples show how to use
javax.sound.sampled.Line.Info.
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: SinkAudio.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
/** * FIXME: * specify the buffer size in the open(AudioFormat,int) method. A delay of 10ms-100ms will be acceptable for realtime audio. Very low latencies like will * not work on all computer systems, and 100ms or more will probably be annoying for your users. A good tradeoff is, e.g. 50ms. For your audio format, * 8-bit, mono at 44100Hz, a good buffer size is 2200 bytes, which is almost 50ms */ void initializeOutput() { DataLine.Info dataLineInfo = new DataLine.Info( SourceDataLine.class, audioFormat); //line = (TargetDataLine) AudioSystem.getLine(info); //Mixer m = AudioSystem.getMixer(null); try { //sourceDataLine = (SourceDataLine)m.getLine(dataLineInfo); sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo); sourceDataLine.open(audioFormat); sourceDataLine.start(); } catch (LineUnavailableException e) { // TODO Auto-generated catch block e.printStackTrace(Log.getWriter()); } }
Example #2
Source File: AudioSystem.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
/** Checks if a Mixer is appropriate. A Mixer is considered appropriate if it support the given line type. If isMixingRequired is true and the line type is an output one (SourceDataLine, Clip), the mixer is appropriate if it supports at least 2 (concurrent) lines of the given type. @return true if the mixer is considered appropriate according to the rules given above, false otherwise. */ private static boolean isAppropriateMixer(Mixer mixer, Line.Info lineInfo, boolean isMixingRequired) { if (! mixer.isLineSupported(lineInfo)) { return false; } Class lineClass = lineInfo.getLineClass(); if (isMixingRequired && (SourceDataLine.class.isAssignableFrom(lineClass) || Clip.class.isAssignableFrom(lineClass))) { int maxLines = mixer.getMaxLines(lineInfo); return ((maxLines == NOT_SPECIFIED) || (maxLines > 1)); } return true; }
Example #3
Source File: SinkAudio.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
public void setDevice(int position) throws LineUnavailableException, IllegalArgumentException { if (position == 0 || position == -1) { initializeOutput(); } else { Mixer appMixer = mixerList[position]; Info sdlLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat); sourceDataLine = (SourceDataLine) appMixer.getLine(sdlLineInfo); sourceDataLine.open(audioFormat); sourceDataLine.start(); } }
Example #4
Source File: AudioSystem.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
/** Return a Mixer with a given name from a given MixerProvider. This method never requires the returned Mixer to do mixing. @param mixerName The name of the Mixer to be returned. @param provider The MixerProvider to check for Mixers. @param info The type of line the returned Mixer is required to support. @return A Mixer matching the requirements, or null if none is found. */ private static Mixer getNamedMixer(String mixerName, MixerProvider provider, Line.Info info) { Mixer.Info[] infos = provider.getMixerInfo(); for (int i = 0; i < infos.length; i++) { if (infos[i].getName().equals(mixerName)) { Mixer mixer = provider.getMixer(infos[i]); if (isAppropriateMixer(mixer, info, false)) { return mixer; } } } return null; }
Example #5
Source File: SinkAudio.java From FoxTelem with GNU General Public License v3.0 | 4 votes |
private static String getMixerIdString(Mixer appMixer) { Mixer.Info info = appMixer.getMixerInfo(); return info.getName() + info.getDescription() + info.getVendor() + info.getVersion(); }
Example #6
Source File: SourceSoundCardAudio.java From FoxTelem with GNU General Public License v3.0 | 4 votes |
private static String getMixerIdString(Mixer appMixer) { Mixer.Info info = appMixer.getMixerInfo(); return info.getName() + info.getDescription() + info.getVendor() + info.getVersion(); }
Example #7
Source File: SourceSoundCardAudio.java From FoxTelem with GNU General Public License v3.0 | 4 votes |
/** * Pass the combo box position and select this device * @param position * @throws LineUnavailableException * @throws IllegalArgumentException */ private void setDevice(int position) throws LineUnavailableException, IllegalArgumentException { //Mixer.Info[] mixers = AudioSystem.getMixerInfo(); //AudioFormat audioFmt = getAudioFormat(); Mixer appMixer = mixerList[position]; Info sdlLineInfo = new DataLine.Info(TargetDataLine.class, makeAudioFormat(sampleRate)); stop(); targetDataLine = (TargetDataLine) appMixer.getLine(sdlLineInfo); init(); }
Example #8
Source File: AudioSystem.java From tuxguitar with GNU Lesser General Public License v2.1 | 2 votes |
/** * Obtains a source data line that can be used for playing back * audio data in the format specified by the * <code>AudioFormat</code> object. The returned line * will be provided by the default system mixer, or, * if not possible, by any other mixer installed in the * system that supports a matching * <code>SourceDataLine</code> object. * * <p>The returned line should be opened with the * <code>open(AudioFormat)</code> or * <code>open(AudioFormat, int)</code> method. * * <p>This is a high-level method that uses <code>getMixer</code> * and <code>getLine</code> internally. * * <p>The returned <code>SourceDataLine</code>'s default * audio format will be initialized with <code>format</code>. * * <p>If the system property * <code>javax.sound.sampled.SourceDataLine</code> * is defined or it is defined in the file "sound.properties", * it is used to retrieve the default source data line. * For details, refer to the {@link AudioSystem class description}. * * @param format an <code>AudioFormat</code> object specifying * the supported audio format of the returned line, * or <code>null</code> for any audio format * @return the desired <code>SourceDataLine</code> object * * @throws LineUnavailableException if a matching source data line * is not available due to resource restrictions * @throws SecurityException if a matching source data line * is not available due to security restrictions * @throws IllegalArgumentException if the system does not * support at least one source data line supporting the * specified audio format through any installed mixer * * @see #getSourceDataLine(AudioFormat, Mixer.Info) * @since 1.5 */ public static SourceDataLine getSourceDataLine(AudioFormat format) throws LineUnavailableException{ DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); return (SourceDataLine) AudioSystem.getLine(info); }