start2 method

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

Implementation

void start2(RegionPair region, int key, int velocity) {
  // According to the implementation of TinySoundFont,
  // the attack time should be adjusted by the velocity.
  var hold = region.holdModulationEnvelope() *
      SoundFontMath.keyNumberToMultiplyingFactor(region.keyNumberToModulationEnvelopeHold(), key);

  var decay = region.decayModulationEnvelope() *
      SoundFontMath.keyNumberToMultiplyingFactor(region.keyNumberToModulationEnvelopeDecay(), key);

  start(
      delay: region.delayModulationEnvelope(),
      attack: region.attackModulationEnvelope() * ((145.0 - velocity) / 144.0),
      hold: hold,
      decay: decay,
      sustain: 1.0 - region.sustainModulationEnvelope() / 100.0,
      release: region.releaseModulationEnvelope());
}