After purchasing a device around 3 weeks ago I have now registered as a developer and I now have the ability to deploy applications to my device.
I thought I should revisit some of my previous WP7Dev related postings, one being WP7 and Microsoft.Xna.Framework.Audio.Microphone.
After creating a new project for this sample code and running it I was presented with the following error :-
"FrameworkDispatcher.Update has not been called. Regular FrameworkDispatcher.Update calls are necessary for fire and forget sound effects and framework events to function correctly. See http://go.microsoft.com/fwlink/?LinkId=193853 for details."
After a search I found the following blog post which solved the issue :-
Recording Audio in Silverlight on Windows Phone 7
Showing posts with label Audio. Show all posts
Showing posts with label Audio. Show all posts
Friday, 10 December 2010
Monday, 10 May 2010
WP7 and Microsoft.Xna.Framework.Audio.Microphone
I was looking to try out the Microphone functionality as detailed by Peter Foot in the following blog post :-
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(m_BufferReady);
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();
}
}
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();
}
}
Subscribe to:
Comments (Atom)