public static E TriggerADSR(double t0, double e0, double attack, double decay, Amplitude sustainLevel, double sustainDuration, double release) => (t) => !HasElapsed(t0, t, attack) ? Attack(t0, e0, attack)(t) : !HasElapsed(t0 + attack, t, decay) ? Decay(t0 + attack, e0, decay, sustainLevel)(t) : !HasElapsed(t0 + attack + decay, t, sustainDuration) ? Sustain(sustainLevel)(t) : !HasElapsed(t0 + attack + decay + sustainDuration, t, release) ? Release(t0 + attack + decay + sustainDuration, Normalize(sustainLevel), release)(t) : Mute()(t);
internal static void PlayPedalStatic(bool down) { if (clsPlay.PlayExists()) { Sustain.PlayPedal(down); } else { int data = (down) ? 127 : 0; if (MidiPlay.OutMRec != null) { MidiPlay.OutMRec.SendShortMsg((byte)(0xb0 | MidiPlay.KBOutChanRec), 0x40, data); } if (MidiPlay.OutMStream != null) { for (int ch = 0; ch < 16; ch++) { //MidiPlay.OutMStream.SendShortMsg((byte)(0xb0 | ch), 121, 0); //reset all ctlrs MidiPlay.OutMStream.SendShortMsg((byte)(0xb0 | ch), 0x40, data); //sustain off } } } }
public static E TriggerAttack(double t0, double e0, double attack, double decay, Amplitude sustainLevel) => (t) => !HasElapsed(t0, t, attack) ? Attack(t0, e0, attack)(t) : !HasElapsed(t0 + attack, t, decay) ? Decay(t0 + attack, e0, decay, sustainLevel)(t) : Sustain(sustainLevel)(t);