public void EnvToSecs(bool sustainIsGain) { // EG times need to be converted from timecents to seconds. // Pin very short EG segments. Timecents don't get to zero, and our EG is // happier with zero values. Delay = (Delay < -11950.0f ? 0.0f : SynthHelper.Timecents2Secs(Delay)); Attack = (Attack < -11950.0f ? 0.0f : SynthHelper.Timecents2Secs(Attack)); Release = (Release < -11950.0f ? 0.0f : SynthHelper.Timecents2Secs(Release)); // If we have dynamic hold or decay times depending on key number we need // to keep the values in timecents so we can calculate it during startNote if (KeynumToHold == 0) { Hold = (Hold < -11950.0f ? 0.0f : SynthHelper.Timecents2Secs(Hold)); } if (KeynumToDecay == 0) { Decay = (Decay < -11950.0f ? 0.0f : SynthHelper.Timecents2Secs(Decay)); } if (Sustain < 0.0f) { Sustain = 0.0f; } else if (sustainIsGain) { Sustain = SynthHelper.DecibelsToGain(-Sustain / 10.0f); } else { Sustain = 1.0f - (Sustain / 1000.0f); } }