本文整理汇总了C#中NAudio.Wave.WaveFormat.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# WaveFormat.Serialize方法的具体用法?C# WaveFormat.Serialize怎么用?C# WaveFormat.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAudio.Wave.WaveFormat
的用法示例。
在下文中一共展示了WaveFormat.Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaveFileWriter
/// <summary>
/// WaveFileWriter that actually writes to a stream
/// </summary>
/// <param name="outStream">Stream to be written to</param>
/// <param name="format">Wave format to use</param>
public WaveFileWriter(Stream outStream, WaveFormat format)
{
this.outStream = outStream;
this.format = format;
this.writer = new BinaryWriter(outStream, System.Text.Encoding.UTF8);
this.writer.Write(System.Text.Encoding.UTF8.GetBytes("RIFF"));
this.writer.Write((int)0); // placeholder
this.writer.Write(System.Text.Encoding.UTF8.GetBytes("WAVE"));
this.writer.Write(System.Text.Encoding.UTF8.GetBytes("fmt "));
format.Serialize(this.writer);
CreateFactChunk();
WriteDataChunkHeader();
}
示例2: WaveFileWriter
/// <summary>
/// WaveFileWriter that actually writes to a stream
/// </summary>
/// <param name="outStream">Stream to be written to</param>
/// <param name="format">Wave format to use</param>
public WaveFileWriter(Stream outStream, WaveFormat format)
{
this.outStream = outStream;
BinaryWriter w = new BinaryWriter(outStream, System.Text.Encoding.ASCII);
w.Write(System.Text.Encoding.ASCII.GetBytes("RIFF"));
w.Write((int)0); // placeholder
w.Write(System.Text.Encoding.ASCII.GetBytes("WAVEfmt "));
this.format = format;
format.Serialize(w);
CreateFactChunk(outStream, format, w);
WriteDataChunkHeader(outStream, w);
}
示例3: AudioFormat
/// <summary>
/// Creates a new instance of the AudioFormat class
/// </summary>
/// <param name="waveFormat">The WaveFormat representing the WAV header.</param>
internal AudioFormat(WaveFormat waveFormat)
{
averageBytesPerSecond = waveFormat.AverageBytesPerSecond;
bitsPerSample = waveFormat.BitsPerSample;
blockAlign = waveFormat.BlockAlign;
channelCount = waveFormat.Channels;
format = (int)waveFormat.Encoding;
sampleRate = waveFormat.SampleRate;
var stream = new MemoryStream();
using (var writer = new BinaryWriter(stream))
{
waveFormat.Serialize(writer);
nativeWaveFormat = new List<byte>(stream.ToArray());
}
}