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


C# WaveFileReader.ToSampleProvider方法代码示例

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


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

示例1: ConvertAFile

 public void ConvertAFile()
 {
     const string input = @"C:\Users\Mark\Downloads\Region-1.wav";
     if (!File.Exists(input)) Assert.Ignore("Test file not found");
     using (var reader = new WaveFileReader(input))
     {
         var sp = reader.ToSampleProvider();
         var wp24 = new SampleToWaveProvider24(sp);
         WaveFileWriter.CreateWaveFile(@"C:\Users\Mark\Downloads\Region1-24.wav", wp24);
     }
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:11,代码来源:SampleToWaveProvider24Tests.cs

示例2: CreateFromWaveFile

 public static SampleSource CreateFromWaveFile(string fileName)
 {
     using (var reader = new WaveFileReader(fileName))
     {
         var sp = reader.ToSampleProvider();
         var sourceSamples = (int)(reader.Length / (reader.WaveFormat.BitsPerSample / 8));
         var sampleData = new float[sourceSamples];
         int n = sp.Read(sampleData, 0, sourceSamples);
         if (n != sourceSamples)
         {
             throw new InvalidOperationException(String.Format("Couldn't read the whole sample, expected {0} samples, got {1}", n, sourceSamples));
         }
         var ss = new SampleSource(sampleData, sp.WaveFormat);
         return ss;
     }
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:16,代码来源:SampleSource.cs

示例3: CombineAudioSignal

 /// <summary>
 ///     Takes 1 wave file, Takes 1 Mp3 File and Combines the two files and resaves on top of the wav.
 /// </summary>
 /// <returns></returns>
 public string CombineAudioSignal()
 {
     var audioPath = _file.Remove(0, _file.IndexOf("Uploads"));
     var server = HttpContext.Current.Server;
     var directoryInfoBeats =
         new DirectoryInfo(new ResourceProvider().GetPath(RapResource.Beats));
     var sortedFiles = from f in directoryInfoBeats.EnumerateFiles() orderby f.CreationTime select f;
     var beats = sortedFiles.Select(item => item.FullName).ToList();
     using (var recordedAudio = new WaveFileReader(server.MapPath("~/" + audioPath)))
     using (var instrumental = new Mp3FileReader(beats[_beatLocation]))
     {
         var inputs = new List<ISampleProvider>
         {
             recordedAudio.ToSampleProvider(),
             instrumental.ToSampleProvider(),
         };
         var mixer = new MixingSampleProvider(inputs);
         //requires work to avoid overriding the file being used
         WaveFileWriter.CreateWaveFile16(
             new ResourceProvider().GetPath(RapResource.RapBattleAudio) + new Guid() + ".wav", mixer);
     }
     return _file;
 }
开发者ID:asebak,项目名称:rapbattleonline,代码行数:27,代码来源:RapSignalProcessing.cs

示例4: GenerateAudio

        public static string GenerateAudio(ControllerContext context, string captcha)
        {
            var mixed =  Path.GetTempFileName();
            var back = Path.GetTempFileName();
            var main = Path.GetTempFileName();

            //gera audio principal
            List<String> chars = new List<string>();
            foreach (var item in captcha)
            {
                chars.Add(context.HttpContext.Server.MapPath("~/Content/Audios/" + item.ToString() + ".wav"));

            }
            Concatenate(main, chars, 1000);

            chars = new List<string>();
            //gera audio aleatorio para sujeira
            for (int i = 0; i < 4; i++)
            {
                var randtext = Captcha.GenerateRandomCode(i);
                foreach (var item in randtext)
                {
                    chars.Add(context.HttpContext.Server.MapPath("~/Content/Audios/" + item.ToString() + ".wav"));
                }
            }
            Concatenate(mixed, chars, 0, true);
            ReverseWaveFile(mixed, back);

            using (var reader1 = new WaveFileReader(main))
            using (var reader2 = new WaveFileReader(back))
            {

                var volumeProvider = new VolumeSampleProvider(reader2.ToSampleProvider());
                volumeProvider.Volume = 0.15f;

                var inputs = new List<ISampleProvider>() {
                    reader1.ToSampleProvider(),
                    volumeProvider
                };

                var mixer = new MixingSampleProvider(inputs);
                WaveFileWriter.CreateWaveFile16(mixed, mixer);
            }

            var mp3file = Path.GetTempFileName();
            WavToMp3(mixed, mp3file, context);

            return mp3file;
        }
开发者ID:lucasteles,项目名称:CaptchaComAudio,代码行数:49,代码来源:AudioTool.cs

示例5: ReadWaveFile

 private static ISampleProvider ReadWaveFile(WaveFileReader reader, CompositeDisposable disposables)
 {
     disposables.Add(reader);
     // if resampling is needed, do it.
     if (reader.WaveFormat.SampleRate != SampleRate)
     {
         var resampler = new MediaFoundationResampler(reader,
                 WaveFormat.CreateIeeeFloatWaveFormat(SampleRate, ChannelCount));
         disposables.Add(resampler);
         return resampler.ToSampleProvider();
     }
     return reader.ToSampleProvider();
 }
开发者ID:Kei-Nanigashi,项目名称:StarryEyes,代码行数:13,代码来源:AudioPlayer.cs


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