当前位置: 首页>>代码示例>>C#>>正文


C# Mp3FileReader.Close方法代码示例

本文整理汇总了C#中NAudio.Wave.Mp3FileReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Mp3FileReader.Close方法的具体用法?C# Mp3FileReader.Close怎么用?C# Mp3FileReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NAudio.Wave.Mp3FileReader的用法示例。


在下文中一共展示了Mp3FileReader.Close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: waveformGenerateWorker_DoWork

        private void waveformGenerateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            WaveformGenerationParams waveformParams = e.Argument as WaveformGenerationParams;
            Mp3FileReader waveformMp3Stream = new Mp3FileReader(waveformParams.Path);
            WaveChannel32 waveformInputStream = new WaveChannel32(waveformMp3Stream);
            waveformInputStream.Sample += waveStream_Sample;

            int frameLength = fftDataSize;
            int frameCount = (int)((double)waveformInputStream.Length / (double)frameLength);
            int waveformLength = frameCount * 2;
            byte[] readBuffer = new byte[frameLength];
            waveformAggregator = new SampleAggregator(frameLength);

            float maxLeftPointLevel = float.MinValue;
            float maxRightPointLevel = float.MinValue;
            int currentPointIndex = 0;
            float[] waveformCompressedPoints = new float[waveformParams.Points];
            List<float> waveformData = new List<float>();
            List<int> waveMaxPointIndexes = new List<int>();

            for (int i = 1; i <= waveformParams.Points; i++)
            {
                waveMaxPointIndexes.Add((int)Math.Round(waveformLength * ((double)i / (double)waveformParams.Points), 0));
            }
            int readCount = 0;
            while (currentPointIndex * 2 < waveformParams.Points && waveformInputStream.Position < (waveformInputStream.Length - 1024))
            {
                waveformInputStream.Read(readBuffer, 0, readBuffer.Length);

                waveformData.Add(waveformAggregator.LeftMaxVolume);
                waveformData.Add(waveformAggregator.RightMaxVolume);

                if (waveformAggregator.LeftMaxVolume > maxLeftPointLevel)
                    maxLeftPointLevel = waveformAggregator.LeftMaxVolume;
                if (waveformAggregator.RightMaxVolume > maxRightPointLevel)
                    maxRightPointLevel = waveformAggregator.RightMaxVolume;

                if (readCount > waveMaxPointIndexes[currentPointIndex])
                {
                    waveformCompressedPoints[(currentPointIndex * 2)] = maxLeftPointLevel;
                    waveformCompressedPoints[(currentPointIndex * 2) + 1] = maxRightPointLevel;
                    maxLeftPointLevel = float.MinValue;
                    maxRightPointLevel = float.MinValue;
                    currentPointIndex++;
                }
                if (readCount % 3000 == 0)
                {
                    float[] clonedData = (float[])waveformCompressedPoints.Clone();
                    App.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        WaveformData = clonedData;
                    }));
                }

                if (waveformGenerateWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                readCount++;
            }

            float[] finalClonedData = (float[])waveformCompressedPoints.Clone();
            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                fullLevelData = waveformData.ToArray();
                WaveformData = finalClonedData;
            }));
            waveformInputStream.Close();
            waveformInputStream.Dispose();
            waveformInputStream = null;
            waveformMp3Stream.Close();
            waveformMp3Stream.Dispose();
            waveformMp3Stream = null;
        }
开发者ID:moezRebai,项目名称:LightMusicPalyer,代码行数:75,代码来源:NAudioEngine.cs

