Example #1
0
 public override string ToSaveText()
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5} {6}",
                          SineJitterFreq, SineJitterNanosec, TpdfJitterNanosec, RpdfJitterNanosec,
                          ConvolutionLengthMinus1, TimingErrorFileNanosec, WWAFUtil.EscapeString(TimingErrorFile)));
 }
Example #2
0
 public override string ToSaveText()
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0}", WWAFUtil.EscapeString(FilterFilePath)));
 }
Example #3
0
 public override string ToSaveText()
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0} {1}", TagType, WWAFUtil.EscapeString(Text)));
 }
        public int Run(string fromPath, List <FilterBase> aFilters,
                       string toPath, WWAFUtil.AFSampleFormat outputSampleFormat,
                       bool dither, ProgressReportCallback Callback)
        {
            AudioData audioDataFrom;
            AudioData audioDataTo;
            int       rv = AudioDataIO.Read(fromPath, out audioDataFrom);

            if (rv < 0)
            {
                return(rv);
            }

            mBarrierReady      = new Barrier(audioDataFrom.meta.channels);
            mBarrierSet        = new Barrier(audioDataFrom.meta.channels);
            mBarrierClearInPcm = new Barrier(audioDataFrom.meta.channels);
            mInPcmArray        = new WWUtil.LargeArray <double> [audioDataFrom.meta.channels];

            Callback(FILE_READ_COMPLETE_PERCENTAGE, new ProgressArgs(Properties.Resources.LogFileReadCompleted, 0));

            var fileFormat = WWAFUtil.FileNameToFileFormatType(toPath);

            rv = SetupResultPcm(audioDataFrom, aFilters, out audioDataTo, fileFormat, outputSampleFormat);
            if (rv < 0)
            {
                return(rv);
            }

            {
                // タグの編集
                var tagData = new TagData();
                tagData.Meta    = new WWFlacRWCS.Metadata(audioDataTo.meta);
                tagData.Picture = audioDataTo.picture;

                foreach (var f in aFilters)
                {
                    tagData = f.TagEdit(tagData);
                }

                audioDataTo.meta    = tagData.Meta;
                audioDataTo.picture = tagData.Picture;
            }

            //for (int ch=0; ch<audioDataFrom.meta.channels; ++ch) {
            Parallel.For(0, audioDataFrom.meta.channels, ch => {
                var filters = new List <FilterBase>();
                foreach (var f in aFilters)
                {
                    filters.Add(f.CreateCopy());
                }

                if (dither)
                {
                    // 最後にディザを加算。
                    FilterBase fb = FinalDither(outputSampleFormat);
                    if (fb != null)
                    {
                        filters.Add(fb);
                    }
                }

                var pRv = FilterSetup(audioDataFrom, ch, filters);
                if (null == pRv)
                {
                    rv = -1;
                    //break;
                    return;
                }

                var from = audioDataFrom.pcm[ch];
                var to   = audioDataTo.pcm[ch];
                rv       = ProcessAudioFile(filters, audioDataFrom.meta.channels, ch, ref from, ref to, Callback);
                if (rv < 0)
                {
                    //break;
                    return;
                }
                audioDataTo.pcm[ch] = to;

                if (audioDataTo.pcm[ch].mOverflow)
                {
                    var s = string.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorSampleValueClipped,
                                          ch, audioDataTo.pcm[ch].mMaxMagnitude);
                    Callback(-1, new ProgressArgs(s, 0));
                }

                filters = null;
            });

            if (rv < 0)
            {
                return(rv);
            }

            Callback(FILE_PROCESS_COMPLETE_PERCENTAGE, new ProgressArgs(string.Format(CultureInfo.CurrentCulture, Properties.Resources.LogfileWriteStarted, toPath), 0));

            switch (audioDataTo.preferredSaveFormat)
            {
            case WWAFUtil.FileFormatType.FLAC:
                rv = AudioDataIO.WriteFlacFile(ref audioDataTo, toPath);
                break;

            case WWAFUtil.FileFormatType.WAVE:
                rv = AudioDataIO.WriteWavFile(ref audioDataTo, toPath);
                break;

            case WWAFUtil.FileFormatType.DSF:
                try {
                    rv = AudioDataIO.WriteDsfFile(ref audioDataTo, toPath);
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                }
                break;
            }

            return(rv);
        }