public class Source extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
attModel
Attenuation model to use for this source.
|
Channel |
channel
Channel to play this source on.
|
protected ICodec |
codec
Codec used to read data for streaming sources.
|
float |
distanceFromListener
This source's distance from the listener.
|
float |
distOrRoll
Either fade distance or rolloff factor, depending on the value of attModel.
|
protected float |
fadeInGain
Specifies the gain factor used for the fade-in effect, or 1 when
source is not currently fading in.
|
protected long |
fadeInMilis
Specifies the number of miliseconds it should take to fade in.
|
protected float |
fadeOutGain
Specifies the gain factor used for the fade-out effect, or -1 when
source is not currently fading out.
|
protected long |
fadeOutMilis
Specifies the number of miliseconds it should take to fade out.
|
FilenameURL |
filenameURL
The audio file which this source should play.
|
float |
gain
This source's volume (a float between 0.0 - 1.0).
|
protected long |
lastFadeCheck
System time in miliseconds when the last fade in/out volume check occurred.
|
protected Class |
libraryType
The library class associated with this type of channel.
|
protected float |
pitch
This value represents the source's pitch (float value between 0.5f - 2.0f).
|
com.badlogic.gdx.math.Vector3 |
position
This source's position in 3D space.
|
boolean |
preLoad
Used by streaming sources to indicate whether or not the initial
stream-buffers still need to be queued.
|
boolean |
priority
Determines whether or not this is a priority source.
|
AudioFormat |
rawDataFormat
Format the raw data will be in if this is a Raw Data Stream source.
|
boolean |
rawDataStream
True if this source is being directly fed with raw audio data.
|
SoundBuffer |
soundBuffer
Holds the data used by normal sources.
|
protected Object |
soundSequenceLock
Ensures that only one thread accesses the soundSequenceQueue at a time.
|
protected LinkedList<FilenameURL> |
soundSequenceQueue
The list of files to stream when the current stream finishes.
|
String |
sourcename
Unique name for this source.
|
float |
sourceVolume
This value should be used to manually increase or decrease source volume.
|
boolean |
temporary
Determines whether a source should be removed after it finishes playing.
|
boolean |
toLoop
Whether this source should loop or only play once.
|
boolean |
toPlay
Whether this source needs to be played (for example if it was playing and
looping when it got culled).
|
boolean |
toStream
Whether or not this source should be streamed.
|
com.badlogic.gdx.math.Vector3 |
velocity
Source's velocity in world-space, for use in Doppler effect.
|
| Constructor and Description |
|---|
Source(AudioFormat audioFormat,
boolean priority,
String sourcename,
float x,
float y,
float z,
int attModel,
float distOrRoll)
Constructor: Creates a new streaming source that will be directly fed with
raw audio data.
|
Source(boolean priority,
boolean toStream,
boolean toLoop,
String sourcename,
FilenameURL filenameURL,
SoundBuffer soundBuffer,
float x,
float y,
float z,
int attModel,
float distOrRoll,
boolean temporary)
Constructor: Creates a new source using the specified parameters.
|
Source(Source old,
SoundBuffer soundBuffer)
Constructor: Creates a new source matching the specified one.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Allows a previously culled source to be played again.
|
boolean |
active()
Returns false if the source has been culled.
|
void |
changeSource(boolean priority,
boolean toStream,
boolean toLoop,
String sourcename,
FilenameURL filenameURL,
SoundBuffer soundBuffer,
float x,
float y,
float z,
int attModel,
float distOrRoll,
boolean temporary)
Changes the sources peripheral information to match the supplied parameters.
|
boolean |
checkFadeOut()
Resets this source's volume if it is fading out or in.
|
void |
cleanup()
Shuts the source down and removes references to all instantiated objects.
|
void |
cull()
Stops and flushes the source, and prevents it from being played again until
the activate() is called.
|
void |
dequeueSound(String filename)
Removes the first occurrence of the specified filename from the list of
sounds to play when the previous stream ends.
|
protected boolean |
errorCheck(boolean error,
String message)
Prints the specified message if error is true.
|
protected void |
errorMessage(String message)
Prints an error message.
|
void |
fadeOut(FilenameURL filenameURL,
long milis)
Fades out the volume of whatever this source is currently playing, then
begins playing the specified filename at the source's previously assigned
volume level.
|
void |
fadeOutIn(FilenameURL filenameURL,
long milisOut,
long milisIn)
Fades out the volume of whatever this source is currently playing, then
fades the volume back in playing the specified file.
|
int |
feedRawAudioData(Channel c,
byte[] buffer)
Feeds raw data to the specified channel.
|
void |
flush()
Dequeues any previously queued data.
|
String |
getClassName()
Returns the name of the class.
|
float |
getDistanceFromListener()
Returns the source's distance from the listener.
|
float |
getPitch()
Returns the pitch of the specified source.
|
int |
getSoundSequenceQueueSize()
Returns the size of the sound sequence queue (if this is a streaming source).
|
protected void |
importantMessage(String message)
Prints an important message.
|
boolean |
incrementSoundSequence()
Removes the next filename/URL from the sound sequence queue and assigns it to
this source.
|
void |
listenerMoved()
Called every time the listener's position or orientation changes.
|
protected void |
message(String message)
Prints a message.
|
float |
millisecondsPlayed()
Returns the number of miliseconds since the source began playing.
|
void |
pause()
Pauses the source.
|
boolean |
paused()
Returns true if the source has been paused.
|
void |
play(Channel c)
Plays the source on the specified channel.
|
boolean |
playing()
Returns true if the source is playing.
|
void |
positionChanged()
Called every time the source changes position.
|
boolean |
preLoad()
Queues up the initial stream-buffers for the stream.
|
protected void |
printStackTrace(Exception e)
Prints an exception's error message followed by the stack trace.
|
void |
queueSound(FilenameURL filenameURL)
If this is a streaming source, queues up the next sound to play when
the previous stream ends.
|
boolean |
reverseByteOrder()
Indicates whether or not this source's associated library requires some
codecs to reverse-order the audio data they generate.
|
void |
rewind()
Rewinds the source.
|
void |
setAttenuation(int model)
Sets this source's attenuation model.
|
void |
setDistOrRoll(float dr)
Sets this source's fade distance or rolloff factor, depending on the
attenuation model.
|
void |
setLooping(boolean lp)
Sets whether this source should loop or only play once.
|
void |
setPitch(float value)
Manually sets the specified source's pitch.
|
void |
setPosition(float x,
float y,
float z)
Moves the source to the specified position.
|
void |
setPriority(boolean pri)
Sets whether or not this source is a priority source.
|
void |
setTemporary(boolean tmp)
Sets whether or not this source should be removed when it finishes playing.
|
void |
setVelocity(float x,
float y,
float z)
Sets this source's velocity, for use in Doppler effect.
|
void |
stop()
Stops the source.
|
boolean |
stopped()
Returns true if the source has been stopped.
|
boolean |
stream()
Streams the source on its current channel
|
protected Class libraryType
public boolean rawDataStream
public AudioFormat rawDataFormat
public boolean temporary
public boolean priority
public boolean toStream
public boolean toLoop
public boolean toPlay
public String sourcename
public FilenameURL filenameURL
public com.badlogic.gdx.math.Vector3 position
public int attModel
public float distOrRoll
public com.badlogic.gdx.math.Vector3 velocity
public float gain
public float sourceVolume
protected float pitch
public float distanceFromListener
public Channel channel
public SoundBuffer soundBuffer
protected ICodec codec
protected LinkedList<FilenameURL> soundSequenceQueue
protected final Object soundSequenceLock
public boolean preLoad
protected float fadeOutGain
protected float fadeInGain
protected long fadeOutMilis
protected long fadeInMilis
protected long lastFadeCheck
public Source(boolean priority,
boolean toStream,
boolean toLoop,
String sourcename,
FilenameURL filenameURL,
SoundBuffer soundBuffer,
float x,
float y,
float z,
int attModel,
float distOrRoll,
boolean temporary)
priority - Setting this to true will prevent other sounds from overriding this one.toStream - Setting this to true will create a streaming source.toLoop - Should this source loop, or play only once.sourcename - A unique identifier for this source. Two sources may not use the same sourcename.filenameURL - The filename/URL of the sound file to play at this source.soundBuffer - Buffer containing audio data, or null if not loaded yet.x - X position for this source.y - Y position for this source.z - Z position for this source.attModel - Attenuation model to use.distOrRoll - Either the fading distance or rolloff factor, depending on the value of 'att'.temporary - Whether or not to remove this source after it finishes playing.public Source(Source old, SoundBuffer soundBuffer)
old - Source to copy information from.soundBuffer - Buffer containing audio data, or null if not loaded yet.public Source(AudioFormat audioFormat, boolean priority, String sourcename, float x, float y, float z, int attModel, float distOrRoll)
audioFormat - Format that the data will be in.priority - Setting this to true will prevent other sounds from overriding this one.sourcename - A unique identifier for this source. Two sources may not use the same sourcename.x - X position for this source.y - Y position for this source.z - Z position for this source.attModel - Attenuation model to use.distOrRoll - Either the fading distance or rolloff factor, depending on the value of 'att'.public void cleanup()
public void queueSound(FilenameURL filenameURL)
filenameURL - The filename/URL of the sound file to stream next.public void dequeueSound(String filename)
filename - Filename/identifier of a sound file to remove from the queue.public void fadeOut(FilenameURL filenameURL, long milis)
filenameURL - Filename/URL of the sound file to play next, or null for none.milis - Number of miliseconds the fadeout should take.public void fadeOutIn(FilenameURL filenameURL, long milisOut, long milisIn)
filenameURL - Filename/URL of the sound file to play next, or null for none.milisOut - Number of miliseconds the fadeout should take.milisIn - Number of miliseconds the fadein should take.public boolean checkFadeOut()
public boolean incrementSoundSequence()
public int getSoundSequenceQueueSize()
public void setTemporary(boolean tmp)
tmp - True or false.public void listenerMoved()
public void setPosition(float x,
float y,
float z)
x - X coordinate to move to.y - Y coordinate to move to.z - Z coordinate to move to.public void positionChanged()
public void setPriority(boolean pri)
pri - True or false.public void setLooping(boolean lp)
lp - True or false.public void setAttenuation(int model)
model - Attenuation model to use.public void setDistOrRoll(float dr)
dr - New value for fade distance or rolloff factor.public void setVelocity(float x,
float y,
float z)
x - Velocity along world x-axis.y - Velocity along world y-axis.z - Velocity along world z-axis.public float getDistanceFromListener()
public void setPitch(float value)
value - A float value ( 0.5f - 2.0f ).public float getPitch()
public boolean reverseByteOrder()
public void changeSource(boolean priority,
boolean toStream,
boolean toLoop,
String sourcename,
FilenameURL filenameURL,
SoundBuffer soundBuffer,
float x,
float y,
float z,
int attModel,
float distOrRoll,
boolean temporary)
priority - Setting this to true will prevent other sounds from overriding this one.toStream - Setting this to true will create a streaming source.toLoop - Should this source loop, or play only once.sourcename - A unique identifier for this source. Two sources may not use the same sourcename.filenameURL - Filename/URL of the sound file to play at this source.x - X position for this source.y - Y position for this source.z - Z position for this source.attModel - Attenuation model to use.distOrRoll - Either the fading distance or rolloff factor, depending on the value of 'att'.temporary - Whether or not to remove this source after it finishes playing.public int feedRawAudioData(Channel c, byte[] buffer)
buffer - Byte buffer containing raw audio data to stream.c - Channel to stream on.public void play(Channel c)
c - Channel to play on.public boolean stream()
public boolean preLoad()
public void pause()
public void stop()
public void rewind()
public void flush()
public void cull()
public void activate()
public boolean active()
public boolean playing()
public boolean stopped()
public boolean paused()
public float millisecondsPlayed()
public String getClassName()
protected void message(String message)
message - Message to print.protected void importantMessage(String message)
message - Message to print.protected boolean errorCheck(boolean error,
String message)
error - True or False.message - Message to print if error is true.protected void errorMessage(String message)
message - Message to print.protected void printStackTrace(Exception e)
e - Exception containing the information to print.Copyright © 2017. All rights reserved.