jmri.jmrit.audio
Class JavaSoundAudioBuffer

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.AbstractAudio
          extended by jmri.jmrit.audio.AbstractAudioBuffer
              extended by jmri.jmrit.audio.JavaSoundAudioBuffer
All Implemented Interfaces:
Serializable, Audio, AudioBuffer, NamedBean

public class JavaSoundAudioBuffer
extends AbstractAudioBuffer

JavaSound implementation of the Audio Buffer 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, 2011
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmri.jmrit.audio.AbstractAudioBuffer
LOOP_POINT_BOTH, LOOP_POINT_END, LOOP_POINT_START
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.jmrit.audio.AudioBuffer
FORMAT_16BIT_5DOT1, FORMAT_16BIT_6DOT1, FORMAT_16BIT_7DOT1, FORMAT_16BIT_MONO, FORMAT_16BIT_QUAD, FORMAT_16BIT_STEREO, FORMAT_8BIT_5DOT1, FORMAT_8BIT_6DOT1, FORMAT_8BIT_7DOT1, FORMAT_8BIT_MONO, FORMAT_8BIT_QUAD, FORMAT_8BIT_STEREO, FORMAT_UNKNOWN
 
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
JavaSoundAudioBuffer(String systemName)
          Constructor for new JavaSoundAudioBuffer with system name
JavaSoundAudioBuffer(String systemName, String userName)
          Constructor for new JavaSoundAudioBuffer with system name and user name
 
Method Summary
protected  void cleanUp()
          Abstract method that concrete classes will implement to perform necessary cleanup routines.
protected  void generateLoopBuffers(int which)
          Method used to generate any necessary loop buffers.
protected  boolean generateStreamingBuffers()
          Internal method used to generate buffers for streaming
protected  AudioFormat getAudioFormat()
          Retrieves the format of the sound sample stored in this buffer as an AudioFormat object
protected  byte[] getDataStorageBuffer()
          Return reference to the DataStorageBuffer byte array Applies only to sub-types: Buffer
 int getFormat()
          Retrieves the format of the sound sample stored in this buffer Applies only to sub-types: Buffer
 int getFrequency()
          Retrieves the frequency of the sound sample stored in this buffer Applies only to sub-types: Buffer
 long getLength()
          Retrieves the length of the sound sample stored in this buffer Applies only to sub-types: Buffer
protected  boolean loadBuffer()
          Method used to load the actual sound data into the buffer
protected  boolean loadBuffer(InputStream stream)
          Method used to load the actual sound data from an InputStream into the buffer
protected  void removeStreamingBuffers()
          Internal method used to remove streaming buffers
 String toString()
           
 
Methods inherited from class jmri.jmrit.audio.AbstractAudioBuffer
getEndLoopPoint, getFrameSize, getStartLoopPoint, getSubType, getURL, isStreamed, isStreamedForced, setEndLoopPoint, setEndLoopPoint, setInputStream, setStartLoopPoint, setStartLoopPoint, setStreamed, setStreamedForced, setURL, stateChanged
 
Methods inherited from class jmri.implementation.AbstractAudio
getState, 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, getState, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setState, setUserName, updateListenerRef
 

Constructor Detail

JavaSoundAudioBuffer

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

Parameters:
systemName - AudioBuffer object system name (e.g. IAB4)

JavaSoundAudioBuffer

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

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

getDataStorageBuffer

protected byte[] getDataStorageBuffer()
Return reference to the DataStorageBuffer byte array

Applies only to sub-types:


getAudioFormat

protected AudioFormat getAudioFormat()
Retrieves the format of the sound sample stored in this buffer as an AudioFormat object

Returns:
audio format as an AudioFormat object

toString

public String toString()
Overrides:
toString in class AbstractAudio

loadBuffer

protected boolean loadBuffer(InputStream stream)
Description copied from class: AbstractAudioBuffer
Method used to load the actual sound data from an InputStream into the buffer

Specified by:
loadBuffer in class AbstractAudioBuffer
Parameters:
stream - InputStream containing sound data
Returns:
True if successful; False if not

loadBuffer

protected boolean loadBuffer()
Description copied from class: AbstractAudioBuffer
Method used to load the actual sound data into the buffer

Specified by:
loadBuffer in class AbstractAudioBuffer
Returns:
True if successful; False if not

generateLoopBuffers

protected void generateLoopBuffers(int which)
Description copied from class: AbstractAudioBuffer
Method used to generate any necessary loop buffers.

Specified by:
generateLoopBuffers in class AbstractAudioBuffer
Parameters:
which - the loop buffer to generate:
AbstractAudioBuffer.LOOP_POINT_START for the start loop buffer
AbstractAudioBuffer.LOOP_POINT_END for the end loop buffer
AbstractAudioBuffer.LOOP_POINT_BOTH for both loop buffers

generateStreamingBuffers

protected boolean generateStreamingBuffers()
Description copied from class: AbstractAudioBuffer
Internal method used to generate buffers for streaming

Specified by:
generateStreamingBuffers in class AbstractAudioBuffer
Returns:
True if successful; False if not

removeStreamingBuffers

protected void removeStreamingBuffers()
Description copied from class: AbstractAudioBuffer
Internal method used to remove streaming buffers

Specified by:
removeStreamingBuffers in class AbstractAudioBuffer

getFormat

public int getFormat()
Description copied from interface: AudioBuffer
Retrieves the format of the sound sample stored in this buffer

Applies only to sub-types:

Returns:
constant representing format

getLength

public long getLength()
Description copied from interface: AudioBuffer
Retrieves the length of the sound sample stored in this buffer

Applies only to sub-types:

Returns:
length of sound sample in frames
See Also:
AudioBuffer.getFrameSize()

getFrequency

public int getFrequency()
Description copied from interface: AudioBuffer
Retrieves the frequency of the sound sample stored in this buffer

Applies only to sub-types:

Returns:
frequency of sound sample in Hz

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


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