35package com.jogamp.openal.util;
37import java.io.BufferedInputStream;
38import java.io.IOException;
39import java.io.InputStream;
40import java.nio.ByteBuffer;
41import java.nio.ByteOrder;
43import com.jogamp.common.util.IOUtil;
44import com.jogamp.openal.ALConstants;
45import com.jogamp.openal.UnsupportedAudioFileException;
55 public final ByteBuffer
data;
100 public static WAVData loadFromStream(InputStream aIn,
final int byteCount,
final int numChannels,
final int bits,
final int sampleRate,
final ByteOrder byteOrder,
final boolean loop)
102 if( !(aIn instanceof BufferedInputStream) ) {
103 aIn =
new BufferedInputStream(aIn);
108 if ((bits == 8) && (numChannels == 1)) {
110 }
else if ((bits == 16) && (numChannels == 1)) {
112 }
else if ((bits == 8) && (numChannels == 2)) {
114 }
else if ((bits == 16) && (numChannels == 2)) {
117 final ByteBuffer buffer = IOUtil.copyStreamChunk2ByteBuffer(aIn, 0, byteCount);
118 final int actualSize = buffer.limit();
121 if ( bits == 16 && ByteOrder.nativeOrder() != byteOrder ) {
122 final int len = buffer.remaining();
123 for (
int i = 0; i < len; i += 2) {
124 final byte a = buffer.get(i);
125 final byte b = buffer.get(i+1);
This class is a holder for WAV (.wav ) file Data returned from the WavLoader, or directly via loadFro...
final int format
the format of the Data.
WAVData(final ByteBuffer data, final int format, final int size, final int freq, final boolean loop)
final ByteBuffer data
The audio data.
final boolean loop
flag indicating whether or not the sound in the data should loop
final int size
Size (in bytes) of the data.
final int freq
The frequency of the data.
static WAVData loadFromStream(InputStream aIn, final int byteCount, final int numChannels, final int bits, final int sampleRate, final ByteOrder byteOrder, final boolean loop)
This method loads a (.wav) file into a WAVData object.
static final int AL_FORMAT_MONO8
Define "AL_FORMAT_MONO8" with expression '0x1100', CType: int.
static final int AL_FORMAT_STEREO16
Define "AL_FORMAT_STEREO16" with expression '0x1103', CType: int.
static final int AL_FORMAT_STEREO8
Define "AL_FORMAT_STEREO8" with expression '0x1102', CType: int.
static final int AL_FORMAT_MONO16
Define "AL_FORMAT_MONO16" with expression '0x1101', CType: int.