Ejemplo n.º 1
0
        void Parse(SysExMessage msg)
        {
            if (msg.Values[0] != (byte)PinNumber)
            {
                throw new Exception($"Pin mismatch {PinNumber} not equal to {msg.Values[1]}");
            }
            var c = (SysExMsg)(msg.Command >> 1);

            switch (c)
            {
            case SysExMsg.MSG_pinType:
                Type = (TriggerType)msg.Values[1];
                break;

            case SysExMsg.MSG_pinThreshold:
                Threshold = msg.Values[1];
                break;

            case SysExMsg.MSG_pinNoteOnThreshold:
                Duration_Threshold = msg.Values[1];
                break;

            case SysExMsg.MSG_pinPitch:
                Pitch = msg.Values[1];
                break;

            default:
                throw new Exception($"Parse error Command:'{msg.Command}' not valid");
            }
        }
Ejemplo n.º 2
0
 internal SysExMessage RunCommand(SysExMessage msg, int Timeout = 30)
 {
     if (sp.BytesToRead != 0) //clear the buffer from any sent bytes previously
         sp.ReadExisting();
     Send(msg.ToArray());
     var r = ReadSysEx(Timeout);
     if (r.Command != msg.Command)
         throw new ArrayTypeMismatchException($"Command Mismatch. Command Sent: '{msg.Command}', Command Read: '{r.Command}'");
     return r;
 }
Ejemplo n.º 3
0
        private void Parse(SysExMessage msg)
        {
            if (msg.Values[0] != (byte)PinNumber)
            {
                throw new Exception($"Pin mismatch {PinNumber} not equal to {msg.Values[1]}");
            }
            var c = (SysExMsg)(msg.Command >> 1);

            switch (c)
            {
            case SysExMsg.PinType:
                Type = (TriggerType)msg.Values[1];
                break;

            case SysExMsg.PinThreshold:
                Threshold = msg.Values[1];
                break;

            case SysExMsg.PinNote:
                DurationThreshold = msg.Values[1];
                break;

            case SysExMsg.PinPitch:
                Pitch = msg.Values[1];
                break;

            case SysExMsg.PinCurve:
                Curve = new TriggerCurve(msg.Values.Skip(1).ToArray());
                break;

            case SysExMsg.PinCurveModifications:
                CurveModification.ClearAndSetFromBytes(msg.Values.Skip(1).ToArray());
                break;

            default:
                throw new Exception($"Trigger Parse Error: Command '{msg.Command}' not valid");
            }
        }
Ejemplo n.º 4
0
 private void SendSysExMsg(SysExMessage sysEx)
 {
     Send(sysEx.ToArray());
 }