本文整理汇总了Java中javax.sound.sampled.AudioFileFormat.getByteLength方法的典型用法代码示例。如果您正苦于以下问题:Java AudioFileFormat.getByteLength方法的具体用法?Java AudioFileFormat.getByteLength怎么用?Java AudioFileFormat.getByteLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.AudioFileFormat
的用法示例。
在下文中一共展示了AudioFileFormat.getByteLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AiffFileFormat
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
AiffFileFormat( AudioFileFormat aff ) {
this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
}
示例2: testAFF
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Tests the {@code AudioFileFormat} fetched from the fake header.
* <p>
* Note that the frameLength and byteLength are stored as int which means
* that {@code AudioFileFormat} will store the data above {@code MAX_INT}
* as NOT_SPECIFIED.
*/
private static void testAFF(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 AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
final AudioFormat format = aff.getFormat();
if (aff.getType() != AudioFileFormat.Type.AU) {
throw new RuntimeException("Error");
}
final long frameLength = size / format.getFrameSize();
if (size != MAX_UNSIGNED_INT && frameLength <= Integer.MAX_VALUE) {
if (aff.getFrameLength() != frameLength) {
System.err.println("Expected: " + frameLength);
System.err.println("Actual: " + aff.getFrameLength());
throw new RuntimeException();
}
} else {
if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
System.err.println("Actual: " + aff.getFrameLength());
throw new RuntimeException();
}
}
final long byteLength = size + AU_HEADER;
if (byteLength <= Integer.MAX_VALUE) {
if (aff.getByteLength() != byteLength) {
System.err.println("Expected: " + byteLength);
System.err.println("Actual: " + aff.getByteLength());
throw new RuntimeException();
}
} else {
if (aff.getByteLength() != AudioSystem.NOT_SPECIFIED) {
System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
System.err.println("Actual: " + aff.getByteLength());
throw new RuntimeException();
}
}
validateFormat(type[1], rate, channel, aff.getFormat());
}
示例3: WaveFileFormat
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
WaveFileFormat( AudioFileFormat aff ) {
this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
}
示例4: AuFileFormat
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
AuFileFormat( AudioFileFormat aff ) {
this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
}