Package com.mojang.blaze3d.audio
Class Channel
java.lang.Object
com.mojang.blaze3d.audio.Channel
Represents an OpenAL audio channel.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprivate final AtomicBooleanprivate static final org.slf4j.Loggerprivate static final intprivate final intprivate AudioStreamprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachBufferStream(AudioStream stream) Attaches a buffer stream to the audio channel.voidattachStaticBuffer(SoundBuffer buffer) Attaches a static buffer to the audio channel.private static intcalculateBufferSize(AudioFormat format, int sampleAmount) Calculates the buffer size for an audio stream.(package private) static Channelcreate()voiddestroy()voidprivate intgetState()voidlinearAttenuation(float linearAttenuation) Sets linear attenuation for the audio channel.voidpause()voidplay()booleanplaying()private voidpumpBuffers(int readCount) Reads and queues audio buffers from the stream.private intvoidsetLooping(boolean looping) Sets whether the audio channel should loop.voidsetPitch(float pitch) Sets the pitch of the audio channel.voidsetRelative(boolean relative) Sets whether the audio channel should be relative to the listener's position.voidsetSelfPosition(Vec3 source) Sets the position of the audio channel.voidsetVolume(float volume) Sets the volume of the audio channel.voidstop()booleanstopped()voidunpause()void
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
QUEUED_BUFFER_COUNT
private static final int QUEUED_BUFFER_COUNT- See Also:
-
BUFFER_DURATION_SECONDS
public static final int BUFFER_DURATION_SECONDS- See Also:
-
source
private final int source -
initialized
-
streamingBufferSize
private int streamingBufferSize -
stream
-
-
Constructor Details
-
Channel
private Channel(int source)
-
-
Method Details
-
create
-
destroy
public void destroy() -
play
public void play() -
getState
private int getState() -
pause
public void pause() -
unpause
public void unpause() -
stop
public void stop() -
playing
public boolean playing() -
stopped
public boolean stopped() -
setSelfPosition
Sets the position of the audio channel.- Parameters:
source- the position of the audio channel
-
setPitch
public void setPitch(float pitch) Sets the pitch of the audio channel.- Parameters:
pitch- the pitch of the audio channel
-
setLooping
public void setLooping(boolean looping) Sets whether the audio channel should loop.- Parameters:
looping-trueif the audio channel should loop,falseotherwise
-
setVolume
public void setVolume(float volume) Sets the volume of the audio channel.- Parameters:
volume- the volume of the audio channel
-
disableAttenuation
public void disableAttenuation() -
linearAttenuation
public void linearAttenuation(float linearAttenuation) Sets linear attenuation for the audio channel.- Parameters:
linearAttenuation- the linear attenuation of the audio channel
-
setRelative
public void setRelative(boolean relative) Sets whether the audio channel should be relative to the listener's position.- Parameters:
relative-trueif the audio channel should be relative,falseotherwise
-
attachStaticBuffer
Attaches a static buffer to the audio channel.- Parameters:
buffer- the buffer to attach
-
attachBufferStream
Attaches a buffer stream to the audio channel.- Parameters:
stream- the stream to attach
-
calculateBufferSize
Calculates the buffer size for an audio stream.- Parameters:
format- the audio format of the streamsampleAmount- the number of samples to buffer- Returns:
- the buffer size
-
pumpBuffers
private void pumpBuffers(int readCount) Reads and queues audio buffers from the stream.- Parameters:
readCount- the number of buffers to read and queue
-
updateStream
public void updateStream() -
removeProcessedBuffers
private int removeProcessedBuffers()
-