本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}