Package net.minecraft.client.sounds
Class SoundEngine
java.lang.Object
net.minecraft.client.sounds.SoundEngine
The
SoundEngine class handles the management and playback of sounds in the game.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelAccessprivate static final longThe default interval in milliseconds for checking the audio device stateprivate final AtomicReference<SoundEngine.DeviceCheckState> The current state of the audio device checkprivate final SoundEngineExecutorprivate final Multimap<SoundSource, SoundInstance> private final Map<SoundInstance, ChannelAccess.ChannelHandle> private longprivate final Libraryprivate final ListenerThe listener object responsible for managing the sound listener position and orientationprivate final List<SoundEventListener> private booleanSet to true when the SoundManager has been initialised.private static final org.slf4j.Loggerprivate static final org.slf4j.MarkerThe marker used for loggingprivate static final intstatic final Stringprivate final MusicManagerprivate static final Set<ResourceLocation> A set of resource locations for which a missing sound warning has been issuedstatic final Stringstatic final intprivate final OptionsReference to the GameSettings object.private static final floatprivate static final floatprivate final Map<SoundInstance, Integer> Contains sounds to play in n ticks.private final List<TickableSoundInstance> private final SoundBufferLibraryprivate final Map<SoundInstance, Integer> The future time in which to stop this sound.final SoundManagerA reference to the sound handler.private intA counter for how long the sound manager has been runningprivate final List<TickableSoundInstance> A subset of playingSounds, this contains only TickableSoundInstanceprivate static final floatprivate static final float -
Constructor Summary
ConstructorsConstructorDescriptionSoundEngine(MusicManager pMusicManager, SoundManager pSoundManager, Options pOptions, ResourceProvider pResourceManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(SoundEventListener pListener) private floatcalculatePitch(SoundInstance pSound) Calculates the pitch of the sound being played.private floatcalculateVolume(float pVolumeMultiplier, SoundSource pSource) Calculates the volume of the sound being played.private floatcalculateVolume(SoundInstance pSound) Calculates the volume for the sound being played.voiddestroy()voidbooleanisActive(SoundInstance pSound) private voidvoidpauseAllExcept(SoundSource... pSoundSources) play(SoundInstance pSound) voidplayDelayed(SoundInstance pSound, int pDelay) Adds a sound to play in n ticksvoidqueueTickingSound(TickableSoundInstance pTickableSound) Queues a newinvalid reference
TickingCodeInstance
voidreload()voidremoveEventListener(SoundEventListener pListener) voidrequestPreload(Sound pSound) Requests a specific Sound instance to be preloaded.private static booleanrequiresManualLooping(SoundInstance pSound) Returns invalid input: 'Returns {@code true} if the SoundInstance requires manual looping, {@code false} otherwise @param pSound the SoundInstance to check'.voidresume()voidsetVolume(SoundInstance pSoundInstance, float pVolume) private booleanprivate static booleanshouldLoopAutomatically(SoundInstance pSound) private static booleanshouldLoopManually(SoundInstance pSound) voidstop(SoundInstance pSound) Stops the provided SoundInstance from continuing to play.voidstop(ResourceLocation pSoundName, SoundSource pCategory) voidstopAll()voidtick(boolean pIsGamePaused) Ticks all active instances ofTickableSoundInstanceprivate voidprivate voidvoidupdateCategoryVolume(SoundSource pCategory) voidupdateSource(Camera pRenderInfo)
-
Field Details
-
MARKER
private static final org.slf4j.Marker MARKERThe marker used for logging -
LOGGER
private static final org.slf4j.Logger LOGGER -
PITCH_MIN
private static final float PITCH_MIN- See Also:
-
PITCH_MAX
private static final float PITCH_MAX- See Also:
-
VOLUME_MIN
private static final float VOLUME_MIN- See Also:
-
VOLUME_MAX
private static final float VOLUME_MAX- See Also:
-
MIN_SOURCE_LIFETIME
private static final int MIN_SOURCE_LIFETIME- See Also:
-
ONLY_WARN_ONCE
A set of resource locations for which a missing sound warning has been issued -
DEFAULT_DEVICE_CHECK_INTERVAL_MS
private static final long DEFAULT_DEVICE_CHECK_INTERVAL_MSThe default interval in milliseconds for checking the audio device state- See Also:
-
MISSING_SOUND
- See Also:
-
OPEN_AL_SOFT_PREFIX
- See Also:
-
OPEN_AL_SOFT_PREFIX_LENGTH
public static final int OPEN_AL_SOFT_PREFIX_LENGTH -
musicManager
-
soundManager
A reference to the sound handler. -
options
Reference to the GameSettings object. -
loaded
private boolean loadedSet to true when the SoundManager has been initialised. -
library
-
listener
The listener object responsible for managing the sound listener position and orientation -
soundBuffers
-
executor
-
channelAccess
-
tickCount
private int tickCountA counter for how long the sound manager has been running -
lastDeviceCheckTime
private long lastDeviceCheckTime -
devicePoolState
The current state of the audio device check -
instanceToChannel
-
instanceBySource
-
tickingSounds
A subset of playingSounds, this contains only TickableSoundInstance -
queuedSounds
Contains sounds to play in n ticks. Type: HashMapinvalid input: '<'ISound, Integer> -
soundDeleteTime
The future time in which to stop this sound. Type: HashMapinvalid input: '<'String, Integer> -
listeners
-
queuedTickableSounds
-
preloadQueue
-
-
Constructor Details
-
SoundEngine
public SoundEngine(MusicManager pMusicManager, SoundManager pSoundManager, Options pOptions, ResourceProvider pResourceManager)
-
-
Method Details
-
reload
public void reload() -
loadLibrary
private void loadLibrary() -
updateCategoryVolume
-
destroy
public void destroy() -
emergencyShutdown
public void emergencyShutdown() -
stop
Stops the provided SoundInstance from continuing to play. -
setVolume
-
stopAll
public void stopAll() -
addEventListener
-
removeEventListener
-
shouldChangeDevice
private boolean shouldChangeDevice() -
tick
public void tick(boolean pIsGamePaused) Ticks all active instances ofTickableSoundInstance -
tickInGameSound
private void tickInGameSound() -
tickMusicWhenPaused
private void tickMusicWhenPaused() -
requiresManualLooping
Returns invalid input: 'Returns {@code true} if the SoundInstance requires manual looping, {@code false} otherwise @param pSound the SoundInstance to check'.- Returns:
- invalid input: 'Returns {@code true} if the SoundInstance requires manual looping, {@code false} otherwise @param pSound the SoundInstance to check'
-
shouldLoopManually
- Parameters:
pSound- The SoundInstance to check- Returns:
- Returns
trueif the SoundInstance should loop manually,falseotherwise
-
shouldLoopAutomatically
- Parameters:
pSound- The SoundInstance to check- Returns:
- Returns
trueif the SoundInstance should loop automatically,falseotherwise
-
isActive
- Parameters:
pSound- the SoundInstance to check- Returns:
trueif the SoundInstance is active,falseotherwise
-
play
-
queueTickingSound
Queues a newinvalid reference
TickingCodeInstance
- Parameters:
pTickableSound- the TickableSoundInstance to queue
-
requestPreload
Requests a specific Sound instance to be preloaded. -
calculatePitch
Calculates the pitch of the sound being played.Clamps the sound between 0.5f and 2.0f.
- Parameters:
pSound- the SoundInstance being played
-
calculateVolume
Calculates the volume for the sound being played.Delegates to
#calculateVolume(float, SoundSource) -
calculateVolume
Calculates the volume of the sound being played.Clamps the sound between 0.0f and 1.0f.
-
pauseAllExcept
-
resume
public void resume() -
playDelayed
Adds a sound to play in n ticks -
updateSource
-
stop
-
getDebugString
-
getAvailableSoundDevices
-
getListenerTransform
-