Exemple #1
0
 private Trigger(MidiNote note, string name)
 {
     type      = TriggerType.NOTE;
     this.note = note;
     this.name = name;
     icon      = XamlReader.Parse(Properties.Resources.note) as Canvas;
 }
Exemple #2
0
        public static Trigger GetTrigger(string value)
        {
            string[] array = value == null ? new string[] { } : value.Trim().Split(' ');

            if (array.Length == 2)
            {
                switch (array[0].ToUpper())
                {
                case "CUE":
                    MscCommand mscCmd1 = MscCommand.getCue(array[1]);
                    if (mscCmd1 != null)
                    {
                        return(new Trigger(mscCmd1));
                    }
                    break;

                case "FOLLOW":
                    long buff    = 0;
                    bool success = false;

                    Match match = Regex.Match(array[1], @"(\d*):([0-5][0-9])\.(\d{3})");
                    if (match.Success)
                    {
                        buff    = long.Parse(match.Groups[1].Value) * 60000;
                        buff   += long.Parse(match.Groups[2].Value) * 1000;
                        buff   += long.Parse(match.Groups[3].Value);
                        success = true;
                    }
                    else
                    {
                        match = Regex.Match(array[1], @"([0-5]?[0-9])\.(\d{3})");
                        if (match.Success)
                        {
                            buff   += long.Parse(match.Groups[1].Value) * 1000;
                            buff   += long.Parse(match.Groups[2].Value);
                            success = true;
                        }
                        else
                        {
                            match = Regex.Match(array[1], @"(\d{1,3})");
                            if (match.Success)
                            {
                                buff   += long.Parse(match.Groups[1].Value);
                                success = true;
                            }
                        }
                    }
                    if (success)
                    {
                        return(new Trigger(buff, "Follow " + match.Groups[0].Value));
                    }
                    break;

                case "MACRO":
                    MscCommand mscCmd2 = MscCommand.getMacro(array[1]);
                    if (mscCmd2 != null)
                    {
                        return(new Trigger(mscCmd2));
                    }
                    break;

                case "NOTE":
                    MidiNote note = MidiNote.getMidiNote(array[1]);
                    if (note != null && note.pitch < 108)
                    {
                        return(new Trigger(note, "Note " + array[1]));
                    }
                    break;

                case "OSC":
                    OscCmd oscCmd = OscCmd.GetOscCmd("/Cue " + array[1]);
                    if (oscCmd != null)
                    {
                        return(new Trigger(oscCmd, "OSC " + array[1]));
                    }
                    break;
                }
            }
            return(null);
        }
Exemple #3
0
        public static Send GetSend(string value, string pbScript)
        {
            string[] array = value == null ? new string[] { } : value.Trim().Split(' ');
            if (array.Length >= 2)
            {
                Match match = Regex.Match(array[0], @"B(\d+)", RegexOptions.IgnoreCase);
                if (match.Success && match.Groups.Count == 2)
                {
                    if (array[1].ToUpper() == "CLOSE")
                    {
                        return(new Send(new Tuple <int, bool>(int.Parse(match.Groups[1].Value), false), array[0].ToUpper() + " close"));
                    }
                    else if (array[1].ToUpper() == "OPEN")
                    {
                        return(new Send(new Tuple <int, bool>(int.Parse(match.Groups[1].Value), true), array[0].ToUpper() + " open"));
                    }
                }
                else
                {
                    switch (array[0].ToUpper())
                    {
                    case "CUE":
                        MscCommand mscCmd1 = MscCommand.getCue(array[1]);
                        if (mscCmd1 != null)
                        {
                            return(new Send(mscCmd1));
                        }
                        break;

                    case "MACRO":
                        MscCommand mscCmd2 = MscCommand.getMacro(array[1]);
                        if (mscCmd2 != null)
                        {
                            return(new Send(mscCmd2));
                        }
                        break;

                    case "MATRIX":
                        MatrixCmd matrixCmd = MatrixCmd.getMatrixCmd(array[1]);
                        if (matrixCmd != null)
                        {
                            return(new Send(matrixCmd));
                        }
                        break;

                    case "MUTE":
                        switch (array[1].ToUpper())
                        {
                        case "ALL":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.ALL, true), "Mute All"));

                        case "NOTE":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.NOTE, true), "Mute Note"));

                        case "MSC":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.MSC, true), "Mute MSC"));

                        case "OSC":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.OSC, true), "Mute OSC"));
                        }
                        break;

                    case "UNMUTE":
                        switch (array[1].ToUpper())
                        {
                        case "ALL":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.ALL, false), "Unmute All"));

                        case "NOTE":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.NOTE, false), "Unmute Note"));

                        case "MSC":
                            return(new Send(new Tuple <MuteType, bool>(MuteType.MSC, false), "Unmute MSC"));

                        case "OSC":
                            return(new Model.Send(new Tuple <MuteType, bool>(MuteType.OSC, false), "Unmute OSC"));
                        }
                        break;

                    case "NOTE":
                        MidiNote note = MidiNote.getMidiNote(array[1]);
                        if (note != null && note.pitch < 108)
                        {
                            return(new Send(note, "Note " + array[1]));
                        }
                        break;

                    case "SC":
                        string[] s = array[1].Split(',');
                        if (s.Length >= 2)
                        {
                            int sequence, cue;
                            if (int.TryParse(s[0], out sequence) && int.TryParse(s[1], out cue))
                            {
                                return(new Send(sequence, cue, "SC " + array[1]));
                            }
                        }
                        break;

                    case "SCRIPT":
                        int scriptNr;
                        if (int.TryParse(array[1], out scriptNr) && scriptNr > 0 && scriptNr < 11)
                        {
                            return(new Send(scriptNr, "Script " + array[1]));
                        }
                        break;
                    }
                }
            }
            else if (array.Length == 1)
            {
                if (array[0].ToUpper() == "PB" && pbScript != null)
                {
                    PbCmd pbCmd = PbCmd.GetPbCmd(pbScript);
                    if (pbCmd != null)
                    {
                        return(new Send(pbCmd));
                    }
                }

                else if (array[0].ToUpper() == "OSC" && pbScript != null)
                {
                    OscCmd oscCmd = OscCmd.GetOscCmd(pbScript);
                    if (oscCmd != null)
                    {
                        return(new Send(oscCmd));
                    }
                }
            }
            return(null);
        }
Exemple #4
0
 private Send(MidiNote note, string name)
 {
     type      = SendType.NOTE;
     this.note = note;
     this.name = name;
 }