Exemple #1
0
        private void midiOutConfirmButton_Click(object sender, EventArgs e)
        {
            if (outReady)
            {
                midiOutput.Close();
                midiOutput.Dispose();

                midiOutDevicesCB.Enabled        = true;
                refreshMidiOutButton.Enabled    = true;
                midiOutConfirmButton.ImageIndex = 0;
                outReady = false;
                checkReady(true);
            }
            else
            {
                midiOutDevicesCB.Enabled     = false;
                refreshMidiOutButton.Enabled = false;

                midiOutput = new MidiOut(midiOutDevicesCB.SelectedIndex);

                midiOutConfirmButton.ImageIndex = 1;
                outReady = true;
                checkReady(true);
            }
        }
Exemple #2
0
        private void open_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)// Тут откроется форма и если будет нажата кнопка ОК тогда путь запишется в переменную path.
            {
                _inputPath = openFileDialog.FileName;
            }

            _midiOut.Dispose();
            _midiOut.Close();
            try
            {
                var midiFile = Melanchall.DryWetMidi.Core.MidiFile.Read(_inputPath);
                using (var outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth"))
                {
                    midiFile.Play(outputDevice);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("Unreadeble file", "error", MessageBoxButtons.OK);
            }

            _midiOut = new MidiOut(0);
        }
Exemple #3
0
 public static void Init(int device)
 {
     if (midiOut != null)
     {
         midiOut.Dispose();
     }
     midiOut = new MidiOut(device);
 }
Exemple #4
0
 public void Dispose()
 {
     Unload();
     if (_midi != null)
     {
         _midi.Dispose();
     }
 }
Exemple #5
0
        public void Send()
        {
            //todo https://github.com/naudio/NAudio/blob/master/Docs/MidiInAndOut.md
            _bassMidiOut.Send(new NoteEvent(5, 1, MidiCommandCode.NoteOn, 50, 64).GetAsShortMessage());
            _bassMidiOut.Dispose();

            _tenorMidiOut.Send(new NoteEvent(1000, 1, MidiCommandCode.NoteOn, 58, 64).GetAsShortMessage());
            _tenorMidiOut.Dispose();
        }
Exemple #6
0
        /// <summary>
        /// Resource clean up.
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed && disposing)
            {
                _mdev?.Dispose();
                _mdev = null;

                _disposed = true;
            }
        }
Exemple #7
0
        public void SetDevice(MidiDeviceInfo deviceInfo)
        {
            if (midiOut != null)
            {
                midiOut.Close();
                midiOut.Dispose();
            }

            midiOut = new MidiOut(deviceInfo.DeviceId);
        }
Exemple #8
0
 private void OnDestroy()
 {
     StopAllCoroutines();
     for (int i = 11; i < 90; i++)
     {
         SendMessage(i, 0);
     }
     controllerIn.Stop();
     controllerIn.Dispose();
     controllerOut.Dispose();
 }
 internal void Stop()
 {
     if (timer != null)
     {
         timer.Dispose(new InvalidWaitHandle());
     }
     if (midi != null)
     {
         midi.Dispose();
     }
 }
Exemple #10
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (_MidiOut != null)
     {
         _MidiOut.Dispose();
     }
     if (_WaveOut != null)
     {
         _WaveOut.Dispose();
     }
 }
Exemple #11
0
        private void StopDevices()
        {
            _mIn.Dispose();
            _mOut.Dispose();

            DeviceDisable = false;
            DeviceEnable  = true;

            _ea.GetEvent <InitializedEvent>().Publish(false);

            UpdateStatus("Devices Disabled...");
        }
 private void MidiInPanel_Disposed(object sender, EventArgs e)
 {
     timer1.Enabled = false;
     StopMonitoring();
     if (midiIn != null)
     {
         midiIn.Dispose();
         midiIn = null;
     }
     if (midiOut != null)
     {
         midiOut.Dispose();
         midiOut = null;
     }
 }
Exemple #13
0
        public void Dispose()
        {
            foreach (var channel in Instruments)
            {
                channel.Stop();
            }

            percussion.Stop();

            if (midiOut != null)
            {
                midiOut.Reset();
                midiOut.Close();
                midiOut.Dispose();
                midiOut = null;
            }
        }
 public void Init(int inDeviceNo, int outDeviceNo)
 {
     if (_initialized)
     {
         _inDevice.Stop();
         _inDevice.Close();
         _inDevice.Dispose();
         _outDevice.Close();
         _outDevice.Dispose();
     }
     _inDevice  = new MidiIn(inDeviceNo);
     _outDevice = new MidiOut(outDeviceNo);
     _inDevice.MessageReceived += MessageReceived;
     _inDevice.ErrorReceived   += ErrorReceived;
     _inDevice.Start();
     _initialized = true;
 }
Exemple #15
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();
 }
        public override void KeyPressed(KeyPayload payload)
        {
            int kitNumber = 0;

            if (this.settings == null || this.settings.MidiDeviceName == null || this.settings.KitNumber == null || this.settings.KitNumber.Length == 0)
            {
                Logger.Instance.LogMessage(TracingLevel.INFO, "Unable to set kit, no kit number or midi device set.");
                return;
            }

            try
            {
                kitNumber = Int32.Parse(this.settings.KitNumber);
            }
            catch (FormatException)
            {
                Logger.Instance.LogMessage(TracingLevel.INFO, "kit number not parceable");
                return;
            }

            bool messageSent = false;

            for (int device = 0; device < MidiOut.NumberOfDevices; device++)
            {
                if (this.settings.MidiDeviceName.Equals(MidiOut.DeviceInfo(device).ProductName))
                {
                    MidiOut midiOut = new MidiOut(device);
                    midiOut.Send(new PatchChangeEvent(0, 10, kitNumber - 1).GetAsShortMessage());
                    midiOut.Dispose();
                    Logger.Instance.LogMessage(TracingLevel.INFO, "Message Sent!");
                    messageSent = true;
                }
            }

            if (!messageSent)
            {
                Logger.Instance.LogMessage(TracingLevel.INFO, "Unable to send message, no device found." +
                                           "There are " + MidiOut.NumberOfDevices + " devices.");
            }
        }
Exemple #17
0
        /// <summary>
        /// Initialize the port.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool Init(string name)
        {
            bool inited = false;

            try
            {
                if (_mdev != null)
                {
                    _mdev.Dispose();
                    _mdev = null;
                }

                if (name != "")
                {
                    for (int device = 0; device < MidiOut.NumberOfDevices && _mdev == null; device++)
                    {
                        if (name == MidiOut.DeviceInfo(device).ProductName)
                        {
                            _mdev  = new MidiOut(device);
                            inited = true;
                        }
                    }

                    if (_mdev == null)
                    {
                        ErrorInfo = $"Invalid midi output: {name}";
                        inited    = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorInfo = $"Init midi out failed: {ex.Message}";
                inited    = false;
            }

            return(inited);
        }
Exemple #18
0
 public void Dispose()
 {
     _midiIn?.Dispose();
     _midiOut?.Dispose();
     _timer?.Dispose();
 }
Exemple #19
0
 public void Dispose()
 {
     midiOut.Close();
     midiOut.Dispose();
 }
Exemple #20
0
 public void Dispose()
 {
     device?.Dispose();
 }
Exemple #21
0
 public void Dispose()
 {
     _midiOut?.Dispose();
 }
 public void Dispose()
 {
     _midiOut.Close();
     _midiOut.Dispose();
 }