Package net.paulhertz.pixelaudio.sampler

# Class SimpleADSR

java.lang.Object
net.paulhertz.pixelaudio.sampler.SimpleADSR

public class SimpleADSR extends Object
SimpleADSR — software envelope generator with optional exponential curves.

Features:

- Sample-rate–based time scaling
- Per-stage exponential curvature
- Sustain-level clamping
- `noteOn()`, `noteOff()`, `tick()`, and `isFinished()`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `private static enum`
  `SimpleADSR.Stage`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `private float`
  `attackCurve`
  `private float`
  `attackTime`
  `private float`
  `decayCurve`
  `private float`
  `decayTime`
  `private float`
  `releaseCurve`
  `private float`
  `releaseStart`
  `private float`
  `releaseTime`
  `private float`
  `sampleRate`
  `private int`
  `samplesInStage`
  `private SimpleADSR.Stage`
  `stage`
  `private int`
  `stageSamples`
  `private float`
  `sustainLevel`
  `private float`
  `value`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleADSR(float attack, float decay, float sustain, float release)`
  `SimpleADSR(float attack, float decay, float sustain, float release, float attackCurve, float decayCurve, float releaseCurve)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `private static float`
  `exponentialInterp(int step, int total, float start, float end, float curve)`
  `float`
  `getValue()`
  `boolean`
  `isFinished()`
  `void`
  `noteOff()`
  `void`
  `noteOn()`
  `void`
  `setCurves(float attackC, float decayC, float releaseC)`
  `void`
  `setSampleRate(float sr)`
  `void`
  `setTimes(float a, float d, float s, float r)`
  `float`
  `tick()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### attackTime

    private float attackTime

  - ### decayTime

    private float decayTime

  - ### sustainLevel

    private float sustainLevel

  - ### releaseTime

    private float releaseTime

  - ### sampleRate

    private float sampleRate

  - ### attackCurve

    private float attackCurve

  - ### decayCurve

    private float decayCurve

  - ### releaseCurve

    private float releaseCurve

  - ### stage

    private SimpleADSR.Stage stage

  - ### value

    private float value

  - ### releaseStart

    private float releaseStart

  - ### samplesInStage

    private int samplesInStage

  - ### stageSamples

    private int stageSamples

- ## Constructor Details

  - ### SimpleADSR

    public SimpleADSR(float attack, float decay, float sustain, float release)

  - ### SimpleADSR

    public SimpleADSR(float attack, float decay, float sustain, float release, float attackCurve, float decayCurve, float releaseCurve)

- ## Method Details

  - ### setSampleRate

    public void setSampleRate(float sr)

  - ### noteOn

    public void noteOn()

  - ### noteOff

    public void noteOff()

  - ### isFinished

    public boolean isFinished()

  - ### tick

    public float tick()

  - ### exponentialInterp

    private static float exponentialInterp(int step, int total, float start, float end, float curve)

  - ### getValue

    public float getValue()

  - ### setCurves

    public void setCurves(float attackC, float decayC, float releaseC)

  - ### setTimes

    public void setTimes(float a, float d, float s, float r)