Class MultiClip

java.lang.Object
tripleplay.sound.MultiClip

public class MultiClip extends Object
Provides a sound clip that can be played multiple times. Callers tell the multiclip to prepare a copy which may result in loading a copy of the sound from a SoundBoard if no reserves are available to play it, they then play the sound, and after a configured duration that sound either goes back into the reserves, or is disposed, if the reserves are already full.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A handle on a copy of a clip.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiClip(SoundBoard board, String path, int reserveCopies, float duration)
    Creates a multiclip with the supplied configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases all of the clips obtained by this multiclip, freeing their audio resources.
    Obtains a copy of the sound (from the reserves if possible or loaded from storage if not).

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiClip

      public MultiClip(SoundBoard board, String path, int reserveCopies, float duration)
      Creates a multiclip with the supplied configuration.
      Parameters:
      board - the soundboard from which to obtain clips.
      path - the path to the underlying sound.
      reserveCopies - the minimum number of copies of the sound to keep in memory.
      duration - the duration of the sound (in seconds). This will be used to determine when it is safe to reuse a copy of the sound.
  • Method Details

    • reserve

      public MultiClip.Copy reserve()
      Obtains a copy of the sound (from the reserves if possible or loaded from storage if not). The copy must be MultiClip.Copy.play()ed or MultiClip.Copy.release()d by the caller.
    • release

      public void release()
      Releases all of the clips obtained by this multiclip, freeing their audio resources.