コード例 #1
0
        private void ClearAudio()
        {
            VstHost host = VstHost.Instance;

            host.ClearRecording();

            this.waveDisplayUserControl1.SetAudioData(host.RecordedLeft.ToArray());
        }
コード例 #2
0
        void ClearBtnClick(object sender, EventArgs e)
        {
            VstHost host = VstHost.Instance;

            host.ClearRecording();

            MaxResolutionTrackBar.Maximum       = 100;
            MaxResolutionTrackBar.TickFrequency = 10;

            this.waveDisplayUserControl1.Resolution = 1;
            this.waveDisplayUserControl1.SetAudioData(host.RecordedLeft.ToArray());
        }
コード例 #3
0
        private void ClearAudio()
        {
            VstHost host = VstHost.Instance;

            host.ClearRecording();

            MaxResolutionTrackBar.Maximum       = 100;
            MaxResolutionTrackBar.TickFrequency = 10;

            this.waveDisplayUserControl1.Resolution = 1;
            this.waveDisplayUserControl1.SetAudioData(host.RecordedLeft.ToArray());
        }
コード例 #4
0
        void MeasureLFOBtnClick(object sender, EventArgs e)
        {
            MeasureLFOInit();
            VstHost host = VstHost.Instance;

            List <string> lfoAlreadyProcessed = new List <string>();

            // step through the LFO steps
            int count = 0;

            for (float paramValue = 1.0f; paramValue >= 0.0f; paramValue -= 0.020f)
            {
                // time how long this takes
                Stopwatch stopwatch = Stopwatch.StartNew();

                // init the buffers
                host.ClearRecording();
                host.ClearLastProcessedBuffers();

                // start record
                host.Record = true;

                // set the parameter
                PluginContext.PluginCommandStub.SetParameter(SYLENTH_PARAM_LFO1_RATE, paramValue);

                // get param display value
                string paramDisplay = PluginContext.PluginCommandStub.GetParameterDisplay(SYLENTH_PARAM_LFO1_RATE);

                // check if already processed
                if (lfoAlreadyProcessed.Contains(paramDisplay))
                {
                    continue;
                }
                else
                {
                    lfoAlreadyProcessed.Add(paramDisplay);
                }

                // wait until it has started playing
                while (!host.LastProcessedBufferLeftPlaying)
                {
                    // start playing audio
                    Playback.Play();

                    // play midi
                    host.SendMidiNote(host.SendContinousMidiNote, host.SendContinousMidiNoteVelocity);

                    if (stopwatch.ElapsedMilliseconds > 5000)
                    {
                        stopwatch.Stop();
                        System.Console.Out.WriteLine("MeasureLFOBtnClick: Playing Midi Failed!");
                        return;
                    }
                    System.Threading.Thread.Sleep(100);
                }

                // play for approx 1000 ms
                // paramValue: 1 = 1/256 Triple     (count = 0)
                // paramValue: 0 = 8/1 D			(count = 10)
                System.Threading.Thread.Sleep((int)(20 * Math.Pow(count, 2)));

                // stop midi
                host.SendMidiNote(host.SendContinousMidiNote, 0);

                // wait until it has stopped playing
                while (host.LastProcessedBufferLeftPlaying)
                {
                    if (stopwatch.ElapsedMilliseconds > 40000)
                    {
                        System.Console.Out.WriteLine("MeasureLFOBtnClick: Playing never stopped?!");
                        break;
                    }
                }
                // stop playing audio
                Playback.Stop();

                stopwatch.Stop();
                System.Console.Out.WriteLine("MeasureLFOBtnClick: Playing stopped: {0} ms. {1}", stopwatch.ElapsedMilliseconds, paramDisplay);

                // stop recording
                host.Record = false;

                // crop
                CropAudio();

                // store this in a wav ouput file.
                string wavFilePath = String.Format("audio-LFO-{0}-{1}.wav", StringUtils.MakeValidFileName(paramDisplay), StringUtils.GetCurrentTimestamp());
                AudioUtilsNAudio.CreateWaveFile(host.RecordedLeft.ToArray(), wavFilePath, new WaveFormat(host.SampleRate, 1));

                // store as a png
                System.Drawing.Bitmap png = CommonUtils.FFT.AudioAnalyzer.DrawWaveform(host.RecordedLeft.ToArray(), new System.Drawing.Size(1000, 600), 10000, 1, 0, host.SampleRate);
                string fileName           = String.Format("audio-LFO-{0}-{1}.png", StringUtils.MakeValidFileName(paramDisplay), StringUtils.GetCurrentTimestamp());
                png.Save(fileName);

                // clear
                ClearAudio();

                // wait a specfied time
                System.Threading.Thread.Sleep(100);

                stopwatch.Stop();

                count++;
            }
        }
