Esempio n. 1
0
        private int ProcessAudioFile(List <FilterBase> filters, int nChannels, ref AudioDataPerChannel from, ref AudioDataPerChannel to)
        {
            foreach (var f in filters)
            {
                f.FilterStart();
            }

            to.ResetStatistics();
            long pos = 0;

            while (pos < to.totalSamples)
            {
                var pcm = FilterNth(filters, filters.Count - 1, ref from);

                to.SetPcmInDouble(pcm, pos);

                pos += pcm.LongLength;

                long currentSamples = System.Threading.Interlocked.Add(ref mProgressSamples, pcm.LongLength);

                double percent = (double)FILE_READ_COMPLETE_PERCENTAGE
                                 + ((double)FILE_PROCESS_COMPLETE_PERCENTAGE - FILE_READ_COMPLETE_PERCENTAGE) * currentSamples / to.totalSamples / nChannels;
                mBackgroundWorker.ReportProgress((int)percent, new ProgressArgs("", 0));
            }

            foreach (var f in filters)
            {
                f.FilterEnd();
            }
            return(0);
        }
        private int ProcessAudioFile(List<FilterBase> filters, int nChannels, ref AudioDataPerChannel from, ref AudioDataPerChannel to)
        {
            foreach (var f in filters) {
                f.FilterStart();
            }

            to.ResetStatistics();
            long pos = 0;
            while (pos < to.totalSamples) {
                var pcm = FilterNth(filters, filters.Count - 1, ref from);

                to.SetPcmInDouble(pcm, pos);

                pos += pcm.LongLength;

                long currentSamples = System.Threading.Interlocked.Add(ref mProgressSamples, pcm.LongLength);

                double percent = (double)FILE_READ_COMPLETE_PERCENTAGE
                        + ((double)FILE_PROCESS_COMPLETE_PERCENTAGE - FILE_READ_COMPLETE_PERCENTAGE) * currentSamples / to.totalSamples / nChannels;
                mBackgroundWorker.ReportProgress((int)percent, new ProgressArgs("", 0));
            }

            foreach (var f in filters) {
                f.FilterEnd();
            }
            return 0;
        }