Esempio n. 1
0
		void LoadBtnClick(object sender, EventArgs e)
		{
			var dialog = new OpenFileDialog();
			dialog.Filter = "Effect Preset Files (.fxp)|*.fxp|Effect Bank Files (.fxb)|*.fxb|All Files|*.*||";
			if (dialog.ShowDialog(this) == DialogResult.OK)
			{
				string fxpFilePath = dialog.FileName;
				VstHost host = VstHost.Instance;
				host.PluginContext = this.PluginContext;
				
				host.LoadFXP(fxpFilePath);
				FillProgram(PluginContext.PluginCommandStub.GetProgram());
			}
		}
        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);
            }
        }