Toine db
Toine db

Reputation: 779

How to store a .wav file in Windows 10 with NAudio

I'm trying to store my 16000hz 16bit mono PCM audio bytes to a wav file in a Windows 10 app.

NAudio normaly has a WavFileWriter, but it seems to be gone in the Windows 10 version. I can only seem to find access to new WaveFormat(16000, 16, 1); from https://www.nuget.org/packages/NAudio/1.7.3/

Is there a stream I can use to create the Wav file or its bytes?

Upvotes: 0

Views: 596

Answers (2)

Mark Heath
Mark Heath

Reputation: 49482

Yes the reason WaveFileWriter is not available in UWP is because you can't use the old File APIs in UWP so WaveFileWriter would need to be re-written to work in UWP.

As Tommaso has pointed out, UWP does actually have the ability to create WAV files using AudioGraph but it's options are very limited, so you may not be able to specify the exact sample rate you want. You might find that AudioEncodingQuality.Low uses a lower sample rate with WAV. (I can't remember off the top of my head)

Upvotes: 0

Tommaso Scalici
Tommaso Scalici

Reputation: 478

I suspect that NAudio removed WavFileWriter because there's now a substitute in the standard UWP API, in the Windows.Media.Audio namespace. What you should use now is something like this:

MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);

Documentation for the api: link

Upvotes: 0

Related Questions