//VstPluginContext pluginContext = null; //VSTStream vstStream = null; //IWavePlayer playbackDevice = null; //EditParametersForm edit = new EditParametersForm(); //RecordableMixerStream32 mixer=new RecordableMixerStream32(); //WaveChannel32 mp3Channel = null; //long mp3Position = 0; //MixerForm mixerForm = null; public VSTForm(string VSTPath) { Singleton = this; UtilityAudio.OpenAudio(AudioLibrary.NAudio, null); InitializeComponent(); vst = UtilityAudio.LoadVST(VSTPath, this.Handle); this.Text = vst.pluginContext.PluginCommandStub.GetProgramName(); Rectangle rect = new Rectangle(); vst.pluginContext.PluginCommandStub.EditorGetRect(out rect); this.SetClientSizeCore(rect.Width, rect.Height + 125); vst.StreamCall += new EventHandler<VSTStreamEventArgs>(vst_StreamCall); UtilityAudio.StartAudio(); /*HostCommandStub hcs = new HostCommandStub(); hcs.Directory = System.IO.Path.GetDirectoryName(VSTPath); try { pluginContext = VstPluginContext.Create(VSTPath, hcs); pluginContext.PluginCommandStub.Open(); this.Text= pluginContext.PluginCommandStub.GetProgramName(); //pluginContext.PluginCommandStub.SetProgram(0); pluginContext.PluginCommandStub.EditorOpen(this.Handle); Rectangle rect = new Rectangle(); pluginContext.PluginCommandStub.EditorGetRect(out rect); this.SetClientSizeCore(rect.Width, rect.Height+125); pluginContext.PluginCommandStub.MainsChanged(true); vstStream = new VSTStream(); vstStream.ProcessCalled += new EventHandler<ProcessCalledEventArgs>(vstStream_ProcessCalled); vstStream.pluginContext = pluginContext; vstStream.SetWaveFormat(44100, 2); mixer.AddInputStream(vstStream); playbackDevice = new AsioOut(0);//new WaveOut();// playbackDevice.Init(mixer); } catch (Exception ex) { MessageBox.Show(ex.Message); }*/ }
public new void Dispose() { /*edit.Close(); playbackDevice.Stop(); playbackDevice.Dispose(); pluginContext.Dispose(); if(mp3Channel!=null) mp3Channel.Dispose(); if(mixerForm!=null) mixerForm.Close(); */ UtilityAudio.DisposeVST(); vst = null; base.Dispose(); Singleton = null; }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { //File.Delete(Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); SaveSetting(Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); //Salviamo la porta aperta if (UtilityMIDI.IsOpen(MIDIType.Serial)) { UtilityIniFile.SetIniString("Setup", "COM", UtilityMIDI.PortName(MIDIType.Serial), Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityMIDI.Close(MIDIType.Serial); } if (UtilityMIDI.IsOpen(MIDIType.MIDI_IN)) { UtilityIniFile.SetIniString("Setup", "MIDI_IN", UtilityMIDI.PortName(MIDIType.MIDI_IN), Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityMIDI.Close(MIDIType.MIDI_IN); } else UtilityIniFile.SetIniString("Setup", "MIDI_IN", "", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); if (UtilityMIDI.IsOpen(MIDIType.MIDI_OUT)) { UtilityIniFile.SetIniString("Setup", "MIDI_OUT", UtilityMIDI.PortName(MIDIType.MIDI_OUT), Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityMIDI.Close(MIDIType.MIDI_OUT); } else UtilityIniFile.SetIniString("Setup", "MIDI_OUT", "", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityIniFile.SetIniString("Setup", "Configuration", configurationToolStripMenuItem.Checked ? "Show" : "Hide", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityIniFile.SetIniString("Setup", "Tool", toolToolStripMenuItem.Checked ? "Show" : "Hide", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityIniFile.SetIniString("Setup", "Monitor", monitorToolStripMenuItem.Checked ? "Show" : "Hide", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityIniFile.SetIniString("Setup", "SFZ", sFZToolStripMenuItem.Checked ? "Show" : "Hide", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); UtilityIniFile.SetIniString("Setup", "Effects", effectsToolStripMenuItem.Checked ? "Show" : "Hide", Application.StartupPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Option.ini"); if (vstForm != null) { vstForm.Dispose(); vstForm = null; } if (sfz != null) sfz.Dispose(); UtilityAudio.Dispose(); }
private void VSTForm_FormClosed(object sender, FormClosedEventArgs e) { /*playbackDevice.Stop(); playbackDevice.Dispose(); pluginContext.Dispose(); mp3Channel.Dispose(); mixerForm.Close();*/ Singleton = null; }
private void loadToolStripMenuItem1_Click(object sender, EventArgs e) { if (vstForm != null) { vstForm.Dispose(); vstForm = null; showToolStripMenuItem.Enabled = false; editParametersToolStripMenuItem.Enabled = false; noteMapToolStripMenuItem.Enabled = false; loadToolStripMenuItem1.Text = "Load..."; } else { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select VST:"; ofd.Filter = "VST Files (*.dll)|*.dll"; if (LastDirectoryUsed.ContainsKey("VSTDir")) ofd.InitialDirectory = LastDirectoryUsed["VSTDir"]; else ofd.InitialDirectory = UtilityAudio.GetVSTDirectory(); DialogResult res = ofd.ShowDialog(); if (res != DialogResult.OK || !File.Exists(ofd.FileName)) return; try { if (LastDirectoryUsed.ContainsKey("VSTDir")) LastDirectoryUsed["VSTDir"] = Directory.GetParent(ofd.FileName).FullName; else LastDirectoryUsed.Add("VSTDir", Directory.GetParent(ofd.FileName).FullName); vstForm = new VSTForm(ofd.FileName); vstForm.Show(); showToolStripMenuItem.Enabled = true; editParametersToolStripMenuItem.Enabled = true; noteMapToolStripMenuItem.Enabled = true; loadToolStripMenuItem1.Text = "Unload..."; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }