jmri.jmrit.audio
Class JoalAudioSource

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.AbstractAudio
          extended by jmri.jmrit.audio.AbstractAudioSource
              extended by jmri.jmrit.audio.JoalAudioSource
All Implemented Interfaces:
Serializable, Audio, AudioSource, NamedBean

public class JoalAudioSource
extends AbstractAudioSource

JOAL implementation of the Audio Source sub-class.

For now, no system-specific implementations are forseen - this will remain internal-only



This software is based on or using the JOAL Library available from http://joal.dev.java.net/

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.



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.

Author:
Matthew Harris copyright (c) 2009
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrit.audio.AbstractAudioSource
AbstractAudioSource.AudioSourceFadeThread, AbstractAudioSource.AudioSourceMoveThread
 
Field Summary
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.jmrit.audio.AudioSource
LOOP_CONTINUOUS, LOOP_NONE
 
Fields inherited from interface jmri.Audio
AT, BUFFER, CMD_BIND_BUFFER, CMD_FADE_IN, CMD_FADE_OUT, CMD_INIT_FACTORY, CMD_LOAD_SOUND, CMD_PAUSE, CMD_PAUSE_TOGGLE, CMD_PLAY, CMD_PLAY_TOGGLE, CMD_RESET_POSITION, CMD_RESUME, CMD_REWIND, CMD_STOP, DECIMAL_PLACES, FADE_IN, FADE_NONE, FADE_OUT, LISTENER, MAX_DISTANCE, SOURCE, STATE_EMPTY, STATE_INITIAL, STATE_LOADED, STATE_MOVING, STATE_PLAYING, STATE_POSITIONED, STATE_STOPPED, UP
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
JoalAudioSource(String systemName)
          Constructor for new JoalAudioSource with system name
JoalAudioSource(String systemName, String userName)
          Constructor for new JoalAudioSource with system name and user name
 
Method Summary
 boolean bindAudioBuffer(AudioBuffer audioBuffer)
          Binds this AudioSource with the specified AudioBuffer Applies only to sub-types: Source
protected  void calculateGain()
          Method to calculate the gain of this AudioSource based on distance from listener and fade levels
protected  void changePosition(Vector3f pos)
          Method to change the current position of this source
protected  void cleanUp()
          Abstract method that concrete classes will implement to perform necessary cleanup routines.
protected  void doFadeIn()
          Fade in then play this AudioSource
protected  void doFadeOut()
          Fade out then stop this AudioSource
protected  void doPause()
          Stop playing the clip but retain the current position
protected  void doPlay()
          Play the clip from the beginning.
protected  void doResume()
          Play the clip from the current position
protected  void doRewind()
          Rewind clip to the beginning
protected  void doStop()
          Stop playing the clip and rewind to the beginning
 int getState()
          Provide generic access to internal state.
 void setDopplerFactor(float dopplerFactor)
          Set the doppler factor of this source Default value = 1.0f Only calculated for JoalAudioSources Applies only to sub-types: Source
 void setGain(float gain)
          Set the gain of this AudioSource object Default value = 1.0f Applies only to sub-types: Listener Source
 void setMaximumDistance(float maximumDistance)
          Set the current maximum distance setting Default value = Audio.MAX_DISTANCE The maximum distance is that where the volume of the sound would normally be zero.
 void setPitch(float pitch)
          Set the pitch of this AudioSource object Values are restricted from 0.5f to 2.0f, i.e. half to double Default value = 1.0f Applies only to sub-types: Source
 void setReferenceDistance(float referenceDistance)
          Set the reference distance of this AudioSource object.
 void setRollOffFactor(float rollOffFactor)
          Set the roll-off factor of this AudioSource object Default value = 1.0f Applies only to sub-types: Source
 void setVelocity(Vector3f vel)
          Sets the velocity of this AudioSource object Applies only to sub-types: Listener Source
 void stateChanged(int oldState)
          Method used to update the current state of the Audio object
 
Methods inherited from class jmri.jmrit.audio.AbstractAudioSource
calculateCurrentPosition, calculateFades, calculateLoops, doResetCurrentPosition, doTogglePause, doTogglePlay, fadeIn, fadeOut, getAssignedBuffer, getAssignedBufferName, getCurrentPosition, getDopplerFactor, getFadeGain, getFadeIn, getFadeOut, getFading, getGain, getMaximumDistance, getMaxLoops, getMinLoops, getNumLoops, getPitch, getPosition, getReferenceDistance, getRollOffFactor, getSubType, getVelocity, isBound, isLooped, pause, play, resetCurrentPosition, resume, rewind, setAssignedBuffer, setAssignedBuffer, setBound, setFadeIn, setFadeOut, setLooped, setMaxLoops, setMinLoops, setPosition, setPosition, setPosition, stop, togglePause, togglePlay, toString
 
Methods inherited from class jmri.implementation.AbstractAudio
roundDecimal, roundDecimal, setState
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, dispose, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setState, setUserName
 

Constructor Detail

JoalAudioSource

public JoalAudioSource(String systemName)
Constructor for new JoalAudioSource with system name

Parameters:
systemName - AudioSource object system name (e.g. IAS1)

JoalAudioSource

public JoalAudioSource(String systemName,
                       String userName)
Constructor for new JoalAudioSource with system name and user name

Parameters:
systemName - AudioSource object system name (e.g. IAS1)
userName - AudioSource object user name
Method Detail

