Class SongSettings

java.lang.Object
de.pottgames.tuningfork.jukebox.song.SongSettings

public class SongSettings extends Object
An immutable settings data class for configuring a Song. It allows settings a general volume and fade-in and fade-out parameters which are used to control the playback of a song.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SongSettings
    No fade-in and no fade-out, general volume of 1.
    static final SongSettings
    Fade-in and fade-out of 1 second, linear interpolation, general volume of 1.
    static final com.badlogic.gdx.math.Interpolation
    Does not interpolate and ignores the alpha value, always applies 1.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SongSettings(float volume, float fadeInDuration, com.badlogic.gdx.math.Interpolation fadeInCurve, float fadeOutDuration, com.badlogic.gdx.math.Interpolation fadeOutCurve)
    Creates a SongSettings instance with the given parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    float
    fadeVolume(SongSettings.FadeType type, float alpha)
    Returns the fade volume for a given fade type and alpha value.
    com.badlogic.gdx.math.Interpolation
    Returns the fade-in curve.
    float
    Returns the fade-in duration in seconds.
    com.badlogic.gdx.math.Interpolation
    Returns the fade-out curve.
    float
    Returns the fade-out duration in seconds.
    float
    Returns the standard volume.
    int
     
    linear(float volume, float fadeInDuration, float fadeOutDuration)
    Creates a SongSettings instance with linear fade-in and fade-out interpolation.
    noFade(float volume)
    Creates a SongSettings instance that has fade-in and fade-out turned off.
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NO_INTERPOLATION

      public static final com.badlogic.gdx.math.Interpolation NO_INTERPOLATION
      Does not interpolate and ignores the alpha value, always applies 1.
    • DEFAULT

      public static final SongSettings DEFAULT
      No fade-in and no fade-out, general volume of 1.
    • DEFAULT_LINEAR

      public static final SongSettings DEFAULT_LINEAR
      Fade-in and fade-out of 1 second, linear interpolation, general volume of 1.
  • Constructor Details

    • SongSettings

      public SongSettings(float volume, float fadeInDuration, com.badlogic.gdx.math.Interpolation fadeInCurve, float fadeOutDuration, com.badlogic.gdx.math.Interpolation fadeOutCurve)
      Creates a SongSettings instance with the given parameters.
      Parameters:
      volume - the volume, ranging from 0 - 1. Will be clamped if it exceeds the range.
      fadeInDuration - fade-in duration in seconds
      fadeInCurve - fade-in curve
      fadeOutDuration - fade-out duration in seconds
      fadeOutCurve - fade-out curve
  • Method Details

    • noFade

      public static SongSettings noFade(float volume)
      Creates a SongSettings instance that has fade-in and fade-out turned off.
      Parameters:
      volume - the volume this song will be played with, ranging from 0 - 1
      Returns:
      the settings
    • linear

      public static SongSettings linear(float volume, float fadeInDuration, float fadeOutDuration)
      Creates a SongSettings instance with linear fade-in and fade-out interpolation.
      Parameters:
      volume - the volume this song will be played with, ranging from 0 - 1
      fadeInDuration - fade-in duration in seconds
      fadeOutDuration - fade-out duration in seconds
      Returns:
      the settings
    • fadeVolume

      public float fadeVolume(SongSettings.FadeType type, float alpha)
      Returns the fade volume for a given fade type and alpha value.
      Parameters:
      type - the fade type
      alpha - the alpha value
      Returns:
      the fade volume
    • getFadeInDuration

      public float getFadeInDuration()
      Returns the fade-in duration in seconds.
      Returns:
      fade-in duration in seconds
    • getFadeOutDuration

      public float getFadeOutDuration()
      Returns the fade-out duration in seconds.
      Returns:
      fade-out duration in seconds
    • getFadeInCurve

      public com.badlogic.gdx.math.Interpolation getFadeInCurve()
      Returns the fade-in curve.
      Returns:
      fade-in curve
    • getFadeOutCurve

      public com.badlogic.gdx.math.Interpolation getFadeOutCurve()
      Returns the fade-out curve.
      Returns:
      fade-out curve
    • getVolume

      public float getVolume()
      Returns the standard volume.
      Returns:
      volume, ranging from 0-1
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object