Esempio n. 1
0
 private void StartMonitoring()
 {
     if (comboBoxMidiInDevices.Items.Count == 0)
     {
         MessageBox.Show("No MIDI input devices available");
         return;
     }
     if (midiIn != null)
     {
         midiIn.Dispose();
         midiIn.MessageReceived -= midiIn_MessageReceived;
         midiIn.ErrorReceived -= midiIn_ErrorReceived;
         midiIn = null;
     }
     if (midiIn == null)
     {
         midiIn = new MidiIn(comboBoxMidiInDevices.SelectedIndex);
         midiIn.MessageReceived += midiIn_MessageReceived;
         midiIn.ErrorReceived += midiIn_ErrorReceived;
     }
     midiIn.Start();
     monitoring = true;
     buttonMonitor.Text = "Stop";
     comboBoxMidiInDevices.Enabled = false;
 }
Esempio n. 2
0
        private void StartMonitoring()
        {
            if (midiIn == null)
            {
                midiIn = new MidiIn(comboBoxMidiInDevices.SelectedIndex);
                midiIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
                midiIn.ErrorReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_ErrorReceived);
            }
            midiIn.Start();
            monitoring = true;
            buttonMonitor.Text = "Stop";
            comboBoxMidiInDevices.Enabled = false;

        }
Esempio n. 3
0
 private void MidiInForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     timer1.Enabled = false;
     StopMonitoring();
     if (midiIn != null)
     {
         midiIn.Dispose();
         midiIn = null;
     }
     if (midiOut != null)
     {
         midiOut.Dispose();
         midiOut = null;
     }
 }
Esempio n. 4
0
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			for (int device = 0; device < MidiIn.NumberOfDevices; device++)
			{
				comboBoxMidiInDevices.Items.Add(MidiIn.DeviceInfo(device).ProductName);
			}
			if (comboBoxMidiInDevices.Items.Count > 0)
			{
				comboBoxMidiInDevices.SelectedIndex = 0;
			}
			for (int device = 0; device < MidiOut.NumberOfDevices; device++)
			{
				comboBoxMidiOutDevices.Items.Add(MidiOut.DeviceInfo(device).ProductName);
			}
			if (comboBoxMidiOutDevices.Items.Count > 0)
			{
				comboBoxMidiOutDevices.SelectedIndex = 0;
			}

			if (comboBoxMidiInDevices.Items.Count == 0)
			{
				//MessageBox.Show("No MIDI input devices available");
			} else {
				if (midiIn == null)
				{
					midiIn = new MidiIn(comboBoxMidiInDevices.SelectedIndex);
					midiIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
					midiIn.ErrorReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_ErrorReceived);
				}
				midiIn.Start();
				comboBoxMidiInDevices.Enabled = false;
			}
			
			if (comboBoxMidiOutDevices.Items.Count == 0)
			{
				MessageBox.Show("No MIDI output devices available");
			} else {
				if (midiOut == null)
				{
					midiOut = new MidiOut(comboBoxMidiOutDevices.SelectedIndex);
				}
			}
		}
Esempio n. 5
0
		private void StartMonitoring()
		{
			if (comboBoxMidiInDevices.Items.Count == 0)
			{
				MessageBox.Show("No MIDI input devices available");
				return;
			}
			if (midiIn == null)
			{
				midiIn = new MidiIn(comboBoxMidiInDevices.SelectedIndex);
				midiIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
				midiIn.ErrorReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_ErrorReceived);
			}
			midiIn.Start();
			monitoring = true;
			buttonMonitor.Text = "Stop";
			comboBoxMidiInDevices.Enabled = false;
			
			if (midiOut == null)
			{
				midiOut = new MidiOut(comboBoxMidiOutDevices.SelectedIndex);
			}
		}
Esempio n. 6
0
		void MainFormFormClosing(object sender, FormClosingEventArgs e)
		{
			if (midiIn != null)
			{
				midiIn.Dispose();
				midiIn = null;
			}
			if (midiOut != null)
			{
				midiOut.Dispose();
				midiOut = null;
			}
			if (vstForm != null)
			{
				vstForm.Dispose();
				vstForm = null;
			}
			UtilityAudio.Dispose();
		}
