Exemplo n.º 1
0
        private void SineWaveEffectWorkHandler(object sender, DoWorkEventArgs e)
        {
            List <object> passedParams = e.Argument as List <object>;
            int           freq         = (int)passedParams[0];
            double        ampl         = (double)passedParams[1];

            audioItem = AudioItemManager.GetAudioItem();

            if (audioItem != null)
            {
                SetMaxProgressBar();

                float[] samplesToProcess;
                long    beginIndex, endIndex;
                int     seconds, miliseconds, minutes;
                int     fullTime = 0;
                SetDataForProcessing(out samplesToProcess, out minutes, out beginIndex, out endIndex, out seconds, out miliseconds);

                int begIndex = (int)beginIndex;
                int enIndex  = (int)endIndex;

                AudioSineWaveEffect.SineWaveInit((short)freq, (float)ampl);
                AudioSineWaveEffect.AddSineWave(samplesToProcess, audioItem.WaveFormat.SampleRate, begIndex, enIndex, ref fullTime);

                this.disp.Invoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    MainWindow.progressBar.Value = 100; // Do all the ui thread updates here
                }));

                audioItem.ProcessedAudioBuffer = samplesToProcess;

                AudioItemManager.SetAudioItem(audioItem);

                ResetProgressBar();

                var milisecondsTime = (double)fullTime / 1000;

                e.Result = "Selection : " + minutes + ":" + AudioItemManager.Instance.GetBeginSpan().Seconds.ToString() + ":" + AudioItemManager.Instance.GetBeginSpan().Milliseconds.ToString() + " - " + AudioItemManager.Instance.GetEndSpan().Minutes.ToString() + ":" + AudioItemManager.Instance.GetEndSpan().Seconds.ToString() + ":" + AudioItemManager.Instance.GetEndSpan().Milliseconds.ToString()
                           + "  " + " -> Processed SineWave effect on audio sample!" + "\nProcessing range length: " + (endIndex - beginIndex).ToString() +
                           "\n" + dllType.ToString() + " library time elapsed: " + milisecondsTime.ToString() + " msec" + "\nThreads count: " + threadsValue.ToString();
            }
            else
            {
                e.Result = "Audio not loaded!";
            }
        }
Exemplo n.º 2
0
 public void ProcessArray(object[] arraySamplesProcess, int beginIndex, int endIndex, ref int timeElapsed)
 {
     AudioSineWaveEffect.AddSineWave(Utility.Utilty.ToFloatArray(arraySamplesProcess), sampleRate, beginIndex, endIndex, ref timeElapsed);
 }