예제 #1
0
        /*
         * Complete Setup
         * url: location of obs-websocket (ip+port)
         * password: password
         * statusCallback: Method to call in case of a Status-Update
         * warningCallback: Method to call in case of a Warning-Message
         * infoCallback: Method to call in case of a Info-Message
         */
        public Kontrol2OBS(string url, string password, LogEventHandler statusCallback, LogEventHandler warningCallback, LogEventHandler infoCallback)
        {
            this.OnStatusLog  = statusCallback;
            this.OnWarningLog = warningCallback;
            this.OnInfoLog    = infoCallback;

            this.UpdateLogStatus("Loading Bindings...");
            this.bindingConfig = new Config(this, @".\config.xml");

            this.UpdateLogStatus("Connecting to websocket...");
            this.obsSocket = new OBSConnector(url, password);
            this.obsSocket.OnOBSWebsocketInfo += (s, e) => { this.OnInfoLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };
            this.obsSocket.OnOBSWebsocketWarning += (s, e) => { this.OnWarningLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };

            this.UpdateLogStatus("Setting up audio (This might take a while)...");
            this.SetupAudio();

            this.UpdateLogStatus("Connecting nanoKontrol2...");
            this.nanoController = new Controller(GetNanoKontrolInputDeviceName(), GetNanoKontrolOutputDeviceName());

            for (byte cc = 16; cc < 70; cc++)//Fancy Animation (Seems like it also helps debugging stuff lol)
            {
                this.nanoController.ToggleLED(cc, false);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, true);
                Thread.Sleep(25);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, false);
            }

            this.nanoController.OnMidiMessageReceived += OnNanoControllerInput;
            this.SetupNanoController();

            this.UpdateLogStatus("Setup Event Handlers...");
            this.SetupOBSEventHandlers();

            this.eventBuffer = new EventClock(this, 20);
            this.UpdateLogStatus("Connected and Ready!");
        }
예제 #2
0
        public Explorer(string ip, string password)
        {
            OBSConnector obsConnector = new OBSConnector(ip, password);

            obsConnector.OnOBSMessageReceived += (s, e) => { Console.WriteLine(e.message); };
            obsConnector.OnOBSWebsocketInfo   += (s, e) => { Console.WriteLine(e.text); };
            Console.WriteLine("obs-websocket protocol: https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md");
            Console.WriteLine("Write Requests in Format: <RequestName> [<parameterName> <parameterValue>]");

            while (true) //That's nice
            {
                string[] consoleLine = Console.ReadLine().Split(' ');
                if (consoleLine[0].Length > 0)
                {
                    List <object> parameters = new List <object>();
                    for (int i = 1; i < consoleLine.Length; i += 2)
                    {
                        parameters.Add(consoleLine[i]);

                        if (bool.TryParse(consoleLine[i + 1], out _))
                        {
                            parameters.Add(bool.Parse(consoleLine[i + 1]));
                        }
                        else if (double.TryParse(consoleLine[i + 1], out _))
                        {
                            parameters.Add(double.Parse(consoleLine[i + 1]));
                        }
                        else if (int.TryParse(consoleLine[i + 1], out _))
                        {
                            parameters.Add(int.Parse(consoleLine[i + 1]));
                        }
                        else
                        {
                            parameters.Add(consoleLine[i + 1]);
                        }
                    }
                    JObject response = obsConnector.Request(consoleLine[0], parameters.ToArray());
                    Console.WriteLine(response);
                }
            }
        }
예제 #3
0
        public void Create()
        {
            this.UpdateLogStatus("Loading Bindings...");
            this.bindingConfig = new Config(this, @".\config.xml");
            this.UpdateLogStatus("Connecting to websocket...");
            this.obsSocket = new OBSConnector(url, password);
            this.obsSocket.OnOBSWebsocketInfo += (s, e) => { this.OnInfoLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };
            this.obsSocket.OnOBSWebsocketWarning += (s, e) => { this.OnWarningLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };
            this.UpdateLogStatus("Setting up audio (This might take a while)...");
            this.SetupAudio();
            this.UpdateLogStatus("Connecting nanoKontrol2...");
            this.nanoController = new Controller(GetNanoKontrolInputDeviceName(), GetNanoKontrolOutputDeviceName());

            for (byte cc = 16; cc < 70; cc++)//Fancy Animation
            {
                this.nanoController.ToggleLED(cc, false);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, true);
                Thread.Sleep(25);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, false);
            }

            this.nanoController.OnMidiMessageReceived += OnNanoControllerInput;
            this.SetupNanoController();
            this.UpdateLogStatus("Setup Event Handlers...");
            this.SetupOBSEventHandlers();
            this.UpdateLogStatus("Connected and Ready!");
        }