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


Java AudioFormat.matches方法代碼示例

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


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

示例1: isConversionSupported

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:FormatConversionProvider.java

示例2: getConvertedStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {

    AudioInputStream cs = null;
    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {
        cs = stream;
    } else {
        cs = new AlawCodecStream(stream, outputFormat);
    }

    return cs;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:AlawCodec.java

示例3: isFormatSupportedInHardware

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public boolean isFormatSupportedInHardware(AudioFormat format) {
    if (format == null) return false;
    for (int i = 0; i < hardwareFormats.length; i++) {
        if (format.matches(hardwareFormats[i])) {
            return true;
        }
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:DirectAudioDevice.java

示例4: getConvertedStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
    AudioInputStream cs = null;

    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {
        cs = stream;
    } else {
        cs = new UlawCodecStream(stream, outputFormat);
    }
    return cs;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:UlawCodec.java

示例5: isContains

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
private static boolean isContains(AudioFormat obj, AudioFormat[] array) {
    for (final AudioFormat format : array) {
        if (obj.matches(format)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:GetTargetIsSupported.java

示例6: open

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:48,代碼來源:AbstractDataLine.java

示例7: getConvertedStream

import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {

    AudioInputStream cs = null;

    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {

        cs = stream;
    } else {

        cs = new PCMtoPCMCodecStream(stream, outputFormat);
    }
    return cs;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:PCMtoPCMCodec.java


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