http://mobileworld.appamundi.com/blogs/peterfoot/archive/2010/03/26/audio-recording-in-wp7.aspx
This is the code that I came up with :-
public partial class MainPage : PhoneApplicationPage
{
private Microphone currentMic = Microphone.Default;
private byte[] currentData;
private MemoryStream currentStream = new MemoryStream();
public MainPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
}
private void m_BufferReady(object sender, EventArgs e)
{
currentMic.GetData(currentData);
currentStream.Write(currentData, 0, currentData.Length);
}
private void Start_Click(object sender, RoutedEventArgs e)
{
currentMic.BufferDuration = TimeSpan.FromMilliseconds(1000);
currentData = new byte[currentMic.GetSampleSizeInBytes(currentMic.BufferDuration)];
currentMic.BufferReady += new EventHandler
currentMic.Start();
}
private void Stop_Click(object sender, RoutedEventArgs e)
{
currentMic.Stop();
currentStream.Close();
}
private void Play_Click(object sender, RoutedEventArgs e)
{
SoundEffect currentSoundEffect = new SoundEffect(currentStream.ToArray(), currentMic.SampleRate, AudioChannels.Mono);
currentSoundEffect.Play();
}
}
This comment has been removed by a blog administrator.
ReplyDeleteExcellent, thanks
ReplyDeleteThank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me
ReplyDeleteyeti usb microphone