Ejemplo n.º 1
0
        public override void KeyPressed(KeyPayload payload)
        {
            this.settings = payload.Settings.ToObject <PluginSettings>();
            Logger.Instance.LogMessage(TracingLevel.INFO, "OscToggle: Key Pressed");
            IMidiOutputDeviceInfo outputDeviceInfo = MidiDeviceManager.Default.OutputDevices.ElementAt(Int32.Parse(this.settings.SelectedDevice));

            MidiDevice.MidiDevice.outputDevice = outputDeviceInfo.CreateDevice();
            if (!MidiDevice.MidiDevice.outputDevice.IsOpen)
            {
                MidiDevice.MidiDevice.outputDevice.Open();
            }
            this.MidiOn(this.settings.Channel, this.settings.MidiNote);
        }
        public override Task OnWillAppear(StreamDeckEventPayload args)
        {
            Log.Information("OnWillAppear");
            this.SetModelProperties(args);

            // This might go wrong when the order of devices change or devices are added/removed
            // We need to refer to the devices by name instead of index.
            IMidiOutputDeviceInfo inputDeviceInfo = this.GetOutputDeviceInfo(this.SettingsModel.SelectedDevice);

            if (!MidiDevice.OutputDevices.ContainsKey(inputDeviceInfo.Name))
            {
                MidiDevice.OutputDevices.Add(
                    inputDeviceInfo.Name, inputDeviceInfo.CreateDevice());
            }

            if (!MidiDevice.OutputDevices[inputDeviceInfo.Name].IsOpen)
            {
                MidiDevice.OutputDevices[inputDeviceInfo.Name].Open();
            }

            return(Task.CompletedTask);
        }