I am facing the following problem regarding to the voice (Audio) recording in windows phone 7.
I am recording the sound using Microphone class available in Microsoft.Xna.Framework.Audio namespace. here is the code -
Variable declaration:
private Microphone mic = Microphone.Default;
private MemoryStream stream;
private const string FILE_NAME = "recording.mp3";
byte[] buffer;
Recording Button click code-
mic.BufferDuration = TimeSpan.FromSeconds(1);
buffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)];
// Create the event handler. I could have done an anonymous
// delegate here if I had so desired.
mic.BufferReady += new EventHandler<EventArgs>(mic_BufferReady);
stream = new MemoryStream();
mic.Start();
Buffer Ready Event code ----------
void mic_BufferReady(object sender, EventArgs e)
{
mic.GetData(buffer);
// Write buffer to stream
stream.Write(buffer, 0, buffer.Length);
}
Button stop code -
private void btnStop_Click(object sender, RoutedEventArgs e)
{
dt.Stop();
btnStop.IsEnabled = false;
btnPlayRecording.IsEnabled = true;
mic.Stop();
//Writing stream into Storage
writeFile(stream);
}
private void writeFile(MemoryStream s, string name)
{
try
{
using (var userStore = IsolatedStorageFile.GetUserStoreForApplication())
{
if (userStore.FileExists(name))
{
userStore.DeleteFile(name);
}
using (var file = userStore.OpenFile(name, FileMode.CreateNew))
{
s.WriteTo(file);
}
}
}
catch (Exception ee)
{
}
}
Once I save the stream into isolated storage and play it back, the volume is very low and the quality is also not good.
So
- Can we amplify the Volume ?
- can we increase the bitrate ?
- Can we do Fadin-Fadout ?
If all these three is not possible in windows phone 7, then is there any third party API available to perform all these operations?
Thanks in advance