예제 #1
0
        void SendMessages(Drums newState, XInput.GamepadEx state)
        {
            if (device == null)
            {
                return;
            }
            var channel = Midi.Enums.Channel.Channel10;

            foreach (Drums d in Enum.GetValues(typeof(Drums)))
            {
                var note = DrumNoteMap[d];
                if (newState.HasFlag(d) && !drumState.HasFlag(d))
                {
                    var velocity = VelocityFunctions[d](state);
                    if (velocity > 127)
                    {
                        velocity = 127;
                    }
                    if (velocity < 32)
                    {
                        velocity = 32;
                    }
                    device.SendNoteOn(channel, (Midi.Enums.Pitch)note, velocity);
                }
                else if (!newState.HasFlag(d) && drumState.HasFlag(d))
                {
                    device.SendNoteOff(channel, (Midi.Enums.Pitch)note, 0);
                }
            }
        }
예제 #2
0
 void SendMessages(Drums newState, XInput.GamepadEx state)
 {
     foreach (Drums d in Enum.GetValues(typeof(Drums)))
     {
         var note = DrumNoteMap[d](newState);
         if (newState.HasFlag(d) && !drumState.HasFlag(d))
         {
             var velocity = VelocityFunctions[d](state);
             if (velocity > 127)
             {
                 velocity = 127;
             }
             if (velocity < 32)
             {
                 velocity = 32;
             }
             OnNoteOn?.Invoke(Channel, (Midi.Enums.Pitch)note, velocity);
         }
         else if (!newState.HasFlag(d) && drumState.HasFlag(d))
         {
             OnNoteOff?.Invoke(Channel, (Midi.Enums.Pitch)note);
         }
     }
 }