コード例 #1
0
ファイル: Program.cs プロジェクト: brianavid/PushWhacker
        static void Main()
        {
            ConfigValues configValues = new ConfigValues();

            configValues.Load();

            if (!PushDisplay.Open() && !configValues.UserModeOnly)
            {
                MessageBox.Show("Can't open Push display");
            }
            else
            {
                midiProcessor = new MidiProcessor(configValues);

                if (!midiProcessor.StartProcessing())
                {
                    MessageBox.Show("Can't start Push Midi Processing\n\nThis is usually because another program or browser web page is using Midi and has locked all ports");
                }
                else
                {
                    SystemEvents.SessionEnding += new SessionEndingEventHandler(PushWacker_SesssionEndingEventHandler);
                    var applicationContext = new CustomApplicationContext(configValues, midiProcessor);
                    Application.Run(applicationContext);

                    midiProcessor.StopProcessing();
                }

                PushDisplay.Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a default instance and reuses that for all threads.
        /// </summary>
        /// <param name="instance">A reference to the default instance or null.</param>
        /// <returns>Returns the default instance.</returns>
        protected override IVstMidiProcessor CreateMidiProcessor(IVstMidiProcessor instance)
        {
            if (instance == null)
            {
                MidiProcessor = new MidiProcessor(this);
                if (AudioProcessor != null)
                {
                    AudioProcessor.SetUp();
                }
                return(MidiProcessor);
            }

            return(base.CreateMidiProcessor(instance));
        }
コード例 #3
0
 /// <summary>
 /// This class should be created and passed into Application.Run( ... )
 /// </summary>
 public CustomApplicationContext(ConfigValues values, MidiProcessor processor)
 {
     configValues  = values;
     midiProcessor = processor;
     InitializeContext();
 }
コード例 #4
0
        /// <summary>
        /// Метод, привязывающий плагин к клавиатуре редактора.
        /// </summary>
        /// <param name="midiProcessor"></param>
        private void BindKeyboard(MidiProcessor midiProcessor)
        {
            Dictionary <int, Rectangle> keys = new Dictionary <int, Rectangle>();

            for (int i = 36; i <= 36 + 64; ++i)
            {
                var key = new Rectangle();
                keys[i]        = key;
                key.Visibility = Visibility.Visible;
                keysStackPanel.Children.Add(key);
                switch (i % 12)
                {
                case 0:
                    key.Style = (Style)keysStackPanel.Resources["whiteKey"];
                    key.Fill  = (Brush)Resources["keyOctaveStartColor"];
                    break;

                case 2:
                case 4:
                case 7:
                case 9:
                case 11:
                    key.Style = (Style)keysStackPanel.Resources["whiteKeyAfterBlack"];
                    break;

                case 5:
                    key.Style = (Style)keysStackPanel.Resources["whiteKey"];
                    break;

                case 1:
                case 3:
                case 6:
                case 8:
                case 10:
                    key.Style = (Style)keysStackPanel.Resources["blackKey"];
                    break;
                }

                var keyNumber = i;

                key.MouseLeftButtonDown += (sender, e) =>
                {
                    var rect     = (Rectangle)sender;
                    var velocity = e.GetPosition(rect).Y / rect.ActualHeight * 127;
                    plugin.MidiProcessor.PressNoteFromUI((byte)keyNumber, (byte)velocity);
                };

                key.MouseEnter += (sender, e) =>
                {
                    if (e.LeftButton == MouseButtonState.Pressed)
                    {
                        var rect     = (Rectangle)sender;
                        var velocity = e.GetPosition(rect).Y / rect.ActualHeight * 127;
                        plugin.MidiProcessor.PressNoteFromUI((byte)keyNumber, (byte)velocity);
                    }
                };

                key.MouseLeave += (sender, e) =>
                {
                    plugin.MidiProcessor.ReleaseNoteFromUI((byte)keyNumber, 0);
                };

                key.MouseLeftButtonUp += (sender, e) =>
                {
                    plugin.MidiProcessor.ReleaseNoteFromUI((byte)keyNumber, 0);
                };
            }

            midiProcessor.NoteOn += (sender, e) =>
            {
                if (keys.ContainsKey(e.Note.NoteNo))
                {
                    Dispatcher.InvokeAsync(() => keys[e.Note.NoteNo].Opacity = 0.3);
                }
            };

            midiProcessor.NoteOff += (sender, e) =>
            {
                if (keys.ContainsKey(e.Note.NoteNo))
                {
                    Dispatcher.InvokeAsync(() => keys[e.Note.NoteNo].Opacity = 1);
                }
            };
        }
コード例 #5
0
 private void buttonCalibrateToe_Click(object sender, EventArgs e)
 {
     MidiProcessor.CalibrateFootPedal(ConfigValues.PedalCalibrationId.ControlToe);
 }
コード例 #6
0
 private void buttonCalibrateDown_Click(object sender, EventArgs e)
 {
     MidiProcessor.CalibrateFootPedal(ConfigValues.PedalCalibrationId.SwitchOn);
 }
コード例 #7
0
 private void buttonColHi_Click(object sender, EventArgs e)
 {
     MidiProcessor.DisplayColours(1);
 }
コード例 #8
0
        public Config(ConfigValues values, MidiProcessor processor)
        {
            InitializeComponent();
            configValues  = values;
            midiProcessor = processor;

            for (int device = 0; device < MidiOut.NumberOfDevices; device++)
            {
                comboBoxOutput.Items.Add(MidiOut.DeviceInfo(device).ProductName);
            }

            foreach (var layout in ConfigValues.Layouts.Choices)
            {
                comboBoxLayout.Items.Add(layout);
            }

            foreach (var pressure in ConfigValues.Pressures.Choices)
            {
                comboBoxPressure.Items.Add(pressure);
            }

            foreach (var touchStripMode in ConfigValues.TouchStripModes.Choices)
            {
                comboBoxTouchStrip.Items.Add(touchStripMode);
            }

            foreach (var pedalMode in ConfigValues.PedalModes.Choices)
            {
                comboBoxPedal.Items.Add(pedalMode);
            }

            foreach (var scale in MidiProcessor.Scales.Keys)
            {
                comboBoxScale.Items.Add(scale);
                comboBoxSwitchedScale.Items.Add(scale);
            }

            foreach (var key in configValues.Keys.Keys)
            {
                comboBoxKey.Items.Add(key);
            }

            comboBoxLayoutStore.Items.Add("Current");
            foreach (var store in Push.StoreageButtonLabels.Values)
            {
                comboBoxLayoutStore.Items.Add("Store " + store);
            }

            comboBoxOutput.SelectedIndex        = 0;
            comboBoxLayout.SelectedIndex        = 0;
            comboBoxLayoutStore.SelectedIndex   = 0;
            comboBoxScale.SelectedIndex         = 0;
            comboBoxSwitchedScale.SelectedIndex = 0;
            comboBoxKey.SelectedIndex           = 0;
            comboBoxPressure.SelectedIndex      = 0;
            comboBoxTouchStrip.SelectedIndex    = 0;
            comboBoxPedal.SelectedIndex         = 0;

            if (!String.IsNullOrEmpty(values.Output))
            {
                comboBoxOutput.SelectedItem = values.Output;
            }
            if (!String.IsNullOrEmpty(values.Layout))
            {
                comboBoxLayout.SelectedItem = values.Layout;
            }
            comboBoxPressure.SelectedItem         = values.Pressure;
            comboBoxTouchStrip.SelectedItem       = values.TouchStripMode;
            comboBoxPedal.SelectedItem            = values.PedalMode;
            checkBoxUserModeOnly.Checked          = configValues.UserModeOnly;
            comboBoxPadStartNote.SelectedIndex    = configValues.FixLayout ? 1 : 0;
            comboBoxKeyChangeAmount.SelectedIndex = configValues.KeyChangeFifths ? 1 : 0;

            LoadScaleValues();
        }