示例2: SendVoice

        private void SendVoice(string file, DiscordClient client, YouTubeVideo video)
        {
            DiscordVoiceClient vc = client.GetVoiceClient();
            try
            {
                int ms = vc.VoiceConfig.FrameLengthMs;
                int channels = vc.VoiceConfig.Channels;
                int sampleRate = 48000;

                int blockSize = 48 * 2 * channels * ms; //sample rate * 2 * channels * milliseconds
                byte[] buffer = new byte[blockSize];
                var outFormat = new WaveFormat(sampleRate, 16, channels);

                vc.SetSpeaking(true);

                if(video.AudioFormat == AudioFormat.Mp3)
                {
                    using (var mp3Reader = new Mp3FileReader(video.Stream()))
                    {
                        using (var resampler = new MediaFoundationResampler(mp3Reader, outFormat) { ResamplerQuality = 60 })
                        {
                            //resampler.ResamplerQuality = 60;
                            int byteCount;
                            while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0)
                            {
                                if (vc.Connected)
                                {
                                    vc.SendVoice(buffer);
                                }
                                else
                                    break;
                            }
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Voice finished enqueuing");
                            Console.ForegroundColor = ConsoleColor.White;
                            resampler.Dispose();
                            mp3Reader.Close();
                        }
                    }
                }
                else if(video.AudioFormat == AudioFormat.Vorbis)
                {
                    using (var vorbis = new NAudio.Vorbis.VorbisWaveReader(video.Stream()))
                    {
                        using (var resampler = new MediaFoundationResampler(vorbis, outFormat) { ResamplerQuality = 60 })
                        {
                            int byteCount;
                            while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0)
                            {
                                if (vc.Connected)
                                {
                                    vc.SendVoice(buffer);
                                }
                                else
                                    break;
                            }
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Voice finished enqueuing");
                            Console.ForegroundColor = ConsoleColor.White;
                            resampler.Dispose();
                            vorbis.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    MainEntry.owner.SendMessage("Exception during voice: `" + ex.Message + "`\n\n```" + ex.StackTrace + "\n```");
                }
                catch { }
            }
        }
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:74,代码来源:Voice.cs

示例3: ProcessAudioMP3

        public static void ProcessAudioMP3(string fileIn, string fileOut, float newTempo = 1, float newPitch = 1, float newRate = 1)
        {
            Mp3FileReader fileReader = new Mp3FileReader(fileIn);
            WaveStream conversionStream = WaveFormatConversionStream.CreatePcmStream(fileReader);

            int numChannels = conversionStream.WaveFormat.Channels;
            int sampleRate = conversionStream.WaveFormat.SampleRate;
            int bitPerSample = conversionStream.WaveFormat.BitsPerSample;
            const int BUFFER_SIZE = 1024 * 16;

            SoundStretcher stretcher = new SoundStretcher(sampleRate, numChannels);
            WaveFileWriter writer = new WaveFileWriter(fileOut, new WaveFormat(sampleRate, 16, numChannels));

            stretcher.Tempo = newTempo;
            stretcher.Pitch = newPitch;
            stretcher.Rate = newRate;

            byte[] buffer = new byte[BUFFER_SIZE];
            short[] buffer2 = null;

            if (bitPerSample != 16 && bitPerSample != 8)
            {
                throw new Exception("Not implemented yet.");
            }

            if (bitPerSample == 8)
            {
                buffer2 = new short[BUFFER_SIZE];
            }

            bool finished = false;

            while (true)
            {
                int bytesRead = 0;
                if (!finished)
                {
                    bytesRead = conversionStream.Read(buffer, 0, BUFFER_SIZE);

                    if (bytesRead == 0)
                    {
                        finished = true;
                        stretcher.Flush();
                    }
                    else
                    {
                        if (bitPerSample == 16)
                        {
                            stretcher.PutSamplesFromBuffer(buffer, 0, bytesRead);
                        }
                        else if (bitPerSample == 8)
                        {
                            for (int i = 0; i < BUFFER_SIZE; i++)
                                buffer2[i] = (short)((buffer[i] - 128) * 256);
                            stretcher.PutSamples(buffer2);
                        }
                    }
                }
                bytesRead = stretcher.ReceiveSamplesToBuffer(buffer, 0, BUFFER_SIZE);
                writer.Write(buffer, 0, bytesRead);

                if (finished && bytesRead == 0)
                    break;
            }

            conversionStream.Close();
            writer.Close();
            fileReader.Close();
        }
开发者ID:michaelbehner96,项目名称:Xyzzxyz,代码行数:69,代码来源:Utilities.cs

示例4: MakeSnaps