コード例 #5
0
        void MeasureADSRParameter(int paramName, float paramValue, string envName, bool measureRelease = false)
        {
            System.Console.Out.WriteLine("MeasureADSREntry: Measuring {0} at value {1:0.00}...", envName, paramValue);

            VstHost host = VstHost.Instance;

            // time how long this takes
            Stopwatch stopwatch = Stopwatch.StartNew();

            // init the buffers
            host.ClearRecording();
            host.ClearLastProcessedBuffers();

            // start record
            host.Record = true;

            // set the parameter
            PluginContext.PluginCommandStub.SetParameter(paramName, paramValue);
            ((HostCommandStub)PluginContext.HostCommandStub).SetParameterAutomated(paramName, paramValue);

            // wait until it has started playing
            while (!host.LastProcessedBufferLeftPlaying)
            {
                // start playing audio
                Playback.Play();

                // play midi
                host.SendMidiNote(host.SendContinousMidiNote, host.SendContinousMidiNoteVelocity);

                if (stopwatch.ElapsedMilliseconds > 5000)
                {
                    stopwatch.Stop();
                    System.Console.Out.WriteLine("MeasureADSREntry: Playing Midi Failed!");
                    return;
                }
                System.Threading.Thread.Sleep(100);
            }

            if (measureRelease)
            {
                // release is a special case where you only measure the tail after
                // a short midi signal
                // therefore we need to stop the midi message here
                host.SendMidiNote(host.SendContinousMidiNote, 0);
            }

            // wait until it has stopped playing
            stopwatch.Restart();
            while (host.LastProcessedBufferLeftPlaying)
            {
                if (stopwatch.ElapsedMilliseconds > 40000)
                {
                    stopwatch.Stop();
                    System.Console.Out.WriteLine("MeasureADSREntry: Playing never stopped?!");
                    break;
                }
            }

            // stop playing audio
            Playback.Stop();

            stopwatch.Stop();
            System.Console.Out.WriteLine("MeasureADSREntry: Playing stopped: {0} ms.", stopwatch.ElapsedMilliseconds);

            // stop recording
            host.Record = false;

            // wait a specfied time
            System.Threading.Thread.Sleep(100);

            // crop
            CropAudio();

            // store the duration
            RetrieveDuration();

            // store this in a wav ouput file.
            float  param       = PluginContext.PluginCommandStub.GetParameter(paramName);
            string wavFilePath = String.Format("{0}{1:0.00}s-{2}.wav", envName, param, StringUtils.GetCurrentTimestamp());

            AudioUtilsNAudio.CreateWaveFile(host.RecordedLeft.ToArray(), wavFilePath, new WaveFormat(host.SampleRate, 1));

            // store as a png
            System.Drawing.Bitmap png = CommonUtils.FFT.AudioAnalyzer.DrawWaveform(host.RecordedLeft.ToArray(), new System.Drawing.Size(1000, 600), 10000, 1, 0, host.SampleRate);
            string fileName           = String.Format("{0}{1:0.00}s-{2}.png", envName, param, StringUtils.GetCurrentTimestamp());

            png.Save(fileName);

            if (!measureRelease)
            {
                // turn of midi unless we are measuring a release envelope
                // then it should have been turned of immideately after a small signal is generated
                host.SendMidiNote(host.SendContinousMidiNote, 0);
            }

            // clear
            ClearAudio();

            // wait a specfied time
            System.Threading.Thread.Sleep(100);

            stopwatch.Stop();
        }