DSPUtil.WaveReader.Close C# (CSharp) Method

Close() public method

Close the wave file
public Close ( ) : void
return void
        public void Close()
        {
            if (_rdr != null) { _rdr.Close(); }
            if (bs != null) { bs.Close(); bs = null; }
            if (fs != null) { fs.Close(); fs = null; }
        }

Usage Example

示例#1
0
        static bool ExecDRC(string drcfile, string target, string outfile, string infileL, string infileR, int peakPosL, int peakPosR, string stereoImpulseFile)
        {
            GC.Collect();
            bool ok = false;
            string args;
            FastConvolver conv;
            WaveWriter wri;
            if (!File.Exists(drcfile))
            {
                stderr.WriteLine();
                stderr.WriteLine("{0} not found.", drcfile);
                return ok;
            }

            string tmpL;
            string tmpR;
            tmpL = Path.GetFileNameWithoutExtension(infileL) + ".tmp";
            tmpR = Path.GetFileNameWithoutExtension(infileR) + ".tmp";
            _tempFiles.Add(tmpL);
            _tempFiles.Add(tmpR);

            stderr.WriteLine("Exec DRC for {0}, left channel", drcfile);
            stderr.WriteLine();
            ok = RunDRC(drcfile, infileL, target, tmpL, peakPosL, out args);

            if (ok)
            {
                stderr.WriteLine();
                stderr.WriteLine("Exec DRC for {0}, right channel", drcfile);
                stderr.WriteLine();
                ok = RunDRC(drcfile, infileR, target, tmpR, peakPosR, out args);
            }

            if (ok)
            {
                stderr.WriteLine();
                if (_noSkew)
                {
                    stderr.WriteLine("Creating stereo filter {0}", outfile + ".wav" );
                }
                else
                {
                    stderr.WriteLine("Creating stereo filter {0} (skew {1} samples)", outfile + ".wav", peakPosR - peakPosL);
                }
                ISoundObj stereoFilter = Splice(tmpL, peakPosL, tmpR, peakPosR, outfile + ".wav");
                stderr.WriteLine();

                // Convolve noise with the stereo filter
                /*
                NoiseGenerator noise = new NoiseGenerator(NoiseType.WHITE_FLAT, 2, (int)131072, stereoFilter.SampleRate, 1.0);
                conv = new FastConvolver();
                conv.impulse = stereoFilter;
                conv.Input = noise;

                wri = new WaveWriter(drcfile + "_Test.wav");
                wri.Input = conv;
                wri.Format = WaveFormat.IEEE_FLOAT;
                wri.BitsPerSample = 32;
                wri.SampleRate = _sampleRate;
                wri.Normalization = -1;
                wri.Run();
                wri.Close();
                wri = null;
                conv = null;
                noise = null;
                 * */

                // Convolve filter with the in-room impulse response
                WaveReader rea = new WaveReader(stereoImpulseFile);
                conv = new FastConvolver();
                conv.impulse = rea;
                conv.Input = stereoFilter;

                if (_pcm)
                {
                    _impulseFiles.Add("LCorrected_" + outfile + ".pcm: corrected test convolution, raw data (32-bit float), left channel");
                    _impulseFiles.Add("RCorrected_" + outfile + ".pcm: corrected test convolution, raw data (32-bit float), right channel");
                    WriteImpulsePCM(conv, "LCorrected_" + outfile + ".pcm", "RCorrected_" + outfile + ".pcm");
                }

                wri = new WaveWriter(outfile + "_TestConvolution.wav");
                wri.Input = conv;
                wri.Format = WaveFormat.PCM;
                wri.Dither = DitherType.TRIANGULAR;
                wri.BitsPerSample = 16;
                wri.SampleRate = _sampleRate;
                wri.Normalization = -1;
                wri.Run();
                wri.Close();
                rea.Close();
                wri = null;
                rea = null;
                conv = null;

                GC.Collect();
            }
            return ok;
        }
All Usage Examples Of DSPUtil.WaveReader::Close