问题
I recording sound from Microphone in Windows Phone device. Using Xna.Framework.Audio.Microphone
I store the sound in MemoryStream
. I can save it to PCM format. However It will be much better to convert it to mp3 file. If converting to mp3 is impossible then maybe somebody at least knows how to convert it to wav.
Thanks for your answers.
回答1:
Here is a brief example I created showing how to save wp7 recorded audio as a wav stream: http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/
回答2:
Here's a great thread which answers this question:
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/59af6c3b-0dd1-4fa0-8438-d7f82e655109
It is a simple WAV file with its header missing. Therefore, Windows has no clue about the format. Unfortunately, the current WP7 OS API (as far as I know) doesn't offer any service to create a WAV file (the RIFF header + the raw PCM data). The RIFF header is not complicated and well documented. It is fairly simple to write the managed code to create one using the known PCM format which, as you already know, is 16bit/mono.
Or alternatively, if you're only trying to save/play it on the wp7 device ...
You should be able to use;
SoundEffect sePlay = new SoundEffect(yourSavedByte[], mic.SampleRate, AudioChannels.Mono); sePlay.Play();
to playback your audio byte[]. I record, save, and playback using just the byte[] on WP7. You shouldn’t need anything more then the raw byte[] if you use the SoundEffect class for playback.
来源:https://stackoverflow.com/questions/4437921/saving-microphone-stream-to-mp3-or-wave