Package com.ardor3d.audio.joal
Class ChannelJOAL
java.lang.Object
com.ardor3d.audio.Channel
com.ardor3d.audio.joal.ChannelJOAL
The ChannelJOAL class is used to reserve a sound-card voice using the
JOAL binding of OpenAL. Channels can be either normal or streaming
channels.
This software is based on or using the JOAL Library available from https://jogamp.org/joal/www/
JOAL License:
Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
SoundSystem LibraryJOAL License:
You are free to use this library for any purpose, commercial or otherwise. You may modify this library or source code, and distribute it any way you like, provided the following conditions are met:
1) You must abide by the conditions of the aforementioned JOAL License.
2) You may not falsely claim to be the author of this library or any unmodified portion of it.
3) You may not copyright this library or a modified version of it and then sue me for copyright infringement.
4) If you modify the source code, you must clearly document the changes made before redistributing the modified source code, so other users know it is not the original code.
5) You are not required to give me credit for this library in any derived work, but if you do, you must also mention my website: http://www.paulscode.com
6) I the author will not be responsible for any damages (physical, financial, or otherwise) caused by the use if this library or any part of it.
7) I the author do not guarantee, warrant, or make any representations, either expressed or implied, regarding the use of this library or any part of it.
Author: Paul Lamb
http://www.paulscode.com
This software is based on or using the JOAL Library available from https://jogamp.org/joal/www/
JOAL License:
Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
SoundSystem LibraryJOAL License:
You are free to use this library for any purpose, commercial or otherwise. You may modify this library or source code, and distribute it any way you like, provided the following conditions are met:
1) You must abide by the conditions of the aforementioned JOAL License.
2) You may not falsely claim to be the author of this library or any unmodified portion of it.
3) You may not copyright this library or a modified version of it and then sue me for copyright infringement.
4) If you modify the source code, you must clearly document the changes made before redistributing the modified source code, so other users know it is not the original code.
5) You are not required to give me credit for this library in any derived work, but if you do, you must also mention my website: http://www.paulscode.com
6) I the author will not be responsible for any damages (physical, financial, or otherwise) caused by the use if this library or any part of it.
7) I the author do not guarantee, warrant, or make any representations, either expressed or implied, regarding the use of this library or any part of it.
Author: Paul Lamb
http://www.paulscode.com
-
Field Summary
Modifier and TypeFieldDescriptionint
OpenAL data format to use when playing back the assigned source.int[]
OpenAL's identifier for this channel.float
Miliseconds of buffers previously played (streaming sources).int
Sample rate (speed) to use for play-back.Fields inherited from class com.ardor3d.audio.Channel
attachedSource, buffersUnqueued, channelType, libraryType
-
Constructor Summary
ConstructorDescriptionChannelJOAL
(int type, int[] src) Constructor: takes channelType identifier and a handle to the OpenAL identifier to use for this channel. -
Method Summary
Modifier and TypeMethodDescriptionboolean
attachBuffer
(int[] buf) Attaches an OpenAL sound-buffer identifier for the sound data to be played back for a normal source.int
Returns the number of queued byte[] buffers that have finished playing.void
cleanup()
Empties the streamBuffers list, stops and deletes the ALSource, shuts the channel down, and removes references to all instantiated objects.void
close()
Stops the channel, dequeues any queued data, and closes the channel.int
feedRawAudioData
(byte[] buffer) Feeds raw data to the stream.void
flush()
Dequeues all previously queued data.float
Calculates the number of milliseconds since the channel began playing.float
millisInBuffer
(int alBufferi) Returns the number of milliseconds of audio contained in specified buffer.void
pause()
Temporarily stops playback for this channel.void
play()
Plays the currently attached normal source, opens this channel up for streaming, or resumes playback if this channel was paused.boolean
playing()
Used to determine if a channel is actively playing a source.boolean
preLoadBuffers
(LinkedList<byte[]> bufferList) Queues up the initial byte[] buffers of data to be streamed.boolean
queueBuffer
(byte[] buffer) Queues up a byte[] buffer of data to be streamed.void
rewind()
Rewinds the attached source to the beginning.void
setAudioFormat
(AudioFormat audioFormat) Sets the channel up to receive the specified audio format.void
setFormat
(int format, int rate) Sets the channel up to receive the specified OpenAL audio format and sample rate.void
stop()
Stops playback for this channel and rewinds the attached source to the beginning.Methods inherited from class com.ardor3d.audio.Channel
errorCheck, errorMessage, getClassName, importantMessage, message, printStackTrace, processBuffer
-
Field Details
-
ALSource
public int[] ALSourceOpenAL's identifier for this channel. -
ALformat
public int ALformatOpenAL data format to use when playing back the assigned source. -
sampleRate
public int sampleRateSample rate (speed) to use for play-back. -
millisPreviouslyPlayed
public float millisPreviouslyPlayedMiliseconds of buffers previously played (streaming sources).
-
-
Constructor Details
-
ChannelJOAL
public ChannelJOAL(int type, int[] src) Constructor: takes channelType identifier and a handle to the OpenAL identifier to use for this channel. Possible values for channel type can be found in theSoundSystemConfig
class.- Parameters:
type
- Type of channel (normal or streaming).src
- Handle to the OpenAL source identifier.
-
-
Method Details
-
cleanup
public void cleanup()Empties the streamBuffers list, stops and deletes the ALSource, shuts the channel down, and removes references to all instantiated objects. -
attachBuffer
public boolean attachBuffer(int[] buf) Attaches an OpenAL sound-buffer identifier for the sound data to be played back for a normal source.- Parameters:
buf
- Identifier for the sound data to play.- Returns:
- False if an error occurred.
-
setAudioFormat
Sets the channel up to receive the specified audio format.- Overrides:
setAudioFormat
in classChannel
- Parameters:
audioFormat
- Format to use when playing the stream data.
-
setFormat
public void setFormat(int format, int rate) Sets the channel up to receive the specified OpenAL audio format and sample rate.- Parameters:
format
- Format to use.rate
- Sample rate (speed) to use.
-
preLoadBuffers
Queues up the initial byte[] buffers of data to be streamed.- Overrides:
preLoadBuffers
in classChannel
- Parameters:
bufferList
- List of the first buffers to be played for a streaming source.- Returns:
- False if problem occurred or if end of stream was reached.
-
queueBuffer
public boolean queueBuffer(byte[] buffer) Queues up a byte[] buffer of data to be streamed.- Overrides:
queueBuffer
in classChannel
- Parameters:
buffer
- The next buffer to be played for a streaming source.- Returns:
- False if an error occurred or if the channel is shutting down.
-
feedRawAudioData
public int feedRawAudioData(byte[] buffer) Feeds raw data to the stream.- Overrides:
feedRawAudioData
in classChannel
- Parameters:
buffer
- Buffer containing raw audio data to stream.- Returns:
- Number of prior buffers that have been processed., or -1 if error.
-
millisInBuffer
public float millisInBuffer(int alBufferi) Returns the number of milliseconds of audio contained in specified buffer.- Parameters:
alBufferi
- buffer identifier- Returns:
- milliseconds, or 0 if unable to calculate.
-
millisecondsPlayed
public float millisecondsPlayed()Calculates the number of milliseconds since the channel began playing.- Overrides:
millisecondsPlayed
in classChannel
- Returns:
- Milliseconds, or -1 if unable to calculate.
-
buffersProcessed
public int buffersProcessed()Returns the number of queued byte[] buffers that have finished playing.- Overrides:
buffersProcessed
in classChannel
- Returns:
- Number of buffers processed.
-
flush
public void flush()Dequeues all previously queued data. -
close
public void close()Stops the channel, dequeues any queued data, and closes the channel. -
play
public void play()Plays the currently attached normal source, opens this channel up for streaming, or resumes playback if this channel was paused. -
pause
public void pause()Temporarily stops playback for this channel. -
stop
public void stop()Stops playback for this channel and rewinds the attached source to the beginning. -
rewind
public void rewind()Rewinds the attached source to the beginning. Stops the source if it was paused. -
playing
public boolean playing()Used to determine if a channel is actively playing a source. This method will return false if the channel is paused or stopped and when no data is queued to be streamed.
-