bindAudioBuffer

public boolean bindAudioBuffer(AudioBuffer audioBuffer)
Description copied from interface: AudioSource
Binds this AudioSource with the specified AudioBuffer

Applies only to sub-types:

Parameters:
audioBuffer - the AudioBuffer to bind to this AudioSource
Returns:
true if successful

changePosition

protected void changePosition(Vector3f pos)
Description copied from class: AbstractAudioSource
Method to change the current position of this source

Specified by:
changePosition in class AbstractAudioSource
Parameters:
pos - new position

setVelocity

public void setVelocity(Vector3f vel)
Description copied from interface: AudioSource
Sets the velocity of this AudioSource object

Applies only to sub-types:

Specified by:
setVelocity in interface AudioSource
Overrides:
setVelocity in class AbstractAudioSource
Parameters:
vel - 3d velocity vector

setGain

public void setGain(float gain)
Description copied from interface: AudioSource
Set the gain of this AudioSource object

Default value = 1.0f

Applies only to sub-types:


setPitch

public void setPitch(float pitch)
Description copied from interface: AudioSource
Set the pitch of this AudioSource object

Values are restricted from 0.5f to 2.0f, i.e. half to double

Default value = 1.0f

Applies only to sub-types:

Specified by:
setPitch in interface AudioSource
Overrides:
setPitch in class AbstractAudioSource
Parameters:
pitch - the pitch of this AudioSource

setReferenceDistance

public void setReferenceDistance(float referenceDistance)
Description copied from interface: AudioSource
Set the reference distance of this AudioSource object.

Default value = 1.0f

The Reference Distance is one of the main parameters you have for controlling the way that sounds attenutate with distance. A Source with Reference Distance set to 5 (meters) will be at maximum volume while it is within 5 metere of the listener, and start to fade out as it moves further away. At 10 meters it will be at half volume, and at 20 meters at a quarter volume, etc ...

Applies only to sub-types:

Specified by:
setReferenceDistance in interface AudioSource
Overrides:
setReferenceDistance in class AbstractAudioSource
Parameters:
referenceDistance - the Reference Distance for this AudioSource

setMaximumDistance

public void setMaximumDistance(float maximumDistance)
Description copied from interface: AudioSource
Set the current maximum distance setting

Default value = Audio.MAX_DISTANCE

The maximum distance is that where the volume of the sound would normally be zero.

Applies only to sub-types:

Specified by:
setMaximumDistance in interface AudioSource
Overrides:
setMaximumDistance in class AbstractAudioSource
Parameters:
maximumDistance - maximum distance of this source

setRollOffFactor

public void setRollOffFactor(float rollOffFactor)
Description copied from interface: AudioSource
Set the roll-off factor of this AudioSource object

Default value = 1.0f

Applies only to sub-types:

Specified by:
setRollOffFactor in interface AudioSource
Overrides:
setRollOffFactor in class AbstractAudioSource
Parameters:
rollOffFactor - roll-off factor

setDopplerFactor

public void setDopplerFactor(float dopplerFactor)
Description copied from interface: AudioSource
Set the doppler factor of this source

Default value = 1.0f

Only calculated for JoalAudioSources

Applies only to sub-types:

Specified by:
setDopplerFactor in interface AudioSource
Overrides:
setDopplerFactor in class AbstractAudioSource
Parameters:
dopplerFactor - factor to apply in doppler calculations

getState

public int getState()
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. getCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
getState in interface NamedBean
Overrides:
getState in class AbstractAudio

stateChanged

public void stateChanged(int oldState)
Description copied from interface: Audio
Method used to update the current state of the Audio object

Specified by:
stateChanged in interface Audio
Overrides:
stateChanged in class AbstractAudioSource

doPlay

protected void doPlay()
Description copied from class: AbstractAudioSource
Play the clip from the beginning. If looped, start looping

Specified by:
doPlay in class AbstractAudioSource

doStop

protected void doStop()
Description copied from class: AbstractAudioSource
Stop playing the clip and rewind to the beginning

Specified by:
doStop in class AbstractAudioSource

doPause

protected void doPause()
Description copied from class: AbstractAudioSource
Stop playing the clip but retain the current position

Specified by:
doPause in class AbstractAudioSource

doResume

protected void doResume()
Description copied from class: AbstractAudioSource
Play the clip from the current position

Specified by:
doResume in class AbstractAudioSource

doRewind

protected void doRewind()
Description copied from class: AbstractAudioSource
Rewind clip to the beginning

Specified by:
doRewind in class AbstractAudioSource

doFadeIn

protected void doFadeIn()
Description copied from class: AbstractAudioSource
Fade in then play this AudioSource

Specified by:
doFadeIn in class AbstractAudioSource

doFadeOut

protected void doFadeOut()
Description copied from class: AbstractAudioSource
Fade out then stop this AudioSource

Specified by:
doFadeOut in class AbstractAudioSource

cleanUp

protected void cleanUp()
Description copied from class: AbstractAudio
Abstract method that concrete classes will implement to perform necessary cleanup routines.

Specified by:
cleanUp in class AbstractAudio

calculateGain

protected void calculateGain()
Description copied from class: AbstractAudioSource
Method to calculate the gain of this AudioSource based on distance from listener and fade levels

Specified by:
calculateGain in class AbstractAudioSource


Copyright © 1997 - 2010 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads