Posted by
Xerxes Rånby on
Mar 17, 2014; 3:32pm
URL: https://forum.jogamp.org/playing-audio-from-an-AVI-file-tp4031894p4031938.html
2014-03-17 15:31, TheLittleP [via
jogamp] skrev:
hiya xerxes,
I wonder what could be gained from examining my avi extracter code
when the problem I am trying to solve is why an audio buffer
doesn't work in joal when it works fine in java sound. I would say
the audio buffer extraction is good.
the problem I have with joal is that it doesn't provide an
"AudioFormat" equivalent so it is expecting the audio buffer to be
different that what I am providing.
Please note that Sound3d is a simplified API on top of OpenAL
The javadoc for the sound3d Buffer configure is flawed since it do
not mention all the possible formats that OpenAL support.
http://jogamp.org/deployment/jogamp-current/javadoc/joal/javadoc/com/jogamp/openal/sound3d/Buffer.html#configure%28java.nio.ByteBuffer,%20int,%20int%29
Internally sound3d Buffer uses OpenAL al.alBufferData to setup the
buffer.
al.alBufferData supports the four standard formats mentioned in
Buffer
static int AL_FORMAT_MONO16
static int AL_FORMAT_MONO8
static int AL_FORMAT_STEREO16
static int AL_FORMAT_STEREO8
+ all OpenAL extension formats thus the javadoc for Buffer forget to
mention the possibility to use the following formats found in
ALExtConstants!
static int AL_FORMAT_51CHN_MULAW
static int AL_FORMAT_51CHN16
static int AL_FORMAT_51CHN32
static int AL_FORMAT_51CHN8
static int AL_FORMAT_61CHN_MULAW
static int AL_FORMAT_61CHN16
static int AL_FORMAT_61CHN32
static int AL_FORMAT_61CHN8
static int AL_FORMAT_71CHN_MULAW
static int AL_FORMAT_71CHN16
static int AL_FORMAT_71CHN32
static int AL_FORMAT_71CHN8
static int AL_FORMAT_IMA_ADPCM_MONO16_EXT
static int AL_FORMAT_IMA_ADPCM_STEREO16_EXT
static int AL_FORMAT_MONO_ALAW_EXT
static int AL_FORMAT_MONO_DOUBLE_EXT
static int AL_FORMAT_MONO_FLOAT32
static int AL_FORMAT_MONO_IMA4
static int AL_FORMAT_MONO_MULAW
static int AL_FORMAT_MONO_MULAW_EXT
static int AL_FORMAT_QUAD_MULAW
static int AL_FORMAT_QUAD16
static int AL_FORMAT_QUAD16_LOKI
static int AL_FORMAT_QUAD32
static int AL_FORMAT_QUAD8
static int AL_FORMAT_QUAD8_LOKI
static int AL_FORMAT_REAR_MULAW
static int AL_FORMAT_REAR16
static int AL_FORMAT_REAR32
static int AL_FORMAT_REAR8
static int AL_FORMAT_STEREO_ALAW_EXT
static int AL_FORMAT_STEREO_DOUBLE_EXT
static int AL_FORMAT_STEREO_FLOAT32
static int AL_FORMAT_STEREO_IMA4
static int AL_FORMAT_STEREO_MULAW
static int AL_FORMAT_STEREO_MULAW_EXT
static int AL_FORMAT_VORBIS_EXT
static int AL_FORMAT_WAVE_EXT
Thus in oder to help you figure out which one of these OpenAL
formats that are supported on your hardware JOAL and matches your
sample buffer you may want to use the
com.jogamp.openal.util.ALHelpers
http://jogamp.org/deployment/jogamp-current/javadoc/joal/javadoc/com/jogamp/openal/util/ALHelpers.html
static int getALSampleType(int sampleSize, boolean signed,
boolean fixedP)
Returns the AL sample type matching the given audio type attributes,
or
ALConstants.AL_NONE
.
getALFormat(int alChannelLayout, int alSampleType, boolean
hasSOFTBufferSamples, AL al, ALExt alExt)
Returns a compatible AL buffer format given the AL channel layout
and AL sample type.
This class should provide you with the tools needed to find a
matching AL format that you can pass to the Buffer.configure format
integer argument.
You can get AL and ALExt needed for the ALHelpers class to do its
runtime detection using ALFactory.getAL() and ALFactory.getALExt()
Cheers
Xerxes