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


Java Mixer.getSourceLineInfo方法代碼示例

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


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

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

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

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

示例4: testMixer

import javax.sound.sampled.Mixer; //導入方法依賴的package包/類
private static boolean testMixer(Mixer mixer, Class lineType,
                                 String providerClassName,
                                 String instanceName) {
    boolean allOk = true;

    try {
        String propertyValue = (providerClassName != null) ? providerClassName: "" ;
        propertyValue += "#" + instanceName;
        out("property value: " + propertyValue);
        System.setProperty(lineType.getName(), propertyValue);
        Line line = null;
        Line.Info info = null;
        Line.Info[] infos;
        AudioFormat format = null;
        if (lineType == SourceDataLine.class || lineType == Clip.class) {
            infos = mixer.getSourceLineInfo();
            format = getFirstLinearFormat(infos);
            info = new DataLine.Info(lineType, format);
        } else if (lineType == TargetDataLine.class) {
            infos = mixer.getTargetLineInfo();
            format = getFirstLinearFormat(infos);
            info = new DataLine.Info(lineType, format);
        } else if (lineType == Port.class) {
            /* Actually, a Ports Mixer commonly has source infos
               as well as target infos. We ignore this here, since we
               just need a random one. */
            infos = mixer.getSourceLineInfo();
            for (int i = 0; i < infos.length; i++) {
                if (infos[i] instanceof Port.Info) {
                    info = infos[i];
                    break;
                }
            }
        }
        out("Line.Info: " + info);
        line = AudioSystem.getLine(info);
        out("line: " + line);
        if (! lineType.isInstance(line)) {
            out("type " + lineType + " failed: class should be '" +
                lineType + "' but is '" + line.getClass() + "'!");
            allOk = false;
        }
    } catch (Exception e) {
        out("Exception thrown; Test NOT failed.");
        e.printStackTrace();
    }
    return allOk;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:49,代碼來源:DefaultMixers.java

示例5: main

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


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