void PluginFormFormClosing(object sender, FormClosingEventArgs e) { if (playback != null) { playback.Dispose(); } VstHost host = VstHost.Instance; host.DisposeInputWave(); }
static void StartVstHost(string pluginPath, string waveInputFilePath, string fxpFilePath, string waveOutputFilePath, bool doPlay) { VstHost host = VstHost.Instance; var hcs = new HostCommandStub(); host.OpenPlugin(pluginPath, hcs); host.InputWave = waveInputFilePath; // with iblock=1...Nblocks and blocksize = Fs * tblock. Fs = 44100 and // tblock = 0.15 makes blocksize = 6615. const int sampleRate = 44100; const int blockSize = 8192; const int channels = 2; host.Init(blockSize, sampleRate, channels); System.Diagnostics.Debug.WriteLine(host.getPluginInfo()); host.LoadFXP(fxpFilePath); if (doPlay) { var playback = new VstPlaybackNAudio(host); playback.Play(); Console.WriteLine("Started Audio Playback"); // make sure to play while the stream is playing if (playback.PlaybackDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(5000); } Console.WriteLine("Ending Audio Playback"); playback.Stop(); Console.WriteLine("Stopped Audio Playback"); playback.Dispose(); } if (waveOutputFilePath != "") { var fileWriter = new VstFileWriter(host); fileWriter.CreateWaveFile(waveOutputFilePath); } }