Java Code Examples for javax.sound.sampled.Mixer#Info

The following examples show how to use javax.sound.sampled.Mixer#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: DirectAudioDeviceProvider.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 2
Source File: PortMixerProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Mixer.Info[] getMixerInfo() {
    synchronized (PortMixerProvider.class) {
        Mixer.Info[] localArray = new Mixer.Info[infos.length];
        System.arraycopy(infos, 0, localArray, 0, infos.length);
        return localArray;
    }
}
 
Example 3
Source File: PortMixerProvider.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Mixer.Info[] getMixerInfo() {
    synchronized (PortMixerProvider.class) {
        Mixer.Info[] localArray = new Mixer.Info[infos.length];
        System.arraycopy(infos, 0, localArray, 0, infos.length);
        return localArray;
    }
}
 
Example 4
Source File: JavaSoundAudioDevice.java    From jsyn with Apache License 2.0 5 votes vote down vote up
Line getDataLine(DataLine.Info info) throws LineUnavailableException {
    Line dataLine;
    if (deviceID >= 0) {
        Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        Mixer mixer = AudioSystem.getMixer(mixers[deviceID]);
        dataLine = mixer.getLine(info);
    } else {
        dataLine = AudioSystem.getLine(info);
    }
    return dataLine;
}
 
Example 5
Source File: BasicPlayer.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public Mixer getMixer(final String name) {
	Mixer mixer = null;
	if (name != null) {
		final Mixer.Info[] mInfos = AudioSystem.getMixerInfo();
		if (mInfos != null) {
			for (final Info mInfo : mInfos) {
				if (mInfo.getName().equals(name)) {
					mixer = AudioSystem.getMixer(mInfo);
					break;
				}
			}
		}
	}
	return mixer;
}
 
Example 6
Source File: PortMixerProvider.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public Mixer getMixer(Mixer.Info info) {
    synchronized (PortMixerProvider.class) {
        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));
}
 
Example 7
Source File: PortMixerProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Mixer getMixer(Mixer.Info info) {
    synchronized (PortMixerProvider.class) {
        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.");
}
 
Example 8
Source File: PortMixerProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Mixer.Info[] getMixerInfo() {
    synchronized (PortMixerProvider.class) {
        Mixer.Info[] localArray = new Mixer.Info[infos.length];
        System.arraycopy(infos, 0, localArray, 0, infos.length);
        return localArray;
    }
}
 
Example 9
Source File: DirectAudioDeviceProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Mixer.Info[] getMixerInfo() {
    synchronized (DirectAudioDeviceProvider.class) {
        Mixer.Info[] localArray = new Mixer.Info[infos.length];
        System.arraycopy(infos, 0, localArray, 0, infos.length);
        return localArray;
    }
}
 
Example 10
Source File: DirectSoundRepeatingBuffer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    println("This is an interactive test for DirectAudio.");
    println("If the tone repeats, the test is failed.");
    println("");
    println("Make sure that you have speakers connected");
    println("and that the system mixer is not muted.");
    println("");
    println("Press a key to start the test.");
    key();
    Mixer.Info[] mixers=null;

        println("   ...using self-generated sine wave for playback");
        audioFormat = new AudioFormat((float)sampleRate, 8, 1, true, true);
        for (int i=0; i<audioData.length; i++) {
            audioData[i] = (byte)(Math.sin(RAD*frequency/sampleRate*i)*127.0);
        }
    info = new DataLine.Info(SourceDataLine.class, audioFormat);

    mixers = AudioSystem.getMixerInfo();
    int succMixers = 0;
    for (int i=0; i<mixers.length; i++) {
        println(""+mixers[i]+":");
        if ((mixers[i].getName()+mixers[i].getDescription()+mixers[i].getVendor()).indexOf("Direct") < 0) {
            println("  ->not a DirectAudio Mixer!");
        } else {
        try {
            Mixer mixer = AudioSystem.getMixer(mixers[i]);
            if (!mixer.isLineSupported(info)) {
                    println("  ->doesn't support SourceDataLine!");
            } else {
                succMixers++;
                println("  -> is getting tested.");
                play(mixer);
            }
        } catch (Exception e) {
            println("  -> Exception occured: "+e);
            e.printStackTrace();
        }
      }
    }
    if (succMixers == 0) {
            println("No DirectAudio mixers available! ");
            println("Cannot run test.");
    }
}
 
