Record Class SoundFilter

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.sound.SoundFilter
Record Components:
gain - how loud the sound stays
gainHF - how much of its high end it keeps
distortion - how much of it is sent through the distortion
reverb - how much of it is sent into the reverb

public record SoundFilter(float gain, float gainHF, float distortion, float reverb) extends Record
How a sound comes through to the listener, each part 0 to 1:
  • gain: how loud it stays, 1 for as loud as it was;
  • gainHF: how much of its high end it keeps; losing the highs is what makes a sound muffled, as through a wall;
  • distortion: how much of it is sent through a distortion, which makes it rough, as if strained through something;
  • reverb: how much of it is sent into a reverb, which makes it echo, as in a cave or a great hall.

 SoundFilter.muffled(0.8F)                          // through a thick wall
 new SoundFilter(0.6F, 0.1F, 0.3F)                  // muffled and rough, as under water
 SoundFilter.echoing(0.5F).then(SoundFilter.quieter(0.8F))
 SoundFilter.NONE.lerp(underwater, fade)            // part of the way there, for a fade
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SoundFilter
    The sound as it is.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SoundFilter(float gain, float gainHF)
    A filter that only muffles.
    SoundFilter(float gain, float gainHF, float distortion)
    A filter without reverb.
    SoundFilter(float gain, float gainHF, float distortion, float reverb)
    Creates an instance of a SoundFilter record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    distorted(float amount)
    Only rough: amount of it sent through the distortion.
    float
    Returns the value of the distortion record component.
    echoing(float amount)
    Only echoing: amount of it sent into the reverb.
    final boolean
    Indicates whether some other object is "equal to" this one.
    float
    Returns the value of the gain record component.
    float
    Returns the value of the gainHF record component.
    final int
    Returns a hash code value for this object.
    boolean
    Whether it changes nothing.
    lerp(SoundFilter to, float delta)
    Part of the way from this filter to another: 0 is this one, 1 the other.
    muffled(float amount)
    Muffled, as through a wall: 0 for not at all, 1 for nearly nothing of the highs left and a little quieter.
    quieter(float gain)
    Only quieter: gain of the volume left.
    float
    Returns the value of the reverb record component.
    Both filters at once, as a sound through one wall and then another.
    final String
    Returns a string representation of this record class.
    withDistortion(float distortion)
    This filter with another distortion.
    withReverb(float reverb)
    This filter with another reverb.

    Methods inherited from class java.lang.Object

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

    • NONE

      public static final SoundFilter NONE
      The sound as it is.
  • Constructor Details

    • SoundFilter

      public SoundFilter(float gain, float gainHF, float distortion, float reverb)
      Creates an instance of a SoundFilter record class.
      Parameters:
      gain - the value for the gain record component
      gainHF - the value for the gainHF record component
      distortion - the value for the distortion record component
      reverb - the value for the reverb record component
    • SoundFilter

      public SoundFilter(float gain, float gainHF, float distortion)
      A filter without reverb.
    • SoundFilter

      public SoundFilter(float gain, float gainHF)
      A filter that only muffles.
  • Method Details

    • muffled

      public static SoundFilter muffled(float amount)
      Muffled, as through a wall: 0 for not at all, 1 for nearly nothing of the highs left and a little quieter.
    • quieter

      public static SoundFilter quieter(float gain)
      Only quieter: gain of the volume left.
    • distorted

      public static SoundFilter distorted(float amount)
      Only rough: amount of it sent through the distortion.
    • echoing

      public static SoundFilter echoing(float amount)
      Only echoing: amount of it sent into the reverb.
    • withDistortion

      public SoundFilter withDistortion(float distortion)
      This filter with another distortion.
    • withReverb

      public SoundFilter withReverb(float reverb)
      This filter with another reverb.
    • then

      public SoundFilter then(SoundFilter other)
      Both filters at once, as a sound through one wall and then another.
    • lerp

      public SoundFilter lerp(SoundFilter to, float delta)
      Part of the way from this filter to another: 0 is this one, 1 the other. For fades.
    • isNone

      public boolean isNone()
      Whether it changes nothing.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • gain

      public float gain()
      Returns the value of the gain record component.
      Returns:
      the value of the gain record component
    • gainHF

      public float gainHF()
      Returns the value of the gainHF record component.
      Returns:
      the value of the gainHF record component
    • distortion

      public float distortion()
      Returns the value of the distortion record component.
      Returns:
      the value of the distortion record component
    • reverb

      public float reverb()
      Returns the value of the reverb record component.
      Returns:
      the value of the reverb record component