//.........这里部分代码省略.........
                        if ((pcm.WaveFormat.SampleRate != 44100) || (pcm.WaveFormat.BitsPerSample != 16))
                            return false;

                        for (int i = 0; i < blockscount; i++)
                        {
                            byte[] buffer = new byte[samplesDesired * 4];
                            short[] left = new short[samplesDesired];
                            short[] right = new short[samplesDesired];
                            double[] leftd = new double[samplesDesired];
                            double[] rightd = new double[samplesDesired];

                            int bytesRead = 0;

                            //for (int j = 0; j < 1; j++) ///////////
                            int seek_counter = 0;
                        seek: pcm.Seek((i + 1) * (i + 1) * (i + 1) * blockscount * samplesDesired % (total_samples - samplesDesired), SeekOrigin.Begin);
                            seek_counter++;

                            bytesRead = pcm.Read(buffer, 0, 4 * samplesDesired);

                            int index = 0;
                            for (int sample = 0; sample < bytesRead / 4; sample++)
                            {
                                left[sample] = BitConverter.ToInt16(buffer, index); index += 2;
                                right[sample] = BitConverter.ToInt16(buffer, index); index += 2;
                            }

                            if (left.Average(t => Math.Abs(t)) == 0)
                                if (seek_counter > 5)
                                    return false;
                                else
                                    goto seek;

                            //snap_log10_energy.Add(Math.Log10(left.Average(t => Math.Abs(t))));

                            leftd = Normalize(left, left.Length);
                            rightd = Normalize(right, right.Length);

                            //alglib.complex[] fl;
                            //alglib.fftr1d(leftd, out fl);
                            //fl[0].x;

                            FourierTransformer ft = new FourierTransformer(samplesDesired);
                            var xxa = new Complex[leftd.Length];

                            for (int j = 0; j < leftd.Length; j++)
                                xxa[j] = new Complex(leftd[j], rightd[j]);

                            var ftt = ft.Transform(xxa);

                            List<double> pow_re_im = new List<double>();
                            //List<double> arg_re_im = new List<double>();

                            ftt.ToList().ForEach(t => pow_re_im.Add(ComplexMath.Abs(t)));
                            //ftt.ToList().ForEach(t => arg_re_im.Add(ComplexMath.Arg(t)));

                            /*if (Double.IsNaN(MC_Log10_Energy(pow_re_im)))
                                if (seek_counter > 5)
                                    return false;
                                else
                                    goto seek;*/

                            fft_snaps.Add(pow_re_im);
                            //fft_smoothed_snaps.Add(Smoothen(pow_re_im, smooth_size));

                            //pow_re_im = Normalize(pow_re_im);

                            /*
                            var f_pwri = pow_re_im.Average(t => Math.Abs(t));
                            for (int k = 0; k < pow_re_im.Count; k++)
                                pow_re_im[k] = (Math.Abs(pow_re_im[k]) >= f_pwri * 1.5) ? pow_re_im[k] : 0;
                            */

                            /*
                            FourierTransformer ft2 = new FourierTransformer(samplesDesired);
                            var xx2 = new List<Complex>();
                            for (int j = 0; j < pow_re_im.Count; j++)
                            {
                                xx2.Add(new Complex(pow_re_im[j], arg_re_im[j]));
                            }
                            var ftt2 = ft2.Transform(xx2);
                            //var ftt2 = ft2.Transform(ftt);

                            List<double> pow_re_im2 = new List<double>();
                            ftt2.ToList().ForEach(t => pow_re_im2.Add(ComplexMath.Abs(t)));
                            pow_re_im2 = Normalize(pow_re_im2);
                            fft2_snaps.Add(pow_re_im2);
                            fft2_smoothed_snaps.Add(Smoothen(pow_re_im2, smooth_size));
                            */
                        }
                        pcm.Close();
                    }
                }
                catch (Exception e)
                {
                return false;
                }

                return true;
            }
开发者ID:develop1,项目名称:holo,代码行数:101,代码来源:Form1.cs

