Class JoalAudioFactory
- java.lang.Object
-
- jmri.jmrit.audio.AbstractAudioFactory
-
- jmri.jmrit.audio.JoalAudioFactory
-
- All Implemented Interfaces:
AudioFactory
public class JoalAudioFactory extends AbstractAudioFactory
This is the JOAL audio system specific AudioFactory.The JOAL sound system supports, where available, full surround-sound with 3D positioning capabilities.
When only stereo capable hardware is available, it will automatically create an approximation of the desired sound-scape.
This factory initialises JOAL, provides new Joal-specific Audio objects and deals with clean-up operations.
This software is based on or using the JOAL Library available from http://jogamp.org/joal/www/
JOAL is released under the BSD license. The full license terms follow:
Copyright (c) 2003-2006 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 MICROSYSTEMS, 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.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intAL_FORMAT_51CHN16Definition of 16-bit 5.1 multi-channel audio format.(package private) static intAL_FORMAT_51CHN8Definition of 8-bit 5.1 multi-channel audio format.(package private) static intAL_FORMAT_61CHN16Definition of 16-bit 6.1 multi-channel audio format.(package private) static intAL_FORMAT_61CHN8Definition of 8-bit 6.1 multi-channel audio format.(package private) static intAL_FORMAT_71CHN16Definition of 16-bit 7.1 multi-channel audio format.(package private) static intAL_FORMAT_71CHN8Definition of 8-bit 7.1 multi-channel audio format.(package private) static intAL_FORMAT_QUAD16Definition of 16-bit quad multi-channel audio format.(package private) static intAL_FORMAT_QUAD8Definition of 8-bit quad multi-channel audio format.(package private) static int[]uiEffect(package private) static int[]uiEffectSlots
-
Constructor Summary
Constructors Constructor Description JoalAudioFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancheckALCError(com.jogamp.openal.ALCdevice alcDevice)Method to check if any error has occurred in the OpenAL sub-system.static booleancheckALCError(com.jogamp.openal.ALCdevice alcDevice, java.lang.String msg)Method to check if any error has occurred in the OpenAL context sub-system.static booleancheckALError()Method to check if any error has occurred in the OpenAL sub-system.static booleancheckALError(java.lang.String msg)Method to check if any error has occurred in the OpenAL sub-system.voidcleanup()Perform any implementation specific clean-up operations.AudioBuffercreateNewBuffer(java.lang.String systemName, java.lang.String userName)Provide a specific new AudioBuffer object.AudioListenercreateNewListener(java.lang.String systemName, java.lang.String userName)Provide a specific new AudioListener object.AudioSourcecreateNewSource(java.lang.String systemName, java.lang.String userName)Provide a specific new AudioSource object.AudioListenergetActiveAudioListener()Get the currently active Listener object.static com.jogamp.openal.ALgetAL()Return a reference to the active AL object for use by other Joal objectsbooleaninit()Initialise this JoalAudioFactory and check for multi-channel support.booleanisInitialised()Determine if this AudioFactory is initialised(package private) static intloadEffect()voidsetDistanceAttenuated(boolean attenuated)Set if this AudioFactory should attenuate sources based on their distance from the listener.java.lang.StringtoString()-
Methods inherited from class jmri.jmrit.audio.AbstractAudioFactory
audioCommandQueue, getCommandThread, isDistanceAttenuated
-
-
-
-
Field Detail
-
uiEffectSlots
static int[] uiEffectSlots
-
uiEffect
static int[] uiEffect
-
AL_FORMAT_QUAD8
static int AL_FORMAT_QUAD8
Definition of 8-bit quad multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_QUAD16
static int AL_FORMAT_QUAD16
Definition of 16-bit quad multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_51CHN8
static int AL_FORMAT_51CHN8
Definition of 8-bit 5.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_51CHN16
static int AL_FORMAT_51CHN16
Definition of 16-bit 5.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_61CHN8
static int AL_FORMAT_61CHN8
Definition of 8-bit 6.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_61CHN16
static int AL_FORMAT_61CHN16
Definition of 16-bit 6.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_71CHN8
static int AL_FORMAT_71CHN8
Definition of 8-bit 7.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
AL_FORMAT_71CHN16
static int AL_FORMAT_71CHN16
Definition of 16-bit 7.1 multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
Initially set format to unknown.
-
-
Constructor Detail
-
JoalAudioFactory
public JoalAudioFactory()
-
-
Method Detail
-
init
public boolean init()
Initialise this JoalAudioFactory and check for multi-channel support.Initial values for multi-channel formats are set to unknown as OpenAL implementations are only guaranteed to support MONO and STEREO Buffers.
On initialisation, we need to check if this implementation supports multi-channel formats.
This is done by making alGetEnumValue calls to request the value of the Buffer Format Tag Enum (that will be passed to an alBufferData call). Enum Values are retrieved by string names. The following names are defined for multi-channel wave formats ...
- "AL_FORMAT_QUAD8" : 4 Channel, 8 bit data
- "AL_FORMAT_QUAD16" : 4 Channel, 16 bit data
- "AL_FORMAT_51CHN8" : 5.1 Channel, 8 bit data
- "AL_FORMAT_51CHN16" : 5.1 Channel, 16 bit data
- "AL_FORMAT_61CHN8" : 6.1 Channel, 8 bit data
- "AL_FORMAT_61CHN16" : 6.1 Channel, 16 bit data
- "AL_FORMAT_71CHN8" : 7.1 Channel, 8 bit data
- "AL_FORMAT_71CHN16" : 7.1 Channel, 16 bit data
- Specified by:
initin interfaceAudioFactory- Overrides:
initin classAbstractAudioFactory- Returns:
- true, if initialisation successful
-
loadEffect
static int loadEffect()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
cleanup
public void cleanup()
Description copied from interface:AudioFactoryPerform any implementation specific clean-up operations.- Specified by:
cleanupin interfaceAudioFactory- Overrides:
cleanupin classAbstractAudioFactory
-
isInitialised
public boolean isInitialised()
Description copied from interface:AudioFactoryDetermine if this AudioFactory is initialised- Returns:
- true if initialised
-
createNewBuffer
public AudioBuffer createNewBuffer(java.lang.String systemName, java.lang.String userName)
Description copied from interface:AudioFactoryProvide a specific new AudioBuffer object.- Parameters:
systemName- for this object instanceuserName- for this object instance- Returns:
- a new specific AudioBuffer
-
createNewListener
public AudioListener createNewListener(java.lang.String systemName, java.lang.String userName)
Description copied from interface:AudioFactoryProvide a specific new AudioListener object.- Parameters:
systemName- for this object instanceuserName- for this object instance- Returns:
- a new specific AudioListener
-
getActiveAudioListener
public AudioListener getActiveAudioListener()
Description copied from interface:AudioFactoryGet the currently active Listener object.- Returns:
- active AudioListener
-
createNewSource
public AudioSource createNewSource(java.lang.String systemName, java.lang.String userName)
Description copied from interface:AudioFactoryProvide a specific new AudioSource object.- Parameters:
systemName- for this object instanceuserName- for this object instance- Returns:
- a new specific AudioSource
-
setDistanceAttenuated
public void setDistanceAttenuated(boolean attenuated)
Description copied from interface:AudioFactorySet if this AudioFactory should attenuate sources based on their distance from the listener.Default = true
- Specified by:
setDistanceAttenuatedin interfaceAudioFactory- Overrides:
setDistanceAttenuatedin classAbstractAudioFactory- Parameters:
attenuated- true if distance attenuation to be used
-
getAL
public static com.jogamp.openal.AL getAL()
Return a reference to the active AL object for use by other Joal objects- Returns:
- active AL object
-
checkALError
public static boolean checkALError()
Method to check if any error has occurred in the OpenAL sub-system.If an error has occurred, log the error as a warning message and return True.
If no error has occurred, return False.
- Returns:
- True if an error has occurred
-
checkALError
public static boolean checkALError(java.lang.String msg)
Method to check if any error has occurred in the OpenAL sub-system.If an error has occurred, log the error as a warning message with the defined message pre-pended and return True.
If no error has occurred, return False.
- Parameters:
msg- additional message prepended to the log- Returns:
- True if an error has occurred
-
checkALCError
public static boolean checkALCError(com.jogamp.openal.ALCdevice alcDevice)
Method to check if any error has occurred in the OpenAL sub-system.If an error has occurred, log the error as a warning message and return True.
If no error has occurred, return False.
- Parameters:
alcDevice- OpenAL context device to check- Returns:
- True if an error has occurred
-
checkALCError
public static boolean checkALCError(com.jogamp.openal.ALCdevice alcDevice, java.lang.String msg)
Method to check if any error has occurred in the OpenAL context sub-system.If an error has occurred, log the error as a warning message with the defined message pre-pended and return True.
If no error has occurred, return False.
- Parameters:
alcDevice- OpenAL context device to checkmsg- additional message prepended to the log- Returns:
- True if an error has occurred
-
-