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

2

0

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?

Discriminative answered 13/9, 2016 at 15:52 Comment(0)
P
0

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

Pieter answered 13/9, 2016 at 18:46 Comment(1)
Thanks, I've been looking into AudioGraph but i couldn't find a way to set 16000hz anywhere (when saving audio). Then I found NAudio that looked promising. Any suggestions how to save a 16khz wav?Discriminative
E
0

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)

Eclampsia answered 17/9, 2016 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.