示例#1
0
 void CheckBoxMidiOutMessagesCheckedChanged(object sender, EventArgs e)
 {
     if (midiOut == null)
     {
         midiOut = new MidiOut(comboBoxMidiOutDevices.SelectedIndex);
     }
 }
        public Launchpad(int deviceID)
        {
            midiout = new MidiOut(deviceID);

            int[] leftColumn = new int[32];
            int[] rightColumn = new int[32];

            for (int i = 0; i < 32; i++)
                leftColumn[i] = i + 36;
            for (int i = 0; i < 32; i++)
                rightColumn[i] = i + 68;

            mainPad = new int[72];
            for (int i = 0, l = 0; i < 8; i++)
            {
                for (int z = 3; z >= 0; z--, l++)
                    mainPad[l] = leftColumn[31 - (z + (i * 4))];
                for (int z = 3; z >= 0; z--, l++)
                    mainPad[l] = rightColumn[31 - (z + (i * 4))];
            }

            for (int i = 0; i < rightPadButtonsCount; i++)
            {
                mainPad[64+i] = 100 + i;
            }
            noteStatus = new bool[72];
        }
示例#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;
     }
 }
示例#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);
				}
			}
		}
示例#5
0
        public MainForm()
        {
            InitializeComponent();

            System.Reflection.AssemblyName AsName = System.Reflection.Assembly.GetExecutingAssembly().GetName();
            this.Text = AsName.Name + " - " + AsName.Version;

            //Ouverture du Midi par defaut
            mMidiOut = new MidiOut(0);
            //trouve les peripheriques Midi Out et remplit la liste
            PopulateMidiDevicesBox();

            try
            {
                _conf = new Configuration("Settings.xml");
                mtouchMessages = _conf.getConfig();
            }
            catch
            {
                MessageBox.Show("Configuration File not found, using default values...");
            }

        }
示例#6
0
 public MusicPlayer()
 {
     midiOut = new MidiOut(0);
     MaxKeyTime = 0;
 }
示例#7
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);
			}
		}
示例#8
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();
		}
示例#9
0
 private void SendNextMidiOutMessage()
 {
     if (midiOut == null)
     {
         midiOut = new MidiOut(comboBoxMidiOutDevices.SelectedIndex);
     }
     MidiEvent eventToSend = events[midiOutIndex++];
     midiOut.Send(eventToSend.GetAsShortMessage());
     progressLog1.LogMessage(Color.Green, String.Format("Sent {0}", eventToSend));
     if (midiOutIndex >= events.Count)
     {
         midiOutIndex = 0;
     }
 }
示例#10
0
 public void Play()
 {
     ResetCounters();
     _midi = new MidiOut(MidiDevice);
     if (_sr != null)
         _sr.Start();
 }
示例#11
0
 public void Unload()
 {
     _seq = null;
     if (_sr != null)
     {
         _sr.OnTrackEvent -= sr_OnTrackEvent;
         _sr.SequenceEnd -= sr_SequenceEnd;
         _sr.TempoChanged -= sr_TempoChanged;
         _sr.Stop();
         _sr = null;
     }
     if (_midi != null)
     {
         _midi.Close();
         _midi = null;
     }
 }
示例#12
0
        private void comboBoxMidiOut_SelectedIndexChanged(object sender, EventArgs e)
        {
            mMidiOut.Close();

            mMidiOut = new MidiOut(comboBoxMidiOut.SelectedIndex);
        }
示例#13
0
 public NAudioMidiOutput(int deviceID)
 {
     this.DeviceID = deviceID;
     Output = new MidiOut(DeviceID);
 }
示例#14
0
 public void Open(int deviceID = 0)
 {
     Close();
     for (int i = 0; i < noteMode.Length; i++)
     {
         noteMode[i] = NoteStyle.Regular;
     }
     this.midiOut = new MidiOut(deviceID);
     this.waveOut = new WasapiOut(AudioClientShareMode.Shared, 5);
     this.waveOut.Init(this.mixer);
     this.waveOut.Play();
 }
示例#15
0
        private void lbOutputDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if the user chooses another output, use a new MIDI output device and use that
            if (mOut != null)
            {
                //dispose the current midi in and create a new one
                mOut.Dispose();

                //create a new MIDI input object with the newly selected input device
                mOut = new MidiOut(lbOutputDevices.SelectedIndex);

            }
        }
示例#16
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();
                }
            }
        }
示例#17
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;
            }
        }