Esempio n. 7
0
        private void CreateMidi()
        {
            if (midiIn != null)
            {
                midiIn.Stop();
                midiIn.Close();
                midiIn.Dispose();
            }

            if (MidiIn.NumberOfDevices > 0)
            {
                MidiInCapabilities cap = MidiIn.DeviceInfo(0);
                midiIn = new NAudio.Midi.MidiIn(0);
            }

            if (midiIn != null)
            {
                midiIn.Start();
                midiIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// From Mark Heath example http://mark-dot-net.blogspot.com/2008/10/midi-in-for-babysmash.html
 /// </summary>
 private void StartMonitoringMidi()
 {
     midiIn = new MidiIn(0); // default device
     midiIn.MessageReceived += midiIn_MessageReceived;
     midiIn.Start();
 }
Esempio n. 9
0
        private void CSelectedInput_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int inputIndex = CSelectedInput.SelectedIndex;

            if (MidiDevice != null)
            {
                MidiDevice.Close();
                MidiDevice.Dispose();
            }

            MidiDevice = new MidiIn(inputIndex);
            MidiDevice.Start();
            MidiDevice.MessageReceived += MidiDeviceOnMessageReceived;
        }
Esempio n. 10
0
        private void lbInputDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if the user chooses another input, create a new MIDI input device and use that
            if (mIn != null)
            {
                //dispose the current midi in and create a new one
                mIn.Dispose();

                //create a new MIDI input object with the newly selected input device
                mIn = new MidiIn(lbInputDevices.SelectedIndex);
                mIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
                mIn.ErrorReceived += (s, o) => { MessageBox.Show("Whoops, an error occurred!"); };

                mIn.Start();
            }
        }
Esempio n. 11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //iterate through all MidiIn devices and add them to the listbox so the user can choose which one to use
            for (int i = 0; i < MidiIn.NumberOfDevices; i++)
            {
                lbInputDevices.Items.Add(MidiIn.DeviceInfo(i).ProductName);

                //regardless of how many devices are added (assuming at least one), the default will be the first one in the list
                lbInputDevices.SelectedIndex = 0;
            }

            //iterate through all MidiOut devices and add them to the listbox so the user can choose which one to use
            for (int i = 0; i < MidiOut.NumberOfDevices; i++)
            {
                lbOutputDevices.Items.Add(MidiOut.DeviceInfo(i).ProductName);

                //regardless of how many devices are added (assuming at least one), the default will be the first one in the list
                lbOutputDevices.SelectedIndex = 0;
            }

            if (mIn == null)
            {
                if (lbInputDevices.Items.Count > 0)
                {
                    //create the new MidiIn object and set up its event handlers
                    mIn = new MidiIn(lbInputDevices.SelectedIndex);
                    mIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
                    mIn.ErrorReceived += (s, o) => { MessageBox.Show("Whoops, an error occurred!"); };

                    //start listening
                    mIn.Start();

                    //create out midi out (so that we can hear the sound playing)
                    if (mOut == null)
                    {
                        mOut = new MidiOut(lbOutputDevices.SelectedIndex);
                    }
                }
                else
                {
                    //warn the user that no midi devices have been found and that they should connect one before clicking Retry
                    if (MessageBox.Show("Please connect a MIDI device and click Retry otherwise click Cancel to exit.", "No MIDI Devices Found", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Retry)
                    {
                        //restart the program if the user selected 'Retry'
                        System.Diagnostics.Process.Start(Application.ExecutablePath);
                        Application.Exit();
                    }
                    else
                        Application.Exit();
                }
            }
        }
Esempio n. 12
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //dispose the midi inputs and outputs
            if (mIn != null)
            {
                mIn.Dispose();
                mIn = null;
            }

            if (mOut != null)
            {
                mOut.Dispose();
                mOut = null;
            }
        }
