本文整理汇总了C#中NAudio.Wave.WaveStream类的典型用法代码示例。如果您正苦于以下问题:C# WaveStream类的具体用法?C# WaveStream怎么用?C# WaveStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveStream类属于NAudio.Wave命名空间,在下文中一共展示了WaveStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResamplerDmoStream
/// <summary>
/// WaveStream to resample using the DMO Resampler
/// </summary>
/// <param name="inputProvider">Input Stream</param>
/// <param name="outputFormat">Desired Output Format</param>
public ResamplerDmoStream(IWaveProvider inputProvider, WaveFormat outputFormat)
{
this.inputProvider = inputProvider;
this.inputStream = inputProvider as WaveStream;
this.outputFormat = outputFormat;
this.resampler = new Resampler();
if (!resampler.MediaObject.SupportsInputWaveFormat(0, inputProvider.WaveFormat))
{
throw new ArgumentException("Unsupported Input Stream format", "inputStream");
}
resampler.MediaObject.SetInputWaveFormat(0, inputProvider.WaveFormat);
if (!resampler.MediaObject.SupportsOutputWaveFormat(0, outputFormat))
{
throw new ArgumentException("Unsupported Output Stream format", "outputStream");
}
resampler.MediaObject.SetOutputWaveFormat(0, outputFormat);
if (inputStream != null)
{
position = InputToOutputPosition(inputStream.Position);
}
this.inputMediaBuffer = new MediaBuffer(inputProvider.WaveFormat.AverageBytesPerSecond);
this.outputBuffer = new DmoOutputDataBuffer(outputFormat.AverageBytesPerSecond);
}
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:30,代码来源:ResamplerDmoStream.cs
示例2: Load
public bool Load(string path, Guid device)
{
var cext = path.GetExt();
_myWaveOut = new DirectSoundOut(device);
try
{
_myWaveStream = _codecs.First(v => v.Extensions.Contains(cext)).CreateWaveStream(path);
}
catch
{
return false;
}
if (_myWaveStream == null) return false;
if (_myWaveStream.WaveFormat.Channels == 2)
{
_myBalanceSampleProvider = new BalanceSampleProvider(_myWaveStream.ToSampleProvider());
_myVolumeSampleProvider = new VolumeSampleProvider(_myBalanceSampleProvider);
_myBalanceSampleProvider.Pan = (float)Balance;
}
else _myVolumeSampleProvider = new VolumeSampleProvider(_myWaveStream.ToSampleProvider());
_myEqualizer = new Equalizer(_myVolumeSampleProvider, _equalizerBands) { Enabled = _enableEqualizer };
_myWaveOut.Init(_myEqualizer);
_myWaveOut.PlaybackStopped += MyWaveOutOnPlaybackStopped;
_myVolumeSampleProvider.Volume = (float)Volume;
return true;
}
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:26,代码来源:NAudioPlayer.cs
示例3: AddInputStream
/// <summary>
/// Add a new input to the mixer
/// </summary>
/// <param name="waveStream">The wave input to add</param>
public void AddInputStream(WaveStream waveStream)
{
if (waveStream.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat)
throw new ArgumentException("Must be IEEE floating point", "waveStream");
if (waveStream.WaveFormat.BitsPerSample != 32)
throw new ArgumentException("Only 32 bit audio currently supported", "waveStream");
if (inputStreams.Count == 0)
{
// first one - set the format
int sampleRate = waveStream.WaveFormat.SampleRate;
int channels = waveStream.WaveFormat.Channels;
this.waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channels);
}
else
{
if (!waveStream.WaveFormat.Equals(waveFormat))
throw new ArgumentException("All incoming channels must have the same format", "waveStream");
}
lock (inputsLock)
{
this.inputStreams.Add(waveStream);
this.length = Math.Max(this.length, waveStream.Length);
// get to the right point in this input file
waveStream.Position = Position;
}
}
开发者ID:Shadetheartist,项目名称:Numboard-2.0,代码行数:32,代码来源:WaveMixerStream32.cs
示例4: WaveListenerProvider
public WaveListenerProvider(WaveStream sourceStream)
{
this.sourceStream = sourceStream;
waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sourceStream.WaveFormat.SampleRate, sourceStream.WaveFormat.Channels);
sampleAggregator.FftCalculated += new EventHandler<FftEventArgs>(FftCalculated);
sampleAggregator.PerformFFT = true;
}
开发者ID:Magicpig55,项目名称:MMP,代码行数:8,代码来源:WaveListenerProvider.cs
示例5: WaveFormatConversionStream
/// <summary>
/// Create a new WaveFormat conversion stream
/// </summary>
/// <param name="targetFormat">Desired output format</param>
/// <param name="sourceStream">Source stream</param>
public WaveFormatConversionStream(WaveFormat targetFormat, WaveStream sourceStream)
{
this.sourceStream = sourceStream;
this.targetFormat = targetFormat;
conversionProvider = new WaveFormatConversionProvider(targetFormat, sourceStream);
length = EstimateSourceToDest((int)sourceStream.Length);
position = 0;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:13,代码来源:WaveFormatConversionStream.cs
示例6: MeteringStream
public MeteringStream(WaveStream sourceStream, int samplesPerNotification)
{
SourceStream = sourceStream;
if (sourceStream.WaveFormat.BitsPerSample != 32)
throw new ArgumentException("Metering Stream expects 32 bit floating point audio", "sourceStream");
maxSamples = new float[sourceStream.WaveFormat.Channels];
this.SamplesPerNotification = samplesPerNotification;
}
开发者ID:RasterCode,项目名称:OtterUI,代码行数:8,代码来源:MeteringStream.cs
示例7: EffectStream
public EffectStream(EffectChain effects, WaveStream sourceStream)
{
this.effects = effects;
this.source = sourceStream;
foreach (Effect effect in effects)
{
InitialiseEffect(effect);
}
}
开发者ID:AlexShkor,项目名称:GestoMusic,代码行数:9,代码来源:EffectStream.cs
示例8: CreatePcmStream
/// <summary>
/// Creates a stream that can convert to PCM
/// </summary>
/// <param name="sourceStream">The source stream</param>
/// <returns>A PCM stream</returns>
public static WaveStream CreatePcmStream(WaveStream sourceStream)
{
if (sourceStream.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
{
return sourceStream;
}
WaveFormat pcmFormat = AcmStream.SuggestPcmFormat(sourceStream.WaveFormat);
return new WaveFormatConversionStream(pcmFormat, sourceStream);
}
开发者ID:Punloeu,项目名称:karaoke,代码行数:14,代码来源:WaveFormatConversionStream.cs
示例9: CreateReader
private IWaveProvider CreateReader()
{
if (reader is RawSourceWaveStream)
{
reader.Position = 0;
return reader;
}
reader = new MediaFoundationReaderRT(selectedStream);
return reader;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:10,代码来源:MainPageViewModel.cs
示例10: SimpleCompressorStream
/// <summary>
/// Create a new simple compressor stream
/// </summary>
/// <param name="sourceStream">Source stream</param>
public SimpleCompressorStream(WaveStream sourceStream)
{
this.sourceStream = sourceStream;
this.channels = sourceStream.WaveFormat.Channels;
this.bytesPerSample = sourceStream.WaveFormat.BitsPerSample / 8;
simpleCompressor = new SimpleCompressor(5.0, 10.0, sourceStream.WaveFormat.SampleRate);
simpleCompressor.Threshold = 16;
simpleCompressor.Ratio = 6;
simpleCompressor.MakeUpGain = 16;
}
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:14,代码来源:SimpleCompressorStream.cs
示例11: WaveFormatConversionStream
/// <summary>
/// Create a new WaveFormat conversion stream
/// </summary>
/// <param name="targetFormat">Desired output format</param>
/// <param name="sourceStream">Source stream</param>
public WaveFormatConversionStream(WaveFormat targetFormat, WaveStream sourceStream)
{
this.sourceStream = sourceStream;
this.targetFormat = targetFormat;
conversionStream = new AcmStream(sourceStream.WaveFormat, targetFormat);
// work out how many bytes the entire input stream will convert to
length = SourceToDest((int)sourceStream.Length);
blockAlign = SourceToDest(sourceStream.BlockAlign);
position = 0;
}
开发者ID:Punloeu,项目名称:karaoke,代码行数:16,代码来源:WaveFormatConversionStream.cs
示例12: TestSeekPosition
private static void TestSeekPosition(WaveStream mainOutputStream, TimeSpan timeSpan)
{
Console.WriteLine("Hit key to reposition..");
Console.ReadKey();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Seeking to new time: {0}...", timeSpan);
(mainOutputStream as WaveChannel32).CurrentTime = timeSpan;
Console.WriteLine("New position after seek: " + (mainOutputStream as WaveChannel32).CurrentTime);
Console.ResetColor();
}
开发者ID:mattcuba,项目名称:practicesharp,代码行数:12,代码来源:Program.cs
示例13: Extract
private static void Extract(Stream output, WaveStream waveStream, byte[] buffer)
{
if (waveStream == null)
return;
using (WaveFileWriter writer = new WaveFileWriter(output, waveStream.WaveFormat))
{
int count;
while ((count = waveStream.Read(buffer, 0, buffer.Length)) != 0)
writer.Write(buffer, 0, count);
}
}
开发者ID:truongan012,项目名称:Pulse,代码行数:12,代码来源:ScdToWaveArchiveEntryExtractor.cs
示例14: Delay
private float[] bufferFloat; // 32bit float audio
/// <summary>
/// Creates a new delay effect
/// </summary>
/// <param name="inStream">The incoming audio data</param>
/// <param name="length">The delay length in milliseconds</param>
/// <param name="wetPercent">Percentage of output delay</param>
/// <param name="feedbackPercent">Percentage feedback</param>
public Delay(WaveStream inStream, int length, float wetPercent, float feedbackPercent)
{
this.inStream = inStream;
if(inStream.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
{
bufferFloat = new float[(inStream.WaveFormat.AverageBytesPerSecond * length)/ 1000];
}
else if(inStream.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
{
buffer16 = new short[(inStream.WaveFormat.AverageBytesPerSecond * length)/ 1000];
}
}
开发者ID:Punloeu,项目名称:karaoke,代码行数:21,代码来源:Delay.cs
示例15: PlaySong
public int PlaySong(string path)
{
int result = 0;
sync.InvokeIfRequired((Action)delegate
{
CleanPlayerAndStream();
result = -1;
if (!string.IsNullOrEmpty(path))
{
try
{
MakePlayerInternal();
stream = CreateStream(path);
player.Init(stream);
player.Play();
result = (int)(stream.Length / stream.WaveFormat.AverageBytesPerSecond);
}
catch (Exception)
{
CleanPlayerAndStream();
}
}
});
return result;
}
开发者ID:punker76,项目名称:HaMusic,代码行数:25,代码来源:NAudioPlayer.cs
示例16: MainForm
public MainForm()
{
waveOutDevice = null;
mainOutputStream = null;
volumeStream = null;
InitializeComponent();
}
开发者ID:dolvlo,项目名称:ssamplerates,代码行数:7,代码来源:MainForm.cs
示例17: playWave
/// <summary>
/// Lejátszik egy .mp3 fájlt
/// </summary>
/// <param name="audioFile">.mp3 fájl</param>
public static void playWave(string audioFile)
{
thread = new WaveOut();
stream = CreateInputStream(audioFile);
thread.Init(stream);
thread.Play();
}
开发者ID:Easimer,项目名称:bearded-spider,代码行数:11,代码来源:Audio.cs
示例18: Initialize
private void Initialize()
{
var extension = Path.GetExtension(file).ToLowerInvariant();
if (extension.Equals(".wav"))
{
reader = new WaveFileReader(file);
}
else
{
reader = new Mp3FileReader(file);
}
var format = reader.WaveFormat;
this.sampleRate = format.SampleRate;
this.channels = format.Channels;
this.Format = new AudioProperties(format.SampleRate, format.BitsPerSample,
format.Channels, (int)reader.TotalTime.TotalSeconds);
if (format.BitsPerSample != 16)
{
Dispose(true);
}
}
开发者ID:wo80,项目名称:AcoustID.NET,代码行数:26,代码来源:NAudioDecoder.cs
示例19: NAudioDecoder
public NAudioDecoder(string file)
{
extension = Path.GetExtension(file).ToLowerInvariant();
ready = false;
if (extension.Equals(".wav"))
{
reader = new WaveFileReader(file);
}
else
{
reader = new Mp3FileReader(file);
}
var format = reader.WaveFormat;
bitsPerSample = format.BitsPerSample;
sampleRate = format.SampleRate;
channels = format.Channels;
duration = (int)reader.TotalTime.TotalSeconds;
ready = (format.BitsPerSample == 16);
}
开发者ID:knocte,项目名称:AcoustID.NET,代码行数:25,代码来源:NAudioDecoder.cs
示例20: SoundResource
public SoundResource(ResourceManager mgr, string fullName, Stream stream, Format fmt)
{
_manager = mgr;
FullName = fullName;
switch (fmt)
{
case Format.MP3:
{
Mp3FileReader mp3 = new Mp3FileReader(stream);
_reader = mp3;
break;
}
case Format.WAV:
{
WaveFileReader wav = new WaveFileReader(stream);
_reader = wav;
break;
}
default:
throw new InvalidOperationException("Unsupported extension.");
}
_stream = new WaveChannel32(_reader);
_stream.PadWithZeroes = false;
_wavDevice.PlaybackStopped += _wavDevice_PlaybackStopped;
}
开发者ID:Veggie13,项目名称:Genesis,代码行数:28,代码来源:SoundResource.cs
注:本文中的NAudio.Wave.WaveStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论