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


Java AudioInputStream.available方法代碼示例

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


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

示例1: testAIS

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
/**
 * Tests the {@code AudioInputStream} fetched from the fake header.
 * <p>
 * Note that the frameLength is stored as long which means that {@code
 * AudioInputStream} must store all possible data from wave file.
 */
private static void testAIS(final byte[] type, final int rate,
                            final int channel, final long size)
        throws Exception {
    final byte[] header = createHeader(type, rate, channel, size);
    final ByteArrayInputStream fake = new ByteArrayInputStream(header);
    final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
    final AudioFormat format = ais.getFormat();
    final long frameLength = size / format.getFrameSize();
    if (frameLength != ais.getFrameLength()) {
        System.err.println("Expected: " + frameLength);
        System.err.println("Actual: " + ais.getFrameLength());
        throw new RuntimeException();
    }
    if (ais.available() < 0) {
        System.err.println("available should be >=0: " + ais.available());
        throw new RuntimeException();
    }

    validateFormat(type[1], rate, channel, format);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:RecognizeHugeWaveFiles.java

示例2: testAIS

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
/**
 * Tests the {@code AudioInputStream} fetched from the fake header.
 * <p>
 * Note that the frameLength is stored as long which means that {@code
 * AudioInputStream} must store all possible data from wave file.
 */
private static void testAIS(final int[] type, final int rate,
                            final int channel, final long size)
        throws Exception {
    final byte[] header = createHeader(type, rate, channel, size);
    final ByteArrayInputStream fake = new ByteArrayInputStream(header);
    final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
    final AudioFormat format = ais.getFormat();
    final long frameLength = size / format.getFrameSize();
    if (frameLength != ais.getFrameLength()) {
        System.err.println("Expected: " + frameLength);
        System.err.println("Actual: " + ais.getFrameLength());
        throw new RuntimeException();
    }
    if (ais.available() < 0) {
        System.err.println("available should be >=0: " + ais.available());
        throw new RuntimeException();
    }

    validateFormat(type[1], rate, channel, format);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:RecognizeHugeWaveExtFiles.java

示例3: testAIS

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
/**
 * Tests the {@code AudioInputStream} fetched from the fake header.
 * <p>
 * Note that the frameLength is stored as long which means that {@code
 * AudioInputStream} must store all possible data from aiff file.
 */
private static void testAIS(final byte bits, final int rate,
                            final int channel, final long frameLength)
        throws Exception {
    final byte[] header = createHeader(bits, rate, channel, frameLength);
    final ByteArrayInputStream fake = new ByteArrayInputStream(header);
    final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
    final AudioFormat format = ais.getFormat();

    if (frameLength != ais.getFrameLength()) {
        System.err.println("Expected: " + frameLength);
        System.err.println("Actual: " + ais.getFrameLength());
        throw new RuntimeException();
    }
    if (ais.available() < 0) {
        System.err.println("available should be >=0: " + ais.available());
        throw new RuntimeException();
    }

    validateFormat(bits, rate, channel, format);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:RecognizeHugeAiffFiles.java

示例4: available

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
@Override
public int available() throws IOException {
    AudioInputStream local_stream = stream;
    if(local_stream != null)
        return local_stream.available();
    return 0;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:SoftSynthesizer.java

示例5: testAIS

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
/**
 * Tests the {@code AudioInputStream} fetched from the fake header.
 * <p>
 * Note that the frameLength is stored as long which means
 * that {@code AudioInputStream} must store all possible data from au file.
 */
private static void testAIS(final byte[] type, final int rate,
                            final int channel, final long size)
        throws Exception {
    final byte[] header = createHeader(type, rate, channel, size);
    final ByteArrayInputStream fake = new ByteArrayInputStream(header);
    final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
    final AudioFormat format = ais.getFormat();
    final long frameLength = size / format.getFrameSize();
    if (size != MAX_UNSIGNED_INT) {
        if (frameLength != ais.getFrameLength()) {
            System.err.println("Expected: " + frameLength);
            System.err.println("Actual: " + ais.getFrameLength());
            throw new RuntimeException();
        }
    } else {
        if (ais.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
            System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
            System.err.println("Actual: " + ais.getFrameLength());
            throw new RuntimeException();
        }
    }
    if (ais.available() < 0) {
        System.err.println("available should be >=0: " + ais.available());
        throw new RuntimeException();
    }
    validateFormat(type[1], rate, channel, format);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:RecognizeHugeAuFiles.java

示例6: available

import javax.sound.sampled.AudioInputStream; //導入方法依賴的package包/類
public int available() throws IOException {
    AudioInputStream local_stream = stream;
    if(local_stream != null)
        return local_stream.available();
    return 0;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:SoftSynthesizer.java


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