Esempio n. 1
0
 void EditorFrameFormClosing(object sender, FormClosingEventArgs e)
 {
     if (playback != null)
     {
         playback.Stop();
     }
 }
Esempio n. 2
0
        void ProcessAudioBtnClick(object sender, EventArgs e)
        {
            // plugin does not support processing audio
            if ((PluginContext.PluginInfo.Flags & VstPluginFlags.CanReplacing) == 0)
            {
                MessageBox.Show(this, "This plugin does not process any audio.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            VstHost host = VstHost.Instance;

            host.PluginContext = this.PluginContext;
            if (waveInputFilePath != "")
            {
                host.InputWave = waveInputFilePath;
                // with iblock=1...Nblocks and blocksize = Fs * tblock. Fs = 44100 and
                // tblock = 0.15 makes blocksize = 6615.
                int sampleRate = 44100;
                int blockSize  = (int)(sampleRate * 0.15f);                 //6615;
                int channels   = 2;
                host.Init(blockSize, sampleRate, channels);

                if (playback == null)
                {
                    playback = new VstPlaybackNAudio(host);
                    playback.Play();
                }
                else
                {
                    // toogle start or stop
                    if (playback.PlaybackDevice.PlaybackState == PlaybackState.Playing)
                    {
                        playback.Stop();
                    }
                    else if (playback.PlaybackDevice.PlaybackState == PlaybackState.Stopped)
                    {
                        playback.Play();
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "Please choose an audio file to process.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        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);
            }
        }