• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Wave.AudioFileReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AudioFileReader类属于NAudio.Wave命名空间,在下文中一共展示了AudioFileReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CanDownsampleAnMp3File

 public void CanDownsampleAnMp3File()
 {
     string testFile = @"D:\Audio\Music\Coldplay\Mylo Xyloto\03 - Paradise.mp3";
     if (!File.Exists(testFile)) Assert.Ignore(testFile);
     string outFile = @"d:\test22.wav";
     using (var reader = new AudioFileReader(testFile))
     {
         // downsample to 22kHz
         var resampler = new WdlResamplingSampleProvider(reader, 22050);
         var wp = new SampleToWaveProvider(resampler);
         using (var writer = new WaveFileWriter(outFile, wp.WaveFormat))
         {
             byte[] b = new byte[wp.WaveFormat.AverageBytesPerSecond];
             while (true)
             {
                 int read = wp.Read(b, 0, b.Length);
                 if (read > 0)
                     writer.Write(b, 0, read);
                 else
                     break;
             }
         }
         //WaveFileWriter.CreateWaveFile(outFile, );
     }
 }
开发者ID:LibertyLocked,项目名称:NAudio,代码行数:25,代码来源:WdlResamplingSampleProviderTests.cs


示例2: Main

        static void Main(string[] args)
        {
            string mp3FilesDir = Directory.GetCurrentDirectory();

            if (args.Length > 0)
            {
                mp3FilesDir = args.First();
            }

            var waveOutDevice = new WaveOut();

            var idToFile = Directory.GetFiles(mp3FilesDir, "*.mp3", SearchOption.AllDirectories).ToDictionary(k => int.Parse(Regex.Match(Path.GetFileName(k), @"^\d+").Value));
            while (true)
            {
                Console.WriteLine("Wprowadz numer nagrania");
                var trackId = int.Parse(Console.ReadLine());

                using (var audioFileReader = new AudioFileReader(idToFile[trackId]))
                {
                    waveOutDevice.Init(audioFileReader);
                    waveOutDevice.Play();

                    Console.ReadLine();
                }
            }
            
        }
开发者ID:onliner10,项目名称:FiszkiPlayer,代码行数:27,代码来源:Program.cs


示例3: BuildWavePartAudio

 private ISampleProvider BuildWavePartAudio(UWavePart part, UProject project)
 {
     AudioFileReader stream;
     try { stream = new AudioFileReader(part.FilePath); }
     catch { return null; }
     return new WaveToSampleProvider(stream);
 }
开发者ID:KineticIsEpic,项目名称:OpenUtau,代码行数:7,代码来源:PlaybackManager.cs


示例4: CachedSound

 public CachedSound(string audioFileName)
 {
     using (var audioFileReader = new AudioFileReader(audioFileName))
     {
         WaveFormat = audioFileReader.WaveFormat;
         if (WaveFormat.SampleRate != 44100 || WaveFormat.Channels != 2)
         {
             using (var resampled = new ResamplerDmoStream(audioFileReader, WaveFormat.CreateIeeeFloatWaveFormat(44100, 2)))
             {
                 var resampledSampleProvider = resampled.ToSampleProvider();
                 WaveFormat = resampledSampleProvider.WaveFormat;
                 var wholeFile = new List<float>((int) (resampled.Length));
                 var readBuffer = new float[resampled.WaveFormat.SampleRate * resampled.WaveFormat.Channels];
                 int samplesRead;
                 while ((samplesRead = resampledSampleProvider.Read(readBuffer, 0, readBuffer.Length)) > 0)
                 {
                     wholeFile.AddRange(readBuffer.Take(samplesRead));
                 }
                 AudioData = wholeFile.ToArray();
             }
         }
         else
         {
             var wholeFile = new List<float>((int) (audioFileReader.Length / 4));
             var readBuffer = new float[audioFileReader.WaveFormat.SampleRate * audioFileReader.WaveFormat.Channels];
             int samplesRead;
             while ((samplesRead = audioFileReader.Read(readBuffer, 0, readBuffer.Length)) > 0)
             {
                 wholeFile.AddRange(readBuffer.Take(samplesRead));
             }
             AudioData = wholeFile.ToArray();
         }
     }
 }
开发者ID:Yaguar666,项目名称:ffxivapp-common,代码行数:34,代码来源:CachedSound.cs


示例5: ExtractWaveProvider

		long _length;		// Number of bytes left to read

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="start">in seconds</param>
		/// <param name="length">in seconds</param>
		public ExtractWaveProvider(AudioFileReader reader, float start, float length) {
			_reader = reader;
			// Position to start
			_reader.Position = _reader.WaveFormat.SecondsToBytes(start);
			// Number of bytes to read
			_length = _reader.WaveFormat.SecondsToBytes(length);
		}
