コード例 #1
0
        public ConvertingSampleProvider(IWaveProvider waveProvider, WaveFormat targetFormat)
        {
            if (waveProvider.WaveFormat.SampleRate != targetFormat.SampleRate)
            {
                if (waveProvider.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
                {
                    provider = ((resampler = new MediaFoundationResampler(waveProvider, targetFormat)) as MediaFoundationResampler).ToSampleProvider();
                }
                else
                {
                    provider = ((resampler = new MediaFoundationResampler(new Wave16ToFloatProvider(waveProvider), targetFormat)) as MediaFoundationResampler).ToSampleProvider();
                }
            }
            else
            {
                provider = waveProvider.ToSampleProvider();
            }

            if (provider.WaveFormat.Channels != targetFormat.Channels)
            {
                if (targetFormat.Channels == 1 & provider.WaveFormat.Channels > 1)
                {
                    provider = provider.ToMono();
                }
                else if (targetFormat.Channels == 2)
                {
                    provider = provider.ToStereo();
                }
                else
                {
                    throw new InvalidWaveFormatException($"Couldn´t find a suitable conversion from {provider.WaveFormat.Channels} to {targetFormat.Channels} Channels");
                }
            }
        }
コード例 #2
0
 public SampleProvider(ISampleProvider input)
 {
     if (input.WaveFormat.Channels == 2)
     {
         this.output = input;
     }
     else
     {
         this.output = input.ToStereo();
     }
 }
コード例 #3
0
 public ISampleProvider SupplySample(bool stereo, bool loop, ISampleProvider input)
 {
     if (stereo)
     {
         input.ToStereo();
     }
     else
     {
         input.ToMono();
     }
     return(input);
 }
コード例 #4
0
 public SampleProvider(VoiceStreamStruct voiceStreamStruct, ISampleProvider input)
 {
     this.buffer            = new float[buffSize];
     this.voiceStreamStruct = voiceStreamStruct;
     if (input.WaveFormat.Channels != 2)
     {
         this.input = input.ToStereo();
     }
     else
     {
         this.input = input;
     }
 }
コード例 #5
0
        public AudioSample(string filePath)
        {
            this.audioFileReader = new AudioFileReader(filePath);
            ISampleProvider sampleProvider = this.audioFileReader.ToSampleProvider();

            // Mono to Stereo
            if (sampleProvider.WaveFormat.Channels == 1)
            {
                sampleProvider = sampleProvider.ToStereo();
            }
            // Resample
            if (sampleProvider.WaveFormat.SampleRate != 16000)
            {
                sampleProvider = new WdlResamplingSampleProvider(sampleProvider, 16000);
            }
            this.oriSample = sampleProvider;
            this.Sample    = this.oriSample;
        }
コード例 #6
0
ファイル: ICEFilter.cs プロジェクト: lukyhruska96/VRLife
            public SampleProvider(string folderPath, ISampleProvider input, SourceLocation location)
            {
                this.hrtf = new HRTF(folderPath);
                this.hrtf.Init();
                this.binSyn   = new BinauralSynthesis(currInput, dataOutput);
                this.location = location;

                // convert stereo input to mono
                if (input.WaveFormat.Channels != 1)
                {
                    this.input = input.ToMono();
                }
                else
                {
                    this.input = input;
                }

                WaveFormat = input.ToStereo().WaveFormat;
            }
コード例 #7
0
ファイル: SfxPlayer.cs プロジェクト: MarshmallowAndroid/NAMP
 private ISampleProvider StereoToMono(ISampleProvider input)
 {
     return(input.ToStereo());
 }