Example 11
Source File: AbstractMixer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public final Mixer.Info getMixerInfo() {
    return mixerInfo;
}
 
Example 12
Source File: PhantomMixers.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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).");
}
 
Example 13
Source File: AbstractMixer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public final Mixer.Info getMixerInfo() {
    return mixerInfo;
}
 
Example 14
Source File: MixerProvider.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Indicates whether the mixer provider supports the mixer represented by
 * the specified mixer info object.
 * <p>
 * The full set of mixer info objects that represent the mixers supported
 * by this {@code MixerProvider} may be obtained
 * through the {@code getMixerInfo} method.
 *
 * @param info an info object that describes the mixer for which support is queried
 * @return {@code true} if the specified mixer is supported,
 *     otherwise {@code false}
 * @see #getMixerInfo()
 */
public boolean isMixerSupported(Mixer.Info info) {

    Mixer.Info infos[] = getMixerInfo();

    for(int i=0; i<infos.length; i++){
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source File: MixerProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Indicates whether the mixer provider supports the mixer represented by
 * the specified mixer info object.
 * <p>
 * The full set of mixer info objects that represent the mixers supported
 * by this {@code MixerProvider} may be obtained
 * through the {@code getMixerInfo} method.
 *
 * @param info an info object that describes the mixer for which support is queried
 * @return {@code true} if the specified mixer is supported,
 *     otherwise {@code false}
 * @see #getMixerInfo()
 */
public boolean isMixerSupported(Mixer.Info info) {

    Mixer.Info infos[] = getMixerInfo();

    for(int i=0; i<infos.length; i++){
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 16
Source File: MixerProvider.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the mixer
 * or mixers provided by this MixerProvider.
 * <p>
 * The {@code isMixerSupported} method returns {@code true}
 * for all the info objects returned by this method.
 * The corresponding mixer instances for the info objects
 * are returned by the {@code getMixer} method.
 *
 * @return a set of mixer info objects
 * @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
 * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
 */
public abstract Mixer.Info[] getMixerInfo();
 
Example 17
Source File: MixerProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the mixer
 * or mixers provided by this MixerProvider.
 * <p>
 * The {@code isMixerSupported} method returns {@code true}
 * for all the info objects returned by this method.
 * The corresponding mixer instances for the info objects
 * are returned by the {@code getMixer} method.
 *
 * @return a set of mixer info objects
 * @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
 * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
 */
public abstract Mixer.Info[] getMixerInfo();
 
Example 18
Source File: MixerProvider.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the mixer or mixers provided
 * by this MixerProvider.
 * <p>
 * The {@code isMixerSupported} method returns {@code true} for all the info
 * objects returned by this method. The corresponding mixer instances for
 * the info objects are returned by the {@code getMixer} method.
 *
 * @return a set of mixer info objects
 * @see #getMixer(Mixer.Info)
 * @see #isMixerSupported(Mixer.Info)
 */
public abstract Mixer.Info[] getMixerInfo();
 
Example 19
Source File: MixerProvider.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an instance of the mixer represented by the info object.
 * <p>
 * The full set of the mixer info objects that represent the mixers
 * supported by this {@code MixerProvider} may be obtained
 * through the {@code getMixerInfo} method.
 * Use the {@code isMixerSupported} method to test whether
 * this {@code MixerProvider} supports a particular mixer.
 *
 * @param info an info object that describes the desired mixer
 * @return mixer instance
 * @throws IllegalArgumentException if the info object specified does not
 *     match the info object for a mixer supported by this MixerProvider.
 * @see #getMixerInfo()
 * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
 */
public abstract Mixer getMixer(Mixer.Info info);
 
Example 20
Source File: MixerProvider.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the set of info objects representing the mixer
 * or mixers provided by this MixerProvider.
 * <p>
 * The {@code isMixerSupported} method returns {@code true}
 * for all the info objects returned by this method.
 * The corresponding mixer instances for the info objects
 * are returned by the {@code getMixer} method.
 *
 * @return a set of mixer info objects
 * @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
 * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
 */
public abstract Mixer.Info[] getMixerInfo();