本文整理汇总了C#中IWaveSource.ChangeSampleRate方法的典型用法代码示例。如果您正苦于以下问题:C# IWaveSource.ChangeSampleRate方法的具体用法?C# IWaveSource.ChangeSampleRate怎么用?C# IWaveSource.ChangeSampleRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWaveSource
的用法示例。
在下文中一共展示了IWaveSource.ChangeSampleRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenTrack
public async Task<bool> OpenTrack(IPlaySource track, bool openCrossfading, long position)
{
IsLoading = true;
if (!openCrossfading)
StopPlayback();
if (_crossfadeService.IsFading)
_crossfadeService.Cancel();
if (_soundSource != null && !openCrossfading)
_soundSource.Dispose();
if (openCrossfading && _soundSource != null)
{
_soundOut.Stopped -= SoundOut_Stopped;
_loopStream.StreamFinished -= LoopStream_StreamFinished;
_simpleNotificationSource.BlockRead -= SimpleNotificationSource_BlockRead;
_crossfadeService.CrossfadeOut(_soundOut, CrossfadeDuration).Forget();
_soundOut = null;
}
var tempSource = await GetSoundSource(track, position);
if (tempSource == null)
return false;
_soundSource = tempSource;
if (_soundSource.WaveFormat.SampleRate < 44100) //Correct sample rate
_soundSource = _soundSource.ChangeSampleRate(44100);
_soundSource = _soundSource
.AppendSource(x => new LoopStream(x), out _loopStream)
.AppendSource(x => Equalizer.Create10BandEqualizer(x.ToSampleSource()), out _equalizer)
.AppendSource(x => new SimpleNotificationSource(x) {Interval = 100}, out _simpleNotificationSource)
.ToWaveSource();
_loopStream.EnableLoop = IsLooping;
_loopStream.StreamFinished += LoopStream_StreamFinished;
_simpleNotificationSource.BlockRead += SimpleNotificationSource_BlockRead;
for (var i = 0; i < EqualizerBands.Count; i++)
SetEqualizerBandValue(EqualizerBands.Bands[i].Value, i);
if (_soundOut == null)
{
_soundOut = _soundOutProvider.GetSoundOut();
_soundOut.Stopped += SoundOut_Stopped;
}
_soundOut.Initialize(_soundSource);
_soundOut.Volume = Volume;
IsLoading = false;
OnTrackLengthChanged();
_playTimeStopwatch.Reset();
if (openCrossfading)
{
await TogglePlayPause();
_fadingService.FadeIn(_soundOut, Volume).Forget();
}
CurrentStateChanged();
OnPositionChanged();
return true;
}