start2 method

void start2(
  1. RegionPair region,
  2. int key,
  3. int velocity
)

Implementation

void start2(RegionPair region, int key, int velocity)
{
    // If the release time is shorter than 10 ms, it will be clamped to 10 ms to avoid pop noise.

    var hold = region.holdVolumeEnvelope() *
      SoundFontMath.keyNumberToMultiplyingFactor(region.keyNumberToVolumeEnvelopeHold(), key);

    var decay = region.decayVolumeEnvelope() *
      SoundFontMath.keyNumberToMultiplyingFactor(region.keyNumberToVolumeEnvelopeDecay(), key);

    start(delay: region.delayVolumeEnvelope(),
          attack: region.attackVolumeEnvelope(),
          hold: hold,
          decay: decay,
          sustain: SoundFontMath.decibelsToLinear(-region.sustainVolumeEnvelope()),
          release: max(region.releaseVolumeEnvelope(), 0.01),
        );
}