Esempio n. 13
0
 private void SetPlayer()
 {
     /*
     switch (ComboBoxAPISelection.SelectedIndex)
     {
         case 0:
             var wo = new WaveOut();
             wo.DeviceNumber = ComboBoxOutputSelection.SelectedIndex;
             wo.DesiredLatency = 100;
             player = wo;
             break;
         case 1:
             var dso = new DirectSoundOut();
             player = dso;
             break;
         case 2:
             var waso = new WasapiOut(AudioClientShareMode.Exclusive, 200);
             player = waso;
             break;
         case 3:
             var ao = new AsioOut();
             player = ao;
             break;
         default:
             break;
     }
      * */
     //ストリーミング品質的にDirectSoundで
     player = new DirectSoundOut();
     min = new MidiIn(ComboBoxMidiInSelection.SelectedIndex);
     min.MessageReceived += min_MessageReceived;
     min.Start();
     TimerStreaming.Start();
     provider = new BufferedWaveProvider(format);
     player.Init(provider);
     player.Play();
     connected = true;
 }
        public PadForm()
        {
            this.AutoSize = true;

            errorState = false;
            showlables = false;
            hlButtons = false;

            preset = new Preset(pCount: 8,bCount: 72);
            for (int i = 0; i < MidiIn.NumberOfDevices; i++)
            {
                if (MidiIn.DeviceInfo(i).ProductName == "Launchpad Emulator")
                {
                    midiin = new MidiIn(i);
                    break;
                }
            }
            for (int i = 0; i < MidiOut.NumberOfDevices; i++)
            {
                if (MidiOut.DeviceInfo(i).ProductName == "Launchpad Emulator")
                {
                    launchpad = new Launchpad(i);
                    break;
                }
            }

            if (midiin != null && launchpad != null)
            {
                midiin.Start();
                midiin.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiEffectsIn);

                InitializeComponent();
                this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

                buttons = new PadButton[72];
                for (int i = 0, x = 36, y = 105; i < 64; i++, x += 62)
                {
                    if (x == 36 + (62 * 8))
                    {
                        x = 36;
                        y += 60;
                    }
                    this.buttons[i] = new PadButton(i, rounded: false);
                    this.buttons[i].Location = new System.Drawing.Point(x, y);
                    this.buttons[i].Name = "centerButtons";
                    this.buttons[i].Size = new System.Drawing.Size(52, 52);
                    this.buttons[i].TabIndex = 1;
                    this.buttons[i].TabStop = false;
                    this.buttons[i].ButtonClick += new EventHandler(onButtonClick);
                    this.buttons[i].ButtonRelease += new EventHandler(onButtonRelease);
                    this.buttons[i].KeyChanged += new KeyChangeEvent(onKeyChanged);
                    this.buttons[i].ID = i;
                    this.alphaTheme.Controls.Add(this.buttons[i]);
                }
                for (int i = 64, y = 105; i < 72; i++, y += 60)
                {
                    this.buttons[i] = new PadButton(i, rounded: true);
                    this.buttons[i].Location = new System.Drawing.Point(532, y);
                    this.buttons[i].Name = "rightButtons";
                    this.buttons[i].Size = new System.Drawing.Size(52, 52);
                    this.buttons[i].TabIndex = 1;
                    this.buttons[i].TabStop = false;
                    this.buttons[i].ButtonClick += new EventHandler(onButtonClick);
                    this.buttons[i].ButtonRelease += new EventHandler(onButtonRelease);
                    this.buttons[i].KeyChanged += new KeyChangeEvent(onKeyChanged);
                    this.buttons[i].ID = i;
                    this.alphaTheme.Controls.Add(this.buttons[i]);
                }
                this.KeyPreview = true;
                this.KeyDown += new KeyEventHandler(onKeyDown);
                this.KeyUp += new KeyEventHandler(onKeyUp);
                this.BackColor = PadButton.backColor;
                alphaTheme.CanDrag = true;

            }
        }
Esempio n. 15
0
 public MidiControl(int device)
 {
     midiIn = new MidiIn(device);
 }