示例5: waveformGenerateWorker_DoWork

        private void waveformGenerateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var waveformParams = (WaveformGenerationParams)e.Argument;

            float[] waveformDataFromCache;
            if (waveformDataCache.TryGet(waveformParams.Path, out waveformDataFromCache))
            {
                Application.Current.Dispatcher.Invoke(() => WaveformData = waveformDataFromCache);
                return;
            }

            Mp3FileReader waveformMp3Stream = new Mp3FileReader(waveformParams.Path);
            WaveChannel32 waveformInputStream = new WaveChannel32(waveformMp3Stream);
            waveformInputStream.Sample += waveStream_Sample;

            int frameLength = fftDataSize;
            int frameCount = (int)((double)waveformInputStream.Length / (double)frameLength);
            int waveformLength = frameCount * 2;
            byte[] readBuffer = new byte[frameLength];
            waveformAggregator = new SampleAggregator(frameLength);

            float maxLeftPointLevel = float.MinValue;
            float maxRightPointLevel = float.MinValue;
            int currentPointIndex = 0;
            float[] waveformCompressedPoints = new float[waveformParams.Points];
            List<float> waveformData = new List<float>();
            List<int> waveMaxPointIndexes = new List<int>();

            for (int i = 1; i <= waveformParams.Points; i++)
            {
                waveMaxPointIndexes.Add((int)Math.Round(waveformLength * ((double)i / (double)waveformParams.Points), 0));
            }
            int readCount = 0;
            while (currentPointIndex * 2 < waveformParams.Points)
            {
                waveformInputStream.Read(readBuffer, 0, readBuffer.Length);

                waveformData.Add(waveformAggregator.LeftMaxVolume);
                waveformData.Add(waveformAggregator.RightMaxVolume);

                if (waveformAggregator.LeftMaxVolume > maxLeftPointLevel)
                    maxLeftPointLevel = waveformAggregator.LeftMaxVolume;
                if (waveformAggregator.RightMaxVolume > maxRightPointLevel)
                    maxRightPointLevel = waveformAggregator.RightMaxVolume;

                if (readCount > waveMaxPointIndexes[currentPointIndex])
                {
                    waveformCompressedPoints[(currentPointIndex * 2)] = maxLeftPointLevel;
                    waveformCompressedPoints[(currentPointIndex * 2) + 1] = maxRightPointLevel;
                    maxLeftPointLevel = float.MinValue;
                    maxRightPointLevel = float.MinValue;
                    currentPointIndex++;
                }
                if (readCount % 3000 == 0)
                {
                    float[] clonedData = (float[])waveformCompressedPoints.Clone();

                    try
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            WaveformData = clonedData;
                        }));
                    }
                    catch (TaskCanceledException)
                    {
                        e.Cancel = true;
                        return;
                    }
                    
                }

                if (waveformGenerateWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                readCount++;
            }

            float[] finalClonedData = (float[])waveformCompressedPoints.Clone();

            // Don't cache half-finished waveforms (my CDJ-1000MK3s do this...)
            if (!waveformGenerateWorker.CancellationPending)
                waveformDataCache.Add(waveformParams.Path, finalClonedData);

            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                fullLevelData = waveformData.ToArray();
                WaveformData = finalClonedData;
            }));
            waveformInputStream.Close();
            waveformInputStream.Dispose();
            waveformInputStream = null;
            waveformMp3Stream.Close();
            waveformMp3Stream.Dispose();
            waveformMp3Stream = null;
        }
开发者ID:rdingwall,项目名称:mixplanner,代码行数:98,代码来源:NAudioEngine.cs

