Ejemplo n.º 1
0
        private IEnumerable <byte> GetCurveModificationBytes()
        {
            yield return((byte)PinNumber);

            if (CurveModification == null)
            {
                yield return(0);

                yield break;
            }

            foreach (var b in CurveModification.GetBytes())
            {
                yield return(b);
            }
        }
Ejemplo n.º 2
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");
            }
        }