本文整理汇总了C#中IWaveSource类的典型用法代码示例。如果您正苦于以下问题:C# IWaveSource类的具体用法?C# IWaveSource怎么用?C# IWaveSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWaveSource类属于命名空间,在下文中一共展示了IWaveSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DmoChannelResampler
/// <summary>
/// Initializes a new instance of the <see cref="DmoChannelResampler"/> class.
/// </summary>
/// <param name="source">Underlying source which has to get resampled.</param>
/// <param name="channelMatrix"><see cref="ChannelMatrix" /> which defines how to map each channel.</param>
/// <param name="outputFormat">Waveformat, which specifies the new format. Note, that by far not all formats are supported.</param>
/// <exception cref="System.ArgumentNullException">
/// source
/// or
/// channelMatrix
/// or
/// outputFormat
/// </exception>
/// <exception cref="System.ArgumentException">The number of channels of the source has to be equal to the number of input channels specified by the channelMatrix.</exception>
public DmoChannelResampler(IWaveSource source, ChannelMatrix channelMatrix, WaveFormat outputFormat)
: base(source, outputFormat)
{
if (source == null)
throw new ArgumentNullException("source");
if (channelMatrix == null)
throw new ArgumentNullException("channelMatrix");
if(outputFormat == null)
throw new ArgumentNullException("outputFormat");
if (source.WaveFormat.Channels != channelMatrix.InputChannelCount)
{
throw new ArgumentException(
"The number of channels of the source has to be equal to the number of input channels specified by the channelMatrix.");
}
var inputFormat = new WaveFormatExtensible(
source.WaveFormat.SampleRate,
source.WaveFormat.BitsPerSample,
source.WaveFormat.Channels,
WaveFormatExtensible.SubTypeFromWaveFormat(source.WaveFormat),
channelMatrix.InputMask);
Outputformat = new WaveFormatExtensible(
outputFormat.SampleRate,
outputFormat.BitsPerSample,
outputFormat.Channels,
WaveFormatExtensible.SubTypeFromWaveFormat(outputFormat),
channelMatrix.OutputMask);
Initialize(inputFormat, Outputformat);
_channelMatrix = channelMatrix;
CommitChannelMatrixChanges();
}
开发者ID:opcon,项目名称:cscore,代码行数:48,代码来源:DmoChannelResampler.cs
示例2: CreateConverter
public static ISampleSource CreateConverter(IWaveSource source)
{
if (source == null)
throw new ArgumentNullException("source");
int bps = source.WaveFormat.BitsPerSample;
if (source.WaveFormat.IsPCM())
{
switch (bps)
{
case 8:
return new Pcm8BitToSample(source);
case 16:
return new Pcm16BitToSample(source);
case 24:
return new Pcm24BitToSample(source);
default:
throw new NotSupportedException("Waveformat is not supported. Invalid BitsPerSample value.");
}
}
else if (source.WaveFormat.IsIeeeFloat() && bps == 32)
{
return new IeeeFloatToSample(source);
}
else
{
throw new NotSupportedException("Waveformat is not supported. Invalid WaveformatTag.");
}
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:32,代码来源:WaveToSampleBase.cs
示例3: DmoAggregator
/// <summary>
/// Creates a new instance of the <see cref="DmoAggregator"/> class.
/// </summary>
/// <param name="source">Base source of the <see cref="DmoAggregator"/>.</param>
public DmoAggregator(IWaveSource source)
{
if (source == null)
throw new ArgumentNullException("source");
_source = source;
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:11,代码来源:DmoAggregator.cs
示例4: FFTDataProvider
public FFTDataProvider(IWaveSource source)
{
if (source == null)
throw new ArgumentNullException("source");
CreateFFTAggregator(source);
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:7,代码来源:FFTDataProvider.cs
示例5: PlayWithoutStreaming
private static void PlayWithoutStreaming(IWaveSource waveSource)
{
using (var xaudio2 = XAudio2.CreateXAudio2())
using (var masteringVoice = xaudio2.CreateMasteringVoice()) //ALWAYS create at least one masteringVoice.
using (var sourceVoice = xaudio2.CreateSourceVoice(waveSource.WaveFormat))
{
var buffer = waveSource.ToByteArray();
using (var sourceBuffer = new XAudio2Buffer(buffer.Length))
{
using (var stream = sourceBuffer.GetStream())
{
stream.Write(buffer, 0, buffer.Length);
}
sourceVoice.SubmitSourceBuffer(sourceBuffer);
}
sourceVoice.Start();
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
sourceVoice.Stop();
}
}
开发者ID:opcon,项目名称:cscore,代码行数:25,代码来源:Program.cs
示例6: WaveAggregatorBase
/// <summary>
/// Creates a new instance of <see cref="WaveAggregatorBase"/> class.
/// </summary>
/// <param name="baseSource">Underlying base stream.</param>
protected WaveAggregatorBase(IWaveSource baseSource)
: this()
{
if (baseSource == null)
throw new ArgumentNullException("baseSource");
_baseSource = baseSource;
}
开发者ID:opcon,项目名称:cscore,代码行数:12,代码来源:WaveAggregatorBase.cs
示例7: Pcm8BitToSample
public Pcm8BitToSample(IWaveSource source)
: base(source, 8, AudioEncoding.Pcm)
{
if (source == null)
throw new ArgumentNullException("source");
if (!source.WaveFormat.IsPCM() && source.WaveFormat.BitsPerSample != 8)
throw new InvalidOperationException("Invalid format. Format has to 8 bit Pcm.");
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:8,代码来源:Pcm8BitToSample.cs
示例8: CsCoreData
internal CsCoreData(ISoundOut soundOut, IWaveSource source)
{
this.soundOut = soundOut;
this.source = source;
locker = new object();
soundOut.Initialize(source);
}
开发者ID:Artentus,项目名称:GameUtils,代码行数:8,代码来源:CsCoreData.cs
示例9: Pcm24BitToSample
/// <summary>
/// Initializes a new instance of the <see cref="Pcm24BitToSample"/> class.
/// </summary>
/// <param name="source">The underlying 24-bit POCM <see cref="IWaveSource"/> instance which has to get converted to a <see cref="ISampleSource"/>.</param>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentException">The format of the <paramref name="source"/> is not 24-bit PCM.</exception>
public Pcm24BitToSample(IWaveSource source)
: base(source)
{
if (source == null)
throw new ArgumentNullException("source");
if (!source.WaveFormat.IsPCM() && source.WaveFormat.BitsPerSample != 24)
throw new InvalidOperationException("Invalid format. Format has to 24 bit Pcm.");
}
开发者ID:hoangduit,项目名称:cscore,代码行数:14,代码来源:Pcm24BitToSample.cs
示例10: WaveToSampleBase
public WaveToSampleBase(IWaveSource source, int bits, AudioEncoding encoding)
{
if (source == null) throw new ArgumentNullException("source");
_source = source;
_waveFormat = new WaveFormat(source.WaveFormat.SampleRate, 32,
source.WaveFormat.Channels, AudioEncoding.IeeeFloat);
_bpsratio = 32.0 / bits;
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:9,代码来源:WaveToSampleBase.cs
示例11: IeeeFloatToSample
public IeeeFloatToSample(IWaveSource source)
: base(source, 32, AudioEncoding.IeeeFloat)
{
if (source == null)
throw new ArgumentNullException("source");
if (!source.WaveFormat.IsIeeeFloat() ||
source.WaveFormat.BitsPerSample != 32)
throw new InvalidOperationException("Invalid format. Format has to be 32 bit IeeeFloat");
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:9,代码来源:IeeeFloatToSample.cs
示例12: WaveToSampleBase
/// <summary>
/// Initializes a new instance of the <see cref="WaveToSampleBase"/> class.
/// </summary>
/// <param name="source">The underlying <see cref="IWaveSource"/> instance which has to get converted to a <see cref="ISampleSource"/>.</param>
/// <exception cref="ArgumentNullException">The <paramref name="source"/> argument is null.</exception>
protected WaveToSampleBase(IWaveSource source)
{
if (source == null)
throw new ArgumentNullException("source");
Source = source;
_waveFormat = (WaveFormat) source.WaveFormat.Clone();
_waveFormat.BitsPerSample = 32;
_waveFormat.SetWaveFormatTagInternal(AudioEncoding.IeeeFloat);
}
开发者ID:opcon,项目名称:cscore,代码行数:15,代码来源:WaveToSampleBase.cs
示例13: CachedSoundSource
/// <summary>
/// Initializes a new instance of the <see cref="CachedSoundSource"/> class.
/// </summary>
/// <param name="source">Source which will be copied to a cache.</param>
public CachedSoundSource(IWaveSource source)
{
if (source == null)
throw new ArgumentNullException("source");
if (source.Length > Int32.MaxValue)
throw new ArgumentException("Length is of source is too large.");
_waveFormat = source.WaveFormat;
CacheSource(source);
}
开发者ID:ianski,项目名称:cscore,代码行数:15,代码来源:CachedSoundSource.cs
示例14: InitializeVisualization
public IWaveSource InitializeVisualization(IWaveSource source)
{
source = new FFTDataProvider(source) { Bands = 512 };
FFTDataProvider = source as FFTDataProvider;
var sampleDataProvier = new SampleDataProvider(source);
sampleDataProvier.Mode = SampleDataProviderMode.LeftAndRight;
SampleDataProvider = sampleDataProvier;
return sampleDataProvier.ToWaveSource(16);
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:11,代码来源:VisualizationViewModel.cs
示例15: CreateFFTAggregator
private void CreateFFTAggregator(IWaveSource source)
{
if (_fftaggregator != null)
{
_fftaggregator.FFTCalculated -= OnNewData;
_fftaggregator = null;
}
_fftaggregator = new FFTAggregator(source);
_fftaggregator.FFTCalculated += OnNewData;
BaseStream = _fftaggregator;
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:12,代码来源:FFTDataProvider.cs
示例16: CreateSoundOut
ISoundOut CreateSoundOut(ref IWaveSource source)
{
ISoundOut soundOut;
if (WasapiOut.IsSupportedOnCurrentPlatform)
soundOut = new WasapiOut(true, AudioClientShareMode.Shared, 50);
else
{
soundOut = new DirectSoundOut() { Latency = 100 };
if (source.WaveFormat.BitsPerSample > 16)
source = source.ToSampleSource().ToWaveSource(16);
}
return soundOut;
}
开发者ID:Artentus,项目名称:GameUtils,代码行数:13,代码来源:CsCoreEngine.cs
示例17: UpdateMetadata
void UpdateMetadata(IWaveSource source)
{
// duration of the last track imported from a CUE sheet is not initially known;
// update it now that we have audio source decoded; this update is only valid for the last track!
if (_duration == TimeSpan.Zero)
{
var duration = source.GetLength();
_duration = duration - Offset;
SetDuration(_duration);
}
kHz = source.WaveFormat.SampleRate / 1000;
kbps = source.WaveFormat.BytesPerSecond * 8 / 1000;
}
开发者ID:WELL-E,项目名称:Hurricane,代码行数:14,代码来源:LocalTrackFragment.cs
示例18: GetData
public static async Task<float[][]> GetData(IWaveSource waveSource)
{
if (waveSource == null)
throw new ArgumentNullException("waveSource");
return await Task.Run(() =>
{
var sampleSource = new InterruptDisposeChainSource(waveSource).ToSampleSource();
var channels = sampleSource.WaveFormat.Channels;
var blockSize = (int) (sampleSource.Length / channels / NumberOfPoints);
var waveformDataChannels = new WaveformDataChannel[channels];
for (var i = 0; i < channels; i++)
{
waveformDataChannels[i] = new WaveformDataChannel(blockSize);
}
var buffer = new float[sampleSource.WaveFormat.BlockAlign * 5];
var sampleCount = 0;
var flag = true;
while (flag)
{
var samplesToRead = buffer.Length;
var read = sampleSource.Read(buffer, 0, samplesToRead);
for (var i = 0; i < read; i += channels)
{
for (var n = 0; n < channels; n++)
{
waveformDataChannels[n].AddSample(buffer[i + n]);
sampleCount++;
}
}
if (read == 0)
flag = false;
}
foreach (var waveformDataChannel in waveformDataChannels)
{
waveformDataChannel.Finish();
}
Length = sampleCount;
return waveformDataChannels.Select(x => x.GetData()).ToArray();
});
}
开发者ID:opcon,项目名称:cscore,代码行数:49,代码来源:WaveformData.cs
示例19: BufferSource
/// <summary>
/// Initializes a new instance of the <see cref="BufferSource"/> class.
/// </summary>
/// <param name="source">The <see cref="IWaveSource"/> to buffer.</param>
/// <param name="bufferSize">Size of the buffer.</param>
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="bufferSize"/> is out of range.</exception>
public BufferSource(IWaveSource source, int bufferSize)
: base(source)
{
if (bufferSize <= 0 || bufferSize % source.WaveFormat.BlockAlign != 0)
throw new ArgumentOutOfRangeException("bufferSize");
_buffer = new FixedSizeBuffer<byte>(bufferSize);
_lockObject = new Object();
_bufferThread = new Thread(BufferProc)
{
Priority = ThreadPriority.Normal,
IsBackground = false
};
_bufferThread.Start();
}
开发者ID:opcon,项目名称:cscore,代码行数:22,代码来源:BufferSource.cs
示例20: StreamingSourceVoice
internal StreamingSourceVoice(XAudio2 xaudio2, IWaveSource waveSource, VoiceCallback voiceCallback, int bufferSize)
: base(CreateSourceVoice(xaudio2, waveSource, voiceCallback), xaudio2.Version)
{
_voiceCallback = voiceCallback;
_waveSource = waveSource;
var maxBufferBytes = (int)waveSource.WaveFormat.MillisecondsToBytes(bufferSize);
_buffer = new byte[maxBufferBytes];
for (int i = 0; i < _buffers.Length; i++)
{
var buffer = new XAudio2Buffer(maxBufferBytes);
_buffers[i] = buffer;
}
InitializeForStreaming();
}
开发者ID:opcon,项目名称:cscore,代码行数:17,代码来源:StreamingSourceVoice.cs
注:本文中的IWaveSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论