示例6: worker_DoWork

        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Mp3FileReader reader = new Mp3FileReader(FileName);
            WaveChannel32 channel = new WaveChannel32(reader);
            channel.Sample += new EventHandler<SampleEventArgs>(channel_Sample);

            int points = 2000;

            int frameLength = (int)FFTDataSize.FFT2048;
            int frameCount = (int)((double)channel.Length / (double)frameLength);
            int waveformLength = frameCount * 2;
            byte[] readBuffer = new byte[frameLength];

            float maxLeftPointLevel = float.MinValue;
            float maxRightPointLevel = float.MinValue;
            int currentPointIndex = 0;
            float[] waveformCompressedPoints = new float[points];
            List<float> waveformData = new List<float>();
            List<int> waveMaxPointIndexes = new List<int>();

            for (int i = 1; i <= points; i++)
            {
                waveMaxPointIndexes.Add((int)Math.Round(waveformLength * ((double)i / (double)points), 0));
            }
            int readCount = 0;
            while (currentPointIndex * 2 < points)
            {
                channel.Read(readBuffer, 0, readBuffer.Length);

                waveformData.Add(InputSampler.LeftMax);
                waveformData.Add(InputSampler.RightMax);

                if (InputSampler.LeftMax > maxLeftPointLevel)
                    maxLeftPointLevel = InputSampler.LeftMax;
                if (InputSampler.RightMax > maxRightPointLevel)
                    maxRightPointLevel = InputSampler.RightMax;

                if (readCount > waveMaxPointIndexes[currentPointIndex])
                {
                    waveformCompressedPoints[(currentPointIndex * 2)] = maxLeftPointLevel;
                    waveformCompressedPoints[(currentPointIndex * 2) + 1] = maxRightPointLevel;
                    maxLeftPointLevel = float.MinValue;
                    maxRightPointLevel = float.MinValue;
                    currentPointIndex++;
                }
                if (readCount % 3000 == 0)
                {
                    WaveformData = (float[])waveformCompressedPoints.Clone();
                }

                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                readCount++;
            }

            FullLevelData = waveformData.ToArray();
            WaveformData = (float[])waveformCompressedPoints.Clone();

            // Cleanup
            channel.Close();
            channel.Dispose();
            channel = null;
            reader.Close();
            reader.Dispose();
            reader = null;
        }
开发者ID:pbeardshear,项目名称:TempoMonkey,代码行数:69,代码来源:WaveformTimeline.cs

