当前位置: 首页>>代码示例>>Java>>正文


Java Mixer类代码示例

本文整理汇总了Java中javax.sound.sampled.Mixer的典型用法代码示例。如果您正苦于以下问题:Java Mixer类的具体用法?Java Mixer怎么用?Java Mixer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Mixer类属于javax.sound.sampled包,在下文中一共展示了Mixer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:goxr3plus,项目名称:java-stream-player,代码行数:23,代码来源:StreamPlayer.java

示例2: getMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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;
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SoftMixingMixerProvider.java

示例3: getMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:DirectAudioDeviceProvider.java

示例4: main

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DataLine_ArrayIndexOutOfBounds.java

示例5: getMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
@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));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DirectAudioDeviceProvider.java

示例6: getMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SoftMixingMixerProvider.java

示例7: AbstractMixer

import javax.sound.sampled.Mixer; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:AbstractMixer.java

示例8: isSoundcardInstalled

import javax.sound.sampled.Mixer; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ExtraCharInSoundbank.java

示例9: isSoundcardInstalled

import javax.sound.sampled.Mixer; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:FloatControlBug.java

示例10: main

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ClipFlushCrash.java

示例11: isSoundcardInstalled

import javax.sound.sampled.Mixer; //导入依赖的package包/类
/**
* 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ClipCloseLoss.java

示例12: main

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:DefaultMixers.java

示例13: testMixers

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DefaultMixers.java

示例14: doMixerClip

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:LineDefFormat.java

示例15: doMixerSDL

import javax.sound.sampled.Mixer; //导入依赖的package包/类
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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:LineDefFormat.java


注:本文中的javax.sound.sampled.Mixer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。