问题
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?
回答1:
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
回答2:
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)
来源:https://stackoverflow.com/questions/39474257/how-to-store-a-wav-file-in-windows-10-with-naudio