Interface AudioBuffer
-
- All Superinterfaces:
Audio
,java.lang.Comparable<NamedBean>
,NamedBean
,PropertyChangeProvider
- All Known Implementing Classes:
AbstractAudioBuffer
,JavaSoundAudioBuffer
,JoalAudioBuffer
,NullAudioBuffer
public interface AudioBuffer extends Audio
Represent an AudioBuffer, a place to store or control sound information.The AbstractAudio class contains a basic implementation of the state and messaging code, and forms a useful start for a system-specific implementation. Specific implementations in the jmrix package, e.g. for LocoNet and NCE, will convert to and from the layout commands.
The states and names are Java Bean parameters, so that listeners can be registered to be notified of any changes.
Each AudioBuffer object has a two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, and provides a unique mapping to the layout control system (for example LocoNet or NCE) and address within that system.
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
Fields Modifier and Type Field Description static int
FORMAT_16BIT_5DOT1
Definition of 16-bit 5.1 multi-channel audio format.static int
FORMAT_16BIT_6DOT1
Definition of 16-bit 6.1 multi-channel audio format.static int
FORMAT_16BIT_7DOT1
Definition of 16-bit 7.1 multi-channel audio format.static int
FORMAT_16BIT_MONO
Definition of 16-bit mono audio formatstatic int
FORMAT_16BIT_QUAD
Definition of 16-bit quad multi-channel audio format.static int
FORMAT_16BIT_STEREO
Definition of 16-bit stereo audio formatstatic int
FORMAT_8BIT_5DOT1
Definition of 8-bit 5.1 multi-channel audio format.static int
FORMAT_8BIT_6DOT1
Definition of 8-bit 6.1 multi-channel audio format.static int
FORMAT_8BIT_7DOT1
Definition of 8-bit 7.1 multi-channel audio format.static int
FORMAT_8BIT_MONO
Definition of 8-bit mono audio formatstatic int
FORMAT_8BIT_QUAD
Definition of 8-bit quad multi-channel audio format.static int
FORMAT_8BIT_STEREO
Definition of 8-bit stereo audio formatstatic int
FORMAT_UNKNOWN
Definition of unknown audio format-
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_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, UP
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getEndLoopPoint()
Retrieves the end loop point of the sound sample stored in this bufferint
getFormat()
Retrieves the format of the sound sample stored in this bufferint
getFrameSize()
Retrieves the length of a sound sample frame stored in this bufferint
getFrequency()
Retrieves the frequency of the sound sample stored in this bufferlong
getLength()
Retrieves the length of the sound sample stored in this bufferlong
getStartLoopPoint()
Retrieves the start loop point of the sound sample stored in this bufferjava.lang.String
getURL()
Return the url of the sound sampleboolean
isStreamed()
Retrieves the current streaming setting of this bufferboolean
isStreamedForced()
Determines if this buffer can be loaded in full or if it must be streamed from the file.boolean
loadBuffer(java.nio.ByteBuffer b, int format, int frequency)
void
setEndLoopPoint(long endLoopPoint)
Sets the end loop point of the sound sample stored in this buffervoid
setInputStream(java.io.InputStream stream)
Sets the input stream of the sound samplevoid
setStartLoopPoint(long startLoopPoint)
Sets the start loop point of the sound sample stored in this buffervoid
setStreamed(boolean streamed)
Sets that this buffer is to be streamed as opposed to loaded in full.void
setURL(java.lang.String pUrl)
Sets the url of the sound sample-
Methods inherited from interface jmri.Audio
getSubType, stateChanged
-
Methods 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, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
FORMAT_UNKNOWN
static final int FORMAT_UNKNOWN
Definition of unknown audio format- See Also:
- Constant Field Values
-
FORMAT_8BIT_MONO
static final int FORMAT_8BIT_MONO
Definition of 8-bit mono audio format- See Also:
- Constant Field Values
-
FORMAT_16BIT_MONO
static final int FORMAT_16BIT_MONO
Definition of 16-bit mono audio format- See Also:
- Constant Field Values
-
FORMAT_8BIT_STEREO
static final int FORMAT_8BIT_STEREO
Definition of 8-bit stereo audio format- See Also:
- Constant Field Values
-
FORMAT_16BIT_STEREO
static final int FORMAT_16BIT_STEREO
Definition of 16-bit stereo audio format- See Also:
- Constant Field Values
-
FORMAT_8BIT_QUAD
static final int FORMAT_8BIT_QUAD
Definition of 8-bit quad multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_16BIT_QUAD
static final int FORMAT_16BIT_QUAD
Definition of 16-bit quad multi-channel audio format.These formats are only supported by certain OpenAL implementations and support is determined at runtime.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_8BIT_5DOT1
static final int FORMAT_8BIT_5DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_16BIT_5DOT1
static final int FORMAT_16BIT_5DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_8BIT_6DOT1
static final int FORMAT_8BIT_6DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_16BIT_6DOT1
static final int FORMAT_16BIT_6DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_8BIT_7DOT1
static final int FORMAT_8BIT_7DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
FORMAT_16BIT_7DOT1
static final int FORMAT_16BIT_7DOT1
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.
JavaSound and Null implementations do not support these formats.
- See Also:
- Constant Field Values
-
-
Method Detail
-
getURL
java.lang.String getURL()
Return the url of the sound sampleApplies only to sub-types:
- Buffer
- Returns:
- url
-
setURL
void setURL(java.lang.String pUrl)
Sets the url of the sound sampleApplies only to sub-types:
- Buffer
- Parameters:
pUrl
- URL for location containing sound sample data
-
setInputStream
void setInputStream(java.io.InputStream stream)
Sets the input stream of the sound sampleApplies only to sub-types:
- Buffer
- Parameters:
stream
- InputStream containing sound sample data
-
getFormat
int getFormat()
Retrieves the format of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- constant representing format
-
getLength
long getLength()
Retrieves the length of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- length of sound sample in frames
- See Also:
getFrameSize()
-
getFrequency
int getFrequency()
Retrieves the frequency of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- frequency of sound sample in Hz
-
getFrameSize
int getFrameSize()
Retrieves the length of a sound sample frame stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- length of sound sample frame in bytes
-
setStartLoopPoint
void setStartLoopPoint(long startLoopPoint)
Sets the start loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Parameters:
startLoopPoint
- position of start loop point in samples
-
getStartLoopPoint
long getStartLoopPoint()
Retrieves the start loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- position of start loop point in samples
-
setEndLoopPoint
void setEndLoopPoint(long endLoopPoint)
Sets the end loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Parameters:
endLoopPoint
- position of end loop point in samples
-
getEndLoopPoint
long getEndLoopPoint()
Retrieves the end loop point of the sound sample stored in this bufferApplies only to sub-types:
- Buffer
- Returns:
- position of end loop point in samples
-
setStreamed
void setStreamed(boolean streamed)
Sets that this buffer is to be streamed as opposed to loaded in full. Can only be turned off whenisStreamedForced
is not set.Applies only to sub-types:
- Buffer
- Parameters:
streamed
- buffer is streamed from file or loaded in full- See Also:
isStreamedForced()
-
isStreamed
boolean isStreamed()
Retrieves the current streaming setting of this bufferApplies only to sub-types:
- Buffer
- Returns:
- current streaming setting
-
isStreamedForced
boolean isStreamedForced()
Determines 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
- Returns:
- True if buffer must be streamed; False it can be loaded in full
-
loadBuffer
boolean loadBuffer(java.nio.ByteBuffer b, int format, int frequency)
-
-