示例7: processStr

        private void processStr(String str)
        {
            files.Clear();
            string[] ContentLines = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            int len = ContentLines.Length;
            int index = 0;
            for (int i = 0; i < len; i++)
            {
                string currentLine = ContentLines[i];
                string[] delim = { "." };
                // delimeter
                if (textBox1.Text == string.Empty)
                {
                    if (zhRadioButton.Checked)
                        delim = new string[] { "。" };
                    else if (enRadioButton.Checked)
                        delim = new string[] { ",", "." };
                    else if (jpRadioButton.Checked)
                        delim = new string[] { "。" };
                }
                else
                {
                    delim = textBox1.Text.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
                }

                //
                string[] senSet = currentLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
                int inLen = senSet.Length;
                for (int j = 0; j < inLen; j++)
                {
                    index++;
                    string destStr = senSet[j];
                    statusLabel.ForeColor = Color.Red;
                    statusLabel.Text = "处理中:"+destStr;
                    // length limit
                    if (destStr.Length > 100)
                    {
                        //Console.WriteLine(destStr);
                        MessageBox.Show("这句话太长了,谷歌娘根本来不及给你读嘛!");
                        continue;
                    }

                    //multi-thread switch
                    if (mThreadCheckBox.Checked)
                    {
                        para par = new para();
                        par.str = senSet[j];
                        par.index = index;
                        Thread newThread = new Thread(new ParameterizedThreadStart(getTTSMT));
                        newThread.Start(par);
                        newThread.Join();
                    }
                    else
                    {
                        getTTS(senSet[j], index);
                        statusLabel.ForeColor = Color.Red;
                        statusLabel.Text = "处理中:" + senSet[j];
                    }
                }
            }
            // status
            statusLabel.Text = "正在进行收尾工作...";
            //// merge all files
            string strFilePattern = prefix + "*.mp3";
            string[] strFiles = Directory.GetFiles(mp3dir, strFilePattern);
            //NAudio
            FileStream fileStream = new FileStream(prefix+".mp3", FileMode.OpenOrCreate);
            foreach (string file in strFiles)
            {
                Mp3FileReader reader = new Mp3FileReader(file);
                if ((fileStream.Position == 0) && (reader.Id3v2Tag != null))
                {
                    fileStream.Write(reader.Id3v2Tag.RawData, 0, reader.Id3v2Tag.RawData.Length);
                }
                Mp3Frame frame;
                while ((frame = reader.ReadNextFrame()) != null)
                {
                    fileStream.Write(frame.RawData, 0, frame.RawData.Length);
                }
                reader.Close();
            }
            fileStream.Close();
            ////
            statusLabel.ForeColor = Color.Black;
            statusLabel.Text = "所有句子全部完成!";

            //
            if (playCheckBox.Checked)
            {
                playMp3(prefix+".mp3");
            }

            if (!saveCheckBox.Checked)
            {
                try
                {
                    File.Delete(prefix + ".mp3");
                }
                catch
                {
//.........这里部分代码省略.........
开发者ID:tjuzhao111,项目名称:GoogleTTS,代码行数:101,代码来源:Form1.cs

示例8: DoTextToSpeech


//.........这里部分代码省略.........
                    }
                    Log4.DeveloperLog.InfoFormat("*** Try get sound again. Bytes: {0} tempid: {1}", audioData.Length, tempId);
                    audioData = null;
                }

                if (audioData == null)
                {
                    Log4.DeveloperLog.Info("Job canceled");
                    break;
                }

                if (writedParts == 0)
                {
                    document.FileIndex++;
                    SaveDocument(document);

                    string bookName = document.Title;
                    string author = document.Author;
                    string group = document.Group;
                    string year = document.Year.ToString();
                    string comments = document.Comments;
                    string genre = document.Genre;

                    string fName = String.Format(@"{1:0000}-{0}", bookName, document.FileIndex);
                    string fDir = String.Format(@"{0}\{1}", document.AudioDirectory, bookName);

                    if (!Directory.Exists(fDir))
                    {
                        Directory.CreateDirectory(fDir);
                    }

                    currentFileName = String.Format(@"{0}\{1}.mp3", fDir, fName);
                    Log4.DeveloperLog.InfoFormat("Current file name: {0}", currentFileName);

                    ///////////////////////////////////////////////////////////
                    // http://www.id3.org/id3v2.3.0
                    ///////////////////////////////////////////////////////////
                    Dictionary<string, string> tags = new Dictionary<string, string>
                        {
                            { "TCON", String.Format("{0}", genre) }, /* Genre */
                            { "TALB", String.Format("{0}", bookName) }, /* Album name */
                            { "TRCK", String.Format("{0}", document.FileIndex) }, /* Track No */
                            { "TIT2", String.Format("{0}", fName) }, /* Name */
                            { "TPE1", String.Format("{0}", author) }, /* Artist */
                            { "TPE2", String.Format("{0}", group) }, /* Group name */
                            { "TYER", String.Format("{0}", year) }, /* year of the song */
                            { "COMM", String.Format("{0}", comments) }
                        };
                    id3v2tag = Id3v2Tag.Create(tags);
                    //id3v2tag = Id3v2xTag.Create();
                }

                fsFullOut = new FileStream(currentFileName, FileMode.OpenOrCreate);
                bwFull = new BinaryWriter(fsFullOut);

                using (MemoryStream ms = new MemoryStream(audioData))
                {
                    using (Mp3FileReader mp3Reader = new Mp3FileReader(ms))
                    {
                        bwFull.Seek(0, SeekOrigin.End);

                        Mp3Frame frame;
                        mp3Reader.CurrentTime = TimeSpan.FromSeconds(1.8);
                        while ((frame = mp3Reader.ReadNextFrame()) != null)
                        {
                            if ((mp3Reader.TotalTime.TotalSeconds - mp3Reader.CurrentTime.TotalSeconds) <= 4)
                            {
                                break;
                            }

                            if (id3v2tag != null)
                            {
                                bwFull.Write(id3v2tag.RawData, 0, id3v2tag.RawData.Length);
                                bwFull.Flush();
                                id3v2tag = null;

                                //Mp3Stream mp3Strm = new Mp3Stream(fsFullOut, Mp3Permissions.ReadWrite);
                            }

                            bwFull.Write(frame.RawData, 0, frame.RawData.Length);
                            bwFull.Flush();
                        }
                        mp3Reader.Close();
                    }
                    ms.Close();
                }

                bwFull.Close();
                fsFullOut.Close();

                parts[i].Processed = true;
                Repository.UpdatePart(parts[i]);
                writedParts = (writedParts == 15) ? 0 : writedParts + 1;

                Log4.DeveloperLog.InfoFormat("Writed Parts: {0}", writedParts);
            }

            progressCallback.End();
            ((MainForm)MainForm).RefreshView();
        }
开发者ID:CBSAdvisor,项目名称:cbs-quantum,代码行数:101,代码来源:VfApplication.cs


注:本文中的NAudio.Wave.Mp3FileReader.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。