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); } }
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); }
public static void Init(int device) { if (midiOut != null) { midiOut.Dispose(); } midiOut = new MidiOut(device); }
public void Dispose() { Unload(); if (_midi != null) { _midi.Dispose(); } }
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(); }
/// <summary> /// Resource clean up. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_disposed && disposing) { _mdev?.Dispose(); _mdev = null; _disposed = true; } }
public void SetDevice(MidiDeviceInfo deviceInfo) { if (midiOut != null) { midiOut.Close(); midiOut.Dispose(); } midiOut = new MidiOut(deviceInfo.DeviceId); }
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(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (_MidiOut != null) { _MidiOut.Dispose(); } if (_WaveOut != null) { _WaveOut.Dispose(); } }
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; } }
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; }
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."); } }
/// <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); }
public void Dispose() { _midiIn?.Dispose(); _midiOut?.Dispose(); _timer?.Dispose(); }
public void Dispose() { midiOut.Close(); midiOut.Dispose(); }
public void Dispose() { device?.Dispose(); }
public void Dispose() { _midiOut?.Dispose(); }
public void Dispose() { _midiOut.Close(); _midiOut.Dispose(); }