I am receiving packets from DIS from network and want to convert these into wav file. I add buffer to my provider as below.
WaveFileWriter writer;
public Player()
{
writer = new WaveFileWriter(@"c:\_temp\file.wav", waveProvider.WaveFormat);
}
public void AddSamples(byte[] leftDataBuffer)
{
waveProvider.AddSamples(leftDataBuffer, 0, leftDataBuffer.Length);
writer.Write(leftDataBuffer, 0, leftDataBuffer.Length);
}
How can I keep adding the buffer to the same file in this function itself? Please help.
I'm not sure if are you trying to play the audio, or just save it to WAV. If just creating a WAV, use WaveFileWriter
instead of BufferedWaveProvider
and call Write
passing in the received audio.
But you can use both if you want, writing received data to both a WaveFileWriter
and putting it into a BufferedWaveProvider
for live playback.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.