Пример #1
0
 public void MidiPress(MidiLevelDriverInstance newDriver)
 {
     if (this.GetPresetForChannelIndex(newDriver.ChannelIndex) != null)
     {
         this.driversByChannel[newDriver.ChannelIndex] = newDriver;
         this.lastChannelInteractionTime = newDriver.PressTimestamp;
     }
 }
Пример #2
0
        private double CurrentMidiLevelDriverValueWithoutReleaseForChannel(
            MidiLevelDriverInstance driver,
            MidiLevelDriverPreset preset,
            long currentTime
            )
        {
            long   timeSincePress = currentTime - driver.PressTimestamp;
            double realPeak       = driver.PressVelocity * preset.PeakLevel;

            if (timeSincePress < preset.AttackTime)
            {
                return(((double)timeSincePress / preset.AttackTime) * realPeak);
            }
            long   timeSinceDecayBegan = timeSincePress - preset.AttackTime;
            double realSustain         = driver.PressVelocity * preset.SustainLevel;

            if (timeSinceDecayBegan > preset.DecayTime)
            {
                return(realSustain);
            }
            return(realPeak -
                   (double)timeSinceDecayBegan / preset.DecayTime * (realPeak - realSustain));
        }