jmri.jmrit.audio
Class JavaSoundAudioSource

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

public class JavaSoundAudioSource
extends AbstractAudioSource

JavaSound implementation of the Audio Source sub-class.

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

For more information about the JavaSound API, visit http://java.sun.com/products/java-media/sound/


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
JavaSoundAudioSource(String systemName)
          Constructor for new JavaSoundAudioSource with system name
JavaSoundAudioSource(String systemName, String userName)
          Constructor for new JavaSoundAudioSource with system name and user name
 
Method Summary
protected  void calculateGain()
          Method to calculate the gain of this AudioSource based on distance from listener and fade levels
protected  void calculatePan()
          Calculates the panning of this Source between fully left (-1.0f) and fully right (1.0f) Calculated internally from the relative positions of this source and the listener.
protected  void calculatePitch()
          Internal method used to calculate the pitch
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 setGain(float gain)
          Set the gain of this AudioSource object Default value = 1.0f Applies only to sub-types: Listener Source
 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 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, isPositionRelative, pause, play, resetCurrentPosition, resume, rewind, setAssignedBuffer, setAssignedBuffer, setBound, setDopplerFactor, setFadeIn, setFadeOut, setLooped, setMaximumDistance, setMaxLoops, setMinLoops, setPosition, setPosition, setPosition, setPositionRelative, setRollOffFactor, setVelocity, stop, togglePause, togglePlay, toString
 
Methods inherited from class jmri.implementation.AbstractAudio
roundDecimal, roundDecimal, setState
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName, updateListenerRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, dispose, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setState, setUserName, updateListenerRef
 

Constructor Detail

JavaSoundAudioSource

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

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

JavaSoundAudioSource

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

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

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

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

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

calculatePan

protected void calculatePan()
Calculates the panning of this Source between fully left (-1.0f) and fully right (1.0f)

Calculated internally from the relative positions of this source and the listener.


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

calculatePitch

protected void calculatePitch()
Internal method used to calculate the pitch



Copyright © 1997 - 2011 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