开发者ID:nikkilocke,项目名称:AlbumRecorder,代码行数:14,代码来源:ExtractWaveProvider.cs


示例6: play_Click

        private void play_Click(object sender, EventArgs e)
        {
            if (playlist.SelectedItems.Count>0)
            {
                id = fn.IndexOf(playlist.SelectedItem.ToString());
                if (waveOutDevice.PlaybackState.ToString() != "Paused")
                {
                    t.Stop();
                    stp();
                    audioFileReader = new AudioFileReader(fp[id]);
                    waveOutDevice = new WaveOut();
                    waveOutDevice.Init(audioFileReader);
                    trackbar.Maximum = (int)audioFileReader.TotalTime.TotalSeconds + 1;
                    //deb.Items.Add(audioFileReader.TotalTime.Seconds.ToString());
                    audioFileReader.Volume = (float)vol.Value / 100;
                    waveOutDevice.Play();
                    t.Start();

                }
                else
                {
                    waveOutDevice.Play();
                    t.Start();
                }
            }
            
           
            
        }
开发者ID:npuMa94,项目名称:npuMathecreator,代码行数:29,代码来源:Form1.cs


示例7: Start

        private async Task Start(string audioFile)
        {
            await Task.Run(() =>
            {
                try
                {
                    lock (syncLock)
                    {
                        using (var audioFileReader = new AudioFileReader(audioFile))
                        {
                            audioFileReader.Volume = settingsService.Settings.Volume * 0.01f;

                            using (dso = new DirectSoundOut(settingsService.Settings.AudioDeviceId))
                            {
                                dso.Init(audioFileReader);

                                using (eventWaiter = new ManualResetEvent(false))
                                {
                                    dso.Play();
                                    dso.PlaybackStopped += (sender, args) => eventWaiter.Set();
                                    eventWaiter.WaitOne();
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {

                }
            });
        }
开发者ID:pjmagee,项目名称:swtor-caster,代码行数:32,代码来源:AudioService.cs


示例8: Main

		public static void Main(string[] argv)
		{
			ISampleProvider decoder = new AudioFileReader(FILE);
			SpectrumProvider spectrumProvider = new SpectrumProvider(decoder, 1024, HOP_SIZE, true);
			float[] spectrum = spectrumProvider.nextSpectrum();
			float[] lastSpectrum = new float[spectrum.Length];
			List<float> spectralFlux = new List<float>();

			do
			{
				float flux = 0;
				for(int i = 0; i < spectrum.Length; i++)
				{
					float @value = (spectrum[i] - lastSpectrum[i]);
					flux += @value < 0 ? 0 : @value;
				}
				spectralFlux.Add(flux);

				System.Array.Copy(spectrum, 0, lastSpectrum, 0, spectrum.Length);
			} while((spectrum = spectrumProvider.nextSpectrum()) != null);

			Plot plot = new Plot("Hopping Spectral Flux", 1024, 512);
			plot.plot(spectralFlux, 1, Color.Red);
			new PlaybackVisualizer(plot, HOP_SIZE, FILE);
		}
开发者ID:LuckyLuik,项目名称:AudioVSTToolbox,代码行数:25,代码来源:HoppingSpectralFlux.cs


示例9: ConvertToMP3

        public static void ConvertToMP3(string inFile, string outFile, int bitRate = 64)
        {

            using (var reader = new AudioFileReader(inFile))
            {
                using (var writer = new LameMP3FileWriter(outFile, reader.WaveFormat, bitRate))
                    reader.CopyTo(writer);
            }
        }
开发者ID:rayanc,项目名称:Pecuniaus,代码行数:9,代码来源:AudioHelper.cs


示例10: playnhac

 private void playnhac()
 {
     IWavePlayer waveOutDevice;
     AudioFileReader audioFileReader;
     waveOutDevice = new WaveOut();
     audioFileReader = new AudioFileReader("animal.mp3");
     waveOutDevice.Init(audioFileReader);
     waveOutDevice.Play();
 }
开发者ID:tranquangchau,项目名称:cshap-2008-2013,代码行数:9,代码来源:Form1.cs


示例11: PlaySong

 public void PlaySong()
 {
     // Instantiate audio player
     waveOutDevice = new WaveOut();
     // Set MP3 to play
     audioFileReader = new AudioFileReader(GetSong());
     // Init device and call play
     waveOutDevice.Init(audioFileReader);
     waveOutDevice.Play();
 }
开发者ID:Brendo311,项目名称:AlarmClockWakeTheFuckUp,代码行数:10,代码来源:SoundAlarm.cs


示例12: OnsetDetection

        // Constructor
        public OnsetDetection(AudioFileReader pcm, int sampleWindow)
        {
            PCM = pcm;
            SampleSize = sampleWindow;

            spectrum = new float[sampleWindow / 2 + 1];
            previousSpectrum = new float[spectrum.Length];
            rectify = true;
            fluxes = new List<float>();
        }
开发者ID:CodeFunta,项目名称:HudlFfmpeg,代码行数:11,代码来源:OnsetDetection.cs


示例13: PlaySound

        public static void PlaySound(NotificationSound sound)
        {
            IWavePlayer waveOutDevice;
            AudioFileReader audioFileReader;
            waveOutDevice = new WaveOut();

            audioFileReader = new AudioFileReader("resources/sounds/message.mp3");
            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();
        }
开发者ID:kioltk,项目名称:VKDesktop,代码行数:10,代码来源:Notificator.cs


示例14: buttonSelectFile_Click

 private void buttonSelectFile_Click(object sender, EventArgs e)
 {
     Cleanup();
     var ofd = new OpenFileDialog();
     ofd.Filter = "Audio files|*.wav;*.mp3";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         this.reader = new AudioFileReader(ofd.FileName);
     }
 }
开发者ID:LibertyLocked,项目名称:NAudio,代码行数:10,代码来源:AsioDirectPanel.cs


示例15: LoadMp3File

        public void LoadMp3File(string fileName)
        {
            if (aReader != null)
                aReader.Dispose();

            aReader = new AudioFileReader(fileName);
            var sampleChannel = new SampleChannel(aReader, true);
            volumeMeter = new MeteringSampleProvider(sampleChannel);

            player.Init(volumeMeter);
        }
开发者ID:dotinfinity,项目名称:srw,代码行数:11,代码来源:RadioStationMain.cs


示例16: BeginFadeIn

        /// <summary>
        /// Begins the fade information.
        /// </summary>
        /// <param name="inputFile">The input file.</param>
        /// <param name="outputFile">The output file.</param>
        /// <param name="duration">The duration.</param>
        /// <returns>
        /// Path of changed file
        /// </returns>
        public static string BeginFadeIn(string inputFile, string outputFile, double duration)
        {
            using (var reader = new AudioFileReader(inputFile))
            {
                var provider = new EffectsProvider(reader);
                provider.BeginFadeIn(duration * 1000);
                WaveFileWriter.CreateWaveFile16(outputFile, provider);
            }

            return outputFile;
        }
开发者ID:ptorchilov,项目名称:mp3-editor,代码行数:20,代码来源:EffectsUtility.cs.cs


示例17: BeginPlayback

 private void BeginPlayback(string filename)
 {
     Debug.Assert(this.wavePlayer == null);
     this.wavePlayer = CreateWavePlayer();
     this.file = new AudioFileReader(filename);
     this.file.Volume = volumeSlider1.Volume;
     this.wavePlayer.Init(file);
     this.wavePlayer.PlaybackStopped += wavePlayer_PlaybackStopped;
     this.wavePlayer.Play();
     EnableButtons(true);
     timer1.Enabled = true; // timer for updating current time label
 }
开发者ID:LibertyLocked,项目名称:NAudio,代码行数:12,代码来源:SimplePlaybackPanel.cs


示例18: Play

        public void Play()
        {
            var path = Path.Combine(@"E:\Dropbox\Music\Imagine Dragons\Night Visions", "01 - Radioactive.mp3");
            var wavePlayer = new WaveOut();
            var file = new AudioFileReader(path);
            file.Volume = 0.8f;
            wavePlayer.Init(file);
            ////wavePlayer.PlaybackStopped += wavePlayer_PlaybackStopped;
            wavePlayer.Play();

            Thread.Sleep(10000);
        }
开发者ID:charlesj,项目名称:Grease,代码行数:12,代码来源:Sandbox.cs


示例19: Stage

        public override void Stage()
        {
            wavePlayer = new WaveOutEvent();

            file = new AudioFileReader(_fileName);
            file.Volume = 1;

            wavePlayer.Init(file);
            wavePlayer.PlaybackStopped += new EventHandler<StoppedEventArgs>(PlaybackEnded);

            _currentStatus = Status.Staged;
        }
开发者ID:carsonk,项目名称:MistyMixer,代码行数:12,代码来源:SoundCue.cs


示例20: CreateInputStream

        private ISampleProvider CreateInputStream(string fileName)
        {
            this.audioFileReader = new AudioFileReader(fileName);

            var sampleChannel = new SampleChannel(audioFileReader, true);
            sampleChannel.PreVolumeMeter+= OnPreVolumeMeter;
            this.setVolumeDelegate = (vol) => sampleChannel.Volume = vol;
            var postVolumeMeter = new MeteringSampleProvider(sampleChannel);
            postVolumeMeter.StreamVolume += OnPostVolumeMeter;

            return postVolumeMeter;
        }
开发者ID:KarimLUCCIN,项目名称:NAudioCustom,代码行数:12,代码来源:AudioPlaybackPanel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Wave.BufferedWaveProvider类代码示例发布时间:2022-05-26
下一篇:
C# VisualBasic.VBParser类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap