Interface PASampler

All Known Implementing Classes:
PASharedBufferSampler

public interface PASampler
Backend engine contract for sampler implementations. Allows swapping implementations without changing higher layers.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if any currently active voice is looping.
    int
    play(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
    Play command with all the useful arguments in standard order.
    void
    Releases all voices through their envelopes.
    void
    setBuffer(float[] buffer)
    Replaces the sampler source buffer.
    void
    setBuffer(float[] buffer, float playbackSampleRate)
    Replaces the sampler source buffer and playback sample rate.
    void
    setSampleRate(float newRate)
    Updates the sampler output sample rate.
    void
    Stops all voices immediately.
  • Method Details

    • play

      int play(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
      Play command with all the useful arguments in standard order.
      Parameters:
      samplePos - index into the buffer to start sampling
      sampleLen - expected duration of the audio event, which is expected to return its actual duration
      amplitude - maximum amplitude of signal generated by the sampler, linear value
      env - ADSR style envelope for the entire event
      pitch - pitch multiplier, where 1.0f implies pitch is unchanged and all samples are read
      pan - location of audio event in stereo field, -1.0f = left, 0.0f = center, 1.0f = right
      Returns:
      actual duration of event in samples, typically sampleLen + envelope release time
    • isLooping

      boolean isLooping()
      Returns true if any currently active voice is looping.
      Returns:
      true if one or more voices are looping
    • stopAll

      void stopAll()
      Stops all voices immediately.
    • releaseAll

      void releaseAll()
      Releases all voices through their envelopes.
    • setSampleRate

      void setSampleRate(float newRate)
      Updates the sampler output sample rate.
      Parameters:
      newRate - new sample rate in Hz
    • setBuffer

      void setBuffer(float[] buffer)
      Replaces the sampler source buffer.
      Parameters:
      buffer - mono source sample buffer
    • setBuffer

      void setBuffer(float[] buffer, float playbackSampleRate)
      Replaces the sampler source buffer and playback sample rate.
      Parameters:
      buffer - mono source sample buffer
      playbackSampleRate - sample rate of the source buffer in Hz