當前位置: 首頁>>代碼示例>>Java>>正文


Java Mixer.Info方法代碼示例

本文整理匯總了Java中javax.sound.sampled.Mixer.Info方法的典型用法代碼示例。如果您正苦於以下問題:Java Mixer.Info方法的具體用法?Java Mixer.Info怎麽用?Java Mixer.Info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.sound.sampled.Mixer的用法示例。


在下文中一共展示了Mixer.Info方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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,代碼來源:ClipSetEndPoint.java

示例2: 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,代碼來源:ClipLinuxCrash2.java

示例3: 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

示例4: 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

示例5: 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:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:DataLine_ArrayIndexOutOfBounds.java

示例6: getMixers

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
/**
 * Returns all available mixers.
 *
 * @return A List of available Mixers
 */
public List<String> getMixers() {
	List<String> mixers = new ArrayList<>();
	
	// 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 (mixerInfos != null)
		Arrays.stream(mixerInfos).forEach(mInfo -> {
			// line info
			Line.Info lineInfo = new Line.Info(SourceDataLine.class);
			Mixer mixer = AudioSystem.getMixer(mInfo);
			
			// if line supported
			if (mixer.isLineSupported(lineInfo))
				mixers.add(mInfo.getName());
			
		});
	
	return mixers;
}
 
開發者ID:goxr3plus,項目名稱:java-stream-player,代碼行數:27,代碼來源:StreamPlayer.java

示例7: getSelectedMixer

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
/**
 * Gets the Mixer to use. Depends upon selectedMixerIndex being defined.
 *
 * @see #newProperties
 */
private Mixer getSelectedMixer() {
	if (selectedMixerIndex.equals("default")) {
		return null;
	} else {
		Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
		if (selectedMixerIndex.equals("last")) {
			return AudioSystem.getMixer(mixerInfo[mixerInfo.length - 1]);
		} else {
			int index = Integer.parseInt(selectedMixerIndex);
			return AudioSystem.getMixer(mixerInfo[index]);
		}
	}
}
 
開發者ID:CognitiveModeling,項目名稱:BrainControl,代碼行數:19,代碼來源:Microphone.java

示例8: 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:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:DirectAudioDeviceProvider.java

示例9: main

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    boolean res=true;
    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    for (int i = 0; i < mixerInfo.length; i++) {
        Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
        System.out.println(mixer);
        Line.Info[] lineinfo = mixer.getSourceLineInfo();
        for (int j = 0; j < lineinfo.length; j++) {
            System.out.println("  " + lineinfo[j]);
            try {
                AudioFormat[] formats = ((DataLine.Info)lineinfo[j]).getFormats();
                for (int k = 0; k < formats.length; k++) {
                    if ( (formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
                          || formats[k].getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED))
                         && (formats[k].getFrameSize() != AudioSystem.NOT_SPECIFIED)
                         && ((formats[k].getSampleSizeInBits() == 16) || (formats[k].getSampleSizeInBits() == 8))
                         && ((((formats[k].getSampleSizeInBits() + 7) / 8) * formats[k].getChannels()) != formats[k].getFrameSize())) {
                        System.out.println(" # " + formats[k] + ", getFrameSize() wrongly returns"+ formats[k].getFrameSize());
                        res=false;
                    }
                }
            } catch (ClassCastException e) {
            }
        }
    }

    if (res) {
        System.out.println("Test passed");
    } else {
        System.out.println("Test failed");
        throw new Exception("Test failed");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:FrameSizeTest.java

示例10: main

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
public static void main(String argv[]) throws Exception {
    boolean success = true;

    Mixer.Info [] infos = AudioSystem.getMixerInfo();

    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        System.out.println("Mixer is: " + mixer);
        Line.Info [] target_line_infos = mixer.getTargetLineInfo();
        for (int j = 0; j < target_line_infos.length; j++) {
            try {
                System.out.println("Trying to get:" + target_line_infos[j]);
                mixer.getLine(target_line_infos[j]);
            } catch (IllegalArgumentException iae) {
                System.out.println("Unexpected IllegalArgumentException raised:");
                iae.printStackTrace();
                success = false;
            } catch (LineUnavailableException lue) {
                System.out.println("Unexpected LineUnavailableException raised:");
                lue.printStackTrace();
                success = false;
            }
        }
    }
    if (success) {
        System.out.println("Test passed");
    } else {
        throw new Exception("Test FAILED");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:UnexpectedIAE.java

示例11: getMixer

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
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.");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:PortMixerProvider.java

示例12: main

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    println("This is an interactive test for DirectAudio.");
    println("If it's impossible to play data after an underun, the test fails.");
    println("");
    println("Make sure that you have speakers connected");
    println("and that the system mixer is not muted.");
    println("Also stop all other programs playing sounds:");
    println("It has been seen that it alters the results.");
    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.");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:48,代碼來源:DirectSoundUnderrunSilence.java

示例13: getMixerInfo

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
@Override
public final Mixer.Info getMixerInfo() {
    return mixerInfo;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:AbstractMixer.java

示例14: getMixerInfo

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
public final Mixer.Info getMixerInfo() {
    return mixerInfo;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:4,代碼來源:AbstractMixer.java

示例15: isMixerSupported

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
/**
 * 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}
 * @throws NullPointerException if {@code info} is {@code null}
 * @see #getMixerInfo()
 */
public boolean isMixerSupported(Mixer.Info info) {
    Objects.requireNonNull(info);

    Mixer.Info infos[] = getMixerInfo();

    for(int i=0; i<infos.length; i++){
        if( info.equals( infos[i] ) ) {
            return true;
        }
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:MixerProvider.java


注:本文中的javax.sound.sampled.Mixer.Info方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。