Class PitchShifter

java.lang.Object
de.pottgames.tuningfork.SoundEffectData
de.pottgames.tuningfork.PitchShifter

public class PitchShifter extends SoundEffectData
The pitch shifter applies time-invariant pitch shifting to the input signal, over a one octave range and controllable at a semi-tone and cent resolution.
  • Field Details

    • coarseTune

      public int coarseTune
      Range: -12 - 12, Default: 12
      This sets the number of semitones by which the pitch is shifted. There are 12 semitones per octave. Negative values create a downwards shift in pitch, positive values pitch the sound upwards.
    • fineTune

      public int fineTune
      Range: -50 - 50, Default: 0
      This sets the number of cents between Semitones a pitch is shifted. A Cent is 1/100th of a Semitone. Negative values create a downwards shift in pitch, positive values pitch the sound upwards.
  • Constructor Details

    • PitchShifter

      public PitchShifter()
  • Method Details

    • chipmunk

      public static PitchShifter chipmunk()
    • demon

      public static PitchShifter demon()
    • maxPitch

      public static PitchShifter maxPitch()
    • minPitch

      public static PitchShifter minPitch()
    • correctPitch

      public PitchShifter correctPitch(float pitch)
      Sets coarseTune and fineTune to values that try to correct a pitch applied to a SoundSource, so that the sound appears to be played back at a pitch of 1. This way, it is possible to change the playback speed of a sound without changing its pitch.

      Note: In order to only hear the pitch corrected sound, the direct sound path must be muted with the help of SoundSource.setFilter(float, float) set to [0,0].
      Parameters:
      pitch - - pitch correction only works for 0.5 <= pitch <= 2
      Returns:
      the PitchShifter for chaining
    • apply

      protected void apply(int effectId)
      Specified by:
      apply in class SoundEffectData
    • 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