Class AbstractAudioBuffer
- All Implemented Interfaces:
Comparable<NamedBean>,Audio,PropertyChangeProvider,AudioBuffer,NamedBean
- Direct Known Subclasses:
JavaSoundAudioBuffer,JoalAudioBuffer,NullAudioBuffer
Specific implementations will extend this base class.
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intIdentifier of both loop pointsprotected static final intIdentifier of end loop pointprotected static final intIdentifier of start loop pointFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields 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_QUEUE_BUFFERS, CMD_RESET_POSITION, CMD_RESUME, CMD_REWIND, CMD_STOP, CMD_UNQUEUE_BUFFERS, 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, UPFields 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_UNKNOWNFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAudioBuffer(String systemName) Abstract constructor for new AudioBuffer with system nameAbstractAudioBuffer(String systemName, String userName) Abstract constructor for new AudioBuffer with system name and user name -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidgenerateLoopBuffers(int which) Method used to generate any necessary loop buffers.protected abstract booleanInternal method used to generate buffers for streaminglongRetrieves the end loop point of the sound sample stored in this bufferintRetrieves the length of a sound sample frame stored in this bufferlongRetrieves the start loop point of the sound sample stored in this buffercharAn Audio object can represent one of a number of subtypes of object.getURL()Return the url of the sound samplebooleanRetrieves the current streaming setting of this bufferbooleanDetermines if this buffer can be loaded in full or if it must be streamed from the file.protected abstract booleanMethod used to load the actual sound data into the bufferprotected abstract booleanMethod used to load the actual sound data from an InputStream into the bufferbooleanloadBuffer(ByteBuffer b, int format, int frequency) protected abstract voidInternal method used to remove streaming buffersvoidsetEndLoopPoint(long endLoopPoint) Sets the end loop point of the sound sample stored in this bufferprotected voidsetEndLoopPoint(long endLoopPoint, boolean generateLoopBuffers) Internal method used to set the end loop point of this buffer with optional generation of loop buffersvoidsetInputStream(InputStream stream) Sets the input stream of the sound samplevoidsetStartLoopPoint(long startLoopPoint) Sets the start loop point of the sound sample stored in this bufferprotected voidsetStartLoopPoint(long startLoopPoint, boolean generateLoopBuffers) Internal method used to set the start loop point of this buffer with optional generation of loop buffersvoidsetStreamed(boolean streamed) Sets that this buffer is to be streamed as opposed to loaded in full.protected voidsetStreamedForced(boolean streamedForced) Protected method used internally to modify the forced streaming flagvoidSets the url of the sound samplevoidstateChanged(int oldState) Method used to update the current state of the Audio objectMethods inherited from class jmri.implementation.AbstractAudio
cleanup, dispose, getBeanType, getState, getUsageReport, roundDecimal, roundDecimal, setStateMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChangeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.jmrit.audio.AudioBuffer
getFormat, getFrequency, getLengthMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getState, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setState, setUserName, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
LOOP_POINT_START
Identifier of start loop point- See Also:
-
LOOP_POINT_END
Identifier of end loop point- See Also:
-
LOOP_POINT_BOTH
Identifier of both loop points- See Also:
-
-
Constructor Details
-
AbstractAudioBuffer
Abstract constructor for new AudioBuffer with system name- Parameters:
systemName- AudioBuffer object system name (e.g. IAB4)
-
AbstractAudioBuffer
Abstract constructor for new AudioBuffer with system name and user name- Parameters:
systemName- AudioBuffer object system name (e.g. IAB4)userName- AudioBuffer object user name
-
-
Method Details
-
getSubType
Description copied from interface:AudioAn Audio object can represent one of a number of subtypes of object.This method enables us to determine which of those subtypes this particular instance is and be able to process accordingly.
Current supported subtypes are:
- B = Buffer
- L = Listener
- S = Source
- Specified by:
getSubTypein interfaceAudio- Returns:
- subType char
-
getURL
Description copied from interface:AudioBufferReturn the url of the sound sampleApplies only to sub-types:
- Buffer
- Specified by:
getURLin interfaceAudioBuffer- Returns:
- url
-
setURL
Description copied from interface:AudioBufferSets the url of the sound sampleApplies only to sub-types:
- Buffer
- Specified by:
setURLin interfaceAudioBuffer- Parameters:
url- URL for location containing sound sample data
-
setInputStream
Description copied from interface:AudioBufferSets the input stream of the sound sampleApplies only to sub-types:
- Buffer
- Specified by:
setInputStreamin interfaceAudioBuffer- Parameters:
stream- InputStream containing sound sample data
-
getFrameSize
Description copied from interface:AudioBufferRetrieves the length of a sound sample frame stored in this bufferApplies only to sub-types:
- Buffer
- Specified by:
getFrameSizein interfaceAudioBuffer- Returns:
- length of sound sample frame in bytes
-
loadBuffer
Method used to load the actual sound data into the buffer- Returns:
- True if successful; False if not
-
loadBuffer
Method used to load the actual sound data from an InputStream into the buffer- Parameters:
s- InputStream containing sound data- Returns:
- True if successful; False if not
-
setStartLoopPoint
Description copied from interface:AudioBufferSets the start loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Specified by:
setStartLoopPointin interfaceAudioBuffer- Parameters:
startLoopPoint- position of start loop point in samples
-
loadBuffer
- Specified by:
loadBufferin interfaceAudioBuffer
-
setStartLoopPoint
Internal method used to set the start loop point of this buffer with optional generation of loop buffers- Parameters:
startLoopPoint- position of start loop point in samplesgenerateLoopBuffers- True if loop buffers to be generated
-
getStartLoopPoint
Description copied from interface:AudioBufferRetrieves the start loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Specified by:
getStartLoopPointin interfaceAudioBuffer- Returns:
- position of start loop point in samples
-
setEndLoopPoint
Description copied from interface:AudioBufferSets the end loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Specified by:
setEndLoopPointin interfaceAudioBuffer- Parameters:
endLoopPoint- position of end loop point in samples
-
setEndLoopPoint
Internal method used to set the end loop point of this buffer with optional generation of loop buffers- Parameters:
endLoopPoint- position of end loop point in samplesgenerateLoopBuffers- True if loop buffers to be generated
-
getEndLoopPoint
Description copied from interface:AudioBufferRetrieves the end loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Specified by:
getEndLoopPointin interfaceAudioBuffer- Returns:
- position of end loop point in samples
-
setStreamed
Description copied from interface:AudioBufferSets that this buffer is to be streamed as opposed to loaded in full. Can only be turned off whenisStreamedForcedis not set.Applies only to sub-types:
- Buffer
- Specified by:
setStreamedin interfaceAudioBuffer- Parameters:
streamed- buffer is streamed from file or loaded in full- See Also:
-
isStreamed
Description copied from interface:AudioBufferRetrieves the current streaming setting of this bufferApplies only to sub-types:
- Buffer
- Specified by:
isStreamedin interfaceAudioBuffer- Returns:
- current streaming setting
-
setStreamedForced
Protected method used internally to modify the forced streaming flag- Parameters:
streamedForced- True if required; False if not
-
isStreamedForced
Description copied from interface:AudioBufferDetermines if this buffer can be loaded in full or if it must be streamed from the file. Forced streaming is usually restricted to larger sound samples that are otherwise too large to fit directly into memory.Applies only to sub-types:
- Buffer
- Specified by:
isStreamedForcedin interfaceAudioBuffer- Returns:
- True if buffer must be streamed; False it can be loaded in full
-
generateLoopBuffers
Method used to generate any necessary loop buffers.- Parameters:
which- the loop buffer to generate:LOOP_POINT_STARTfor the start loop bufferLOOP_POINT_ENDfor the end loop bufferLOOP_POINT_BOTHfor both loop buffers
-
generateStreamingBuffers
Internal method used to generate buffers for streaming- Returns:
- True if successful; False if not
-
removeStreamingBuffers
Internal method used to remove streaming buffers -
stateChanged
Description copied from interface:AudioMethod used to update the current state of the Audio object- Specified by:
stateChangedin interfaceAudio- Parameters:
oldState- the former state
-