Пример #1
0
 protected override void InitalizeConcreteAudioEffect()
 {
     AudioWahWahEffect.AutoWahInit((short)audioEffectParameters["Effect Rate"],
                                   (short)audioEffectParameters["Sampling Frequency"],
                                   (short)audioEffectParameters["Maximum Frequency"],
                                   (short)audioEffectParameters["MinimumFrequency"],
                                   (short)audioEffectParameters["Q"],
                                   (double)audioEffectParameters["Gain Factor"],
                                   (short)audioEffectParameters["Fequency Increment"]);
 }
Пример #2
0
        private void WahWahEffectWorkHandler(object sender, DoWorkEventArgs e)
        {
            List <object> passedParams = e.Argument as List <object>;
            int           effectRate   = (int)passedParams[0];
            int           maxF         = (int)passedParams[1];
            int           minF         = (int)passedParams[2];
            int           Q            = (int)passedParams[3];
            double        gainFactor   = (double)passedParams[4];


            audioItem = AudioItemManager.GetAudioItem();

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

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

                AudioWahWahEffect.AutoWahInit((short)effectRate, /*Effect rate 2000*/
                                              16000,             /*Sampling Frequency*/
                                              (short)maxF,       /*Maximum frequency*/
                                              (short)minF,       /*Minimum frequency*/
                                              (short)Q,          /*Q*/
                                              gainFactor,        /*Gain factor*/
                                              10 /*Frequency increment*/);

                AudioWahWahEffect.AutoWahSweep();


                if (threadsValue > 1)
                {
                    samplesCountForThreads = (int)((endIndex - beginIndex) / threadsValue);
                    samplesThreadToProcess = new int[threadsValue];

                    for (int i = 0; i < threadsValue; i++)
                    {
                        samplesThreadToProcess[i] = (int)beginIndex + (samplesCountForThreads * i);
                    }
                    samplesThreadToProcess[threadsValue - 1] = (int)endIndex - 1;

                    for (int x = 0; x < threadsValue - 1; x++)
                    {
                        int startIndex, stopIndex;
                        startIndex = samplesThreadToProcess[x];
                        stopIndex  = samplesThreadToProcess[x + 1];


                        threads.Add(new Thread(() =>
                        {
                            for (int i = startIndex; i < stopIndex + 1; i++)
                            {
                                samplesToProcess[i] = AudioWahWahEffect.AutoWahProcess(samplesToProcess[i], ref timeElapsed);
                                AudioWahWahEffect.AutoWahSweep();
                                fullTime += timeElapsed;
                            }
                        }));
                    }

                    for (int i = 0; i < threadsValue - 1; i++)
                    {
                        threads[i].Start();
                        threads[i].Join();
                        var first = i;
                        var range = threadsValue - 1;
                        var z     = (double)first / range;
                        worker.ReportProgress((int)(z * 100));
                    }
                }
                else
                {
                    for (long i = beginIndex; i < endIndex; ++i)
                    {
                        samplesToProcess[i] = AudioWahWahEffect.AutoWahProcess(samplesToProcess[i], ref timeElapsed);
                        AudioWahWahEffect.AutoWahSweep();
                        if (i % 8000 == 0 && i != 0)
                        {
                            var first = i - beginIndex;
                            var range = endIndex - beginIndex;
                            var x     = (double)first / range;
                            worker.ReportProgress((int)(x * 100));
                            System.Threading.Thread.Sleep(50);
                        }
                        fullTime += timeElapsed;
                    }
                }

                ResetProgressBar();

                audioItem.ProcessedAudioBuffer = samplesToProcess;

                AudioItemManager.SetAudioItem(audioItem);

                var milisecondsTime = (double)fullTime / 1000;

                e.Result = "Selection : " + minutes + ":" + seconds + ":" + miliseconds + " - " + AudioItemManager.Instance.GetEndSpan().Minutes.ToString() + ":" + AudioItemManager.Instance.GetEndSpan().Seconds.ToString() + ":" + AudioItemManager.Instance.GetEndSpan().Milliseconds.ToString()
                           + "  " + " -> Processed Wah-Wah 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!";
            }
        }
Пример #3
0
 public void PorcessSample(object sampleToProcess, ref int timeElapsed)
 {
     AudioWahWahEffect.AutoWahProcess((float)sampleToProcess, ref timeElapsed);
     AudioWahWahEffect.AutoWahSweep();
 }