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 static void main(String[] args) throws InterruptedException { for (AudioFileFormat.Type fileFormat : AudioSystem.getAudioFileTypes()) { System.out.print(fileFormat + ", "); } System.out.println(); System.out.println(); for (Info info : AudioSystem.getMixerInfo()) { System.out.println(info); } System.out.println(); Mixer mixer = AudioSystem.getMixer(null); int maxLines = mixer.getMaxLines(mixer.getLineInfo()); System.out.println("maxlines=" + maxLines); Thread.sleep(100); play("freesoundproject_22740__FranciscoPadilla__37_Click_Finger.wav"); play("freesoundproject_28917__junggle__btn107.mp3"); Thread.sleep(1000); System.out.println("Done"); }
public static Vector<Mixer.Info> getMixerInfo( final boolean supportsPlayback, final boolean supportsRecording) { final Vector<Mixer.Info> infos = new Vector<Mixer.Info>(); final Mixer.Info[] mixers = AudioSystem.getMixerInfo(); for (final Info mixerinfo : mixers) { if (supportsRecording && AudioSystem.getMixer(mixerinfo).getTargetLineInfo().length != 0) { // Mixer capable of recording audio if target LineWavelet length != 0 infos.add(mixerinfo); } else if (supportsPlayback && AudioSystem.getMixer(mixerinfo).getSourceLineInfo().length != 0) { // Mixer capable of audio play back if source LineWavelet length != 0 infos.add(mixerinfo); } } return infos; }
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; }
public AudioFormat[] GetMixerCapabilities(int MixerIndex) { Info[] mixerinfo = AudioSystem.getMixerInfo(); // select the Mixer to record from Mixer mixer = AudioSystem.getMixer(mixerinfo[MixerIndex]); Line.Info[] Infos = mixer.getTargetLineInfo(); for (int i = 0; i < Infos.length; i++) { if (Infos[i] instanceof DataLine.Info) { DataLine.Info dataLineInfo = (DataLine.Info) Infos[i]; // these are the available formats of the selected mixer AudioFormat[] supportedFormats = dataLineInfo.getFormats(); return supportedFormats; } } return null; }
public String getModel() { StringBuilder result = new StringBuilder(MODEL_1); for (ProtocolDecoder decoder : decoders.getAllDecoders()) { result.append("<item>"); result.append(decoder.getInfo().getName()); result.append("</item>"); } result.append(MODEL_2); result.append("<item>"); result.append(getSourceName()); result.append("</item>"); for (Info source : audioSampler.getSourceList()) { result.append("<item>"); result.append(source.getName()); result.append("</item>"); } result.append(MODEL_3); return result.toString(); }
/** * Specify audio source. This can be specified in two ways, either the * source number or by the name of the source. Even if the number is * specified, the source name is stored and used. * * @param name source name or source number */ public void setSourceName(String name) { Info sources[] = m_PulsePlayer.getSourceList(); if ((name.length() == 1) && (name.charAt(0) >= '0') && (name.charAt(0) <= '9')) { m_PulsePlayer.setSource(Integer.parseInt(name)); } else { for (int i = 0; i < sources.length; i++) { if (sources[i].getName().replaceAll("\\s+", " ").equalsIgnoreCase(name)) { m_PulsePlayer.setSource(i); } } } m_SourceName = sources[m_PulsePlayer.getSource()].getName(); if (m_PulsePlayer.isOpen()) { m_PulsePlayer.closeLine(); m_PulsePlayer.openLine(); } }
@Override public Mixer getMixer(Info info) { if( TGMixer.MIXER_INFO.equals(info) ) { return new TGMixer(); } return null; }
@Override public Mixer getMixer(Info info) { if (info.equals(mixer.getMixerInfo())) return mixer; throw new IllegalArgumentException("This provider cannot handle a mixer or type: " + info.getName()); }
public static void main(String[] args) throws InterruptedException { for (AudioFileFormat.Type fileFormat : AudioSystem.getAudioFileTypes()) { System.out.print(fileFormat + ", "); } System.out.println(); System.out.println(); for (Info info : AudioSystem.getMixerInfo()) { System.out.println(info); } System.out.println(); Mixer mixer = AudioSystem.getMixer(null); int maxLines = mixer.getMaxLines(mixer.getLineInfo()); System.out.println("maxlines=" + maxLines); Thread.sleep(100); play("35631__reinsamba__crystal_glass.wav"); play("9874__vixuxx__crow.au"); play("9874__vixuxx__crow.aiff"); play("Bird_Black_Ready1.wav"); play("Bird_Black_Clicked1.mp3"); play("ambient_construction.mp3"); play("28917__junggle__btn107.mp3"); play("forty-two.mp3"); Thread.sleep(1000); System.out.println("Done"); }
@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; }
public boolean isMixerSupported(Mixer.Info info) { Mixer.Info[] devices = getMixerInfo(); for (Info element : devices) { if (info.equals(element)) { return true; } } return false; }
@Override public JMenu getMenu() { final JMenu retVal = new JMenu(); if(getWavDisplay().isPlaying()) { retVal.add(new StopAction(getEditor(), this)); } else { retVal.add(new PlayAction(getEditor(), this)); final JCheckBoxMenuItem loopItem = new JCheckBoxMenuItem(new ToggleLoop(getWavDisplay())); retVal.add(loopItem); // output device selection final JMenu mixerMenu = new JMenu("Output Device"); final Info[] mixers = AudioSystem.getMixerInfo(); for(Info mixerInfo:mixers) { // if we have no source lines, we can't use this device if(AudioSystem.getMixer(mixerInfo).getSourceLineInfo().length == 0) continue; final SelectMixerAction mixerAct = new SelectMixerAction(getWavDisplay(), mixerInfo); mixerAct.putValue(SelectMixerAction.SELECTED_KEY, getWavDisplay().getMixerInfo() == mixerInfo); mixerMenu.add(new JCheckBoxMenuItem(mixerAct)); } retVal.add(mixerMenu); } retVal.addSeparator(); retVal.add(new ResetAction(getEditor(), this)); retVal.add(new ZoomAction(getEditor(), this)); retVal.add(new ZoomAction(getEditor(), this, false)); retVal.addSeparator(); retVal.add(new SaveAction(getEditor(), this)); retVal.add(new GenerateAction(getEditor(), this)); for(SpeechAnalysisTier tier:pluginTiers) { tier.addMenuItems(retVal, false); } return retVal; }
public static String[] getInputDeviceNames(){ Info[] mixerInfo = AudioSystem.getMixerInfo(); List<String> ls = new ArrayList<>(); ls.add("Default"); for(Info i : mixerInfo){ if(i.getDescription().equals("Direct Audio Device: DirectSound Capture")){ ls.add(i.getName()); } } return cutLength(ls.toArray(new String[ls.size()]), 31); }
public static String[] getOutputDeviceNames(){ Info[] mixerInfo = AudioSystem.getMixerInfo(); List<String> ls = new ArrayList<>(); ls.add("Default"); ls.add("None"); for(Info i : mixerInfo){ if(i.getDescription().equals("Direct Audio Device: DirectSound Playback")){ ls.add(i.getName()); } } return cutLength(ls.toArray(new String[ls.size()]), 31); }
public String[] GetAvailableAudioMixers() { // Get all mixers from the system - USB audio device will have its own mixer Info[] mixerinfo = AudioSystem.getMixerInfo(); String[] Return = new String[mixerinfo.length]; for (int i = 0; i < mixerinfo.length; i++) { AudioFormat[] formats = GetMixerCapabilities(i); if (formats != null) { Return[i] = mixerinfo[i].getName() + " " + mixerinfo[i].getDescription(); } } return Return; }
public void SetAudioOptions(int MixerIndex, int FormatIndex) { FormatID = FormatIndex; MixerID = MixerIndex; Info[] mixerinfo = AudioSystem.getMixerInfo(); // select the mixer to record from Mixer mixer = AudioSystem.getMixer(mixerinfo[MixerIndex]); // get all available audio formats on that device AudioFormat[] supportedFormats = GetMixerCapabilities(MixerIndex); // we use WAV by default RecAudioFileFormat = AudioFileFormat.Type.WAVE; // Create AudioFormat that the audio hardware supports // 48KHz is hardcoded for now until we create a custom field in the settings for it if (supportedFormats[FormatIndex].getSampleRate() == -1) { RecAudioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000.0F, supportedFormats[FormatIndex].getSampleSizeInBits(), supportedFormats[FormatIndex].getChannels(), supportedFormats[FormatIndex].getFrameSize(), 48000.0F, supportedFormats[FormatIndex].isBigEndian()); } else { RecAudioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, supportedFormats[FormatIndex].getSampleRate(), supportedFormats[FormatIndex].getSampleSizeInBits(), supportedFormats[FormatIndex].getChannels(), supportedFormats[FormatIndex].getFrameSize(), supportedFormats[FormatIndex].getSampleRate(), supportedFormats[FormatIndex].isBigEndian()); } TargetDataLine targetDataLine = null; try { targetDataLine = AudioSystem.getTargetDataLine(RecAudioFormat, mixerinfo[MixerIndex]); targetDataLine.open(RecAudioFormat); } catch (LineUnavailableException e) { Parent.WriteErrortoConsole("unable to get a recording line"); } Dataline = targetDataLine; AudioInputStream = new AudioInputStream(Dataline); AudioMonitorStream = new AudioInputStream(Dataline); }