当前位置: 首页>>代码示例>>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;未经允许,请勿转载。