Class SoundManager

All Implemented Interfaces:
PreparableReloadListener

The SoundManager class is responsible for managing sound events and playing sounds. It handles sound event registrations, caching of sound resources, and sound playback.
  • Field Details

  • Constructor Details

    • SoundManager

      public SoundManager(Options pOptions)
  • Method Details

    • prepare

      protected SoundManager.Preparations prepare(ResourceManager pResourceManager, ProfilerFiller pProfiler)
      Performs any reloading that can be done off-thread, such as file IO
      Specified by:
      prepare in class SimplePreparableReloadListener<SoundManager.Preparations>
      Parameters:
      pResourceManager - The resource manager in-charge of loading sound files
      pProfiler - The sound profiler
    • apply

      protected void apply(SoundManager.Preparations pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler)
      Applies the prepared sound event registrations and caches to the sound manager.
      Specified by:
      apply in class SimplePreparableReloadListener<SoundManager.Preparations>
      Parameters:
      pObject - The prepared sound event registrations and caches
      pResourceManager - The resource manager
      pProfiler - The profiler
    • getAvailableSoundDevices

      public List<String> getAvailableSoundDevices()
    • getListenerTransform

      public ListenerTransform getListenerTransform()
    • validateSoundResource

      static boolean validateSoundResource(Sound pSound, ResourceLocation pLocation, ResourceProvider pResourceProvider)
      Validates a sound resource

      Parameters:
      pSound - The sound to validate
      pLocation - The location of the sound event
      pResourceProvider - The resource provider
      Returns:
      true if the sound resource is valid, false otherwise
    • getSoundEvent

      @Nullable public WeighedSoundEvents getSoundEvent(ResourceLocation pLocation)
      Returns The sound event associated with the specific ResourceLocation, or null if not found.
      Parameters:
      pLocation - The location of the sound event
      Returns:
      The sound event associated with the specific ResourceLocation, or null if not found
    • getAvailableSounds

      public Collection<ResourceLocation> getAvailableSounds()
    • queueTickingSound

      public void queueTickingSound(TickableSoundInstance pTickableSound)
      Queues a ticking sound to be played.
      Parameters:
      pTickableSound - The ticking sound instance
    • play

      public void play(SoundInstance pSound)
      Play a sound
    • playDelayed

      public void playDelayed(SoundInstance pSound, int pDelay)
      Plays a sound with a delay in ticks.
      Parameters:
      pSound - The sound instance to play
      pDelay - The delay in ticks before playing the sound
    • updateSource

      public void updateSource(Camera pActiveRenderInfo)
      Updates the sound source position based on the active render info.
      Parameters:
      pActiveRenderInfo - The active render info
    • pause

      public void pause()
    • stop

      public void stop()
    • destroy

      public void destroy()
    • emergencyShutdown

      public void emergencyShutdown()
    • tick

      public void tick(boolean pIsGamePaused)
      Updates the sound manager's tick state.
      Parameters:
      pIsGamePaused - true if the game is paused, false otherwise
    • resume

      public void resume()
    • updateSourceVolume

      public void updateSourceVolume(SoundSource pCategory, float pVolume)
      Updates the volume of the specified sound source category.
      Parameters:
      pCategory - The sound source category
      pVolume - The new volume
    • stop

      public void stop(SoundInstance pSound)
    • isActive

      public boolean isActive(SoundInstance pSound)
      Checks if the specified sound is active (playing or scheduled to be played).
      Parameters:
      pSound - The sound instance to check
      Returns:
      true if the sound is active, false otherwise
    • addListener

      public void addListener(SoundEventListener pListener)
    • removeListener

      public void removeListener(SoundEventListener pListener)
    • stop

      public void stop(@Nullable ResourceLocation pId, @Nullable SoundSource pCategory)
      Stops all sounds associated with the specified ID and category.
      Parameters:
      pId - The ID of the sounds to stop, or null to stop all sounds
      pCategory - The category of the sounds to stop, or null to stop sounds from all categories
    • getDebugString

      public String getDebugString()
    • reload

      public void reload()