Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

XNA 4 includes the Microsoft.Xna.Framework.Audio.Microphone class which can seemingly read the raw sound data off the microphone via its API as documented:

GetData - Gets the latest recorded data from the microphone.

GetSampleDuration - Returns the duration of audio playback based on the size of the buffer.

GetSampleSizeInBytes - Returns the size of the byte array required to hold the specified duration of audio for this microphone object.

Can I read sound data using this class, record it in an array and then play it back? On the Xbox 360?

share|improve this question
up vote 7 down vote accepted

You could try submitting the data from the microphone to a Dynamic Sound Effect.

I just wrote some code to test this, it works.

DynamicSoundEffectInstance sound;

protected override void Initialize()
    sound = new DynamicSoundEffectInstance(Microphone.Default.SampleRate, AudioChannels.Mono);

    Microphone.Default.BufferReady += (a, b) =>
        byte[] data = new byte[Microphone.Default.GetSampleSizeInBytes(Microphone.Default.BufferDuration)];



protected override void Update(GameTime gameTime)
    if (gameTime.TotalGameTime.TotalSeconds > 5)

share|improve this answer

As a supplement to Martin's answer (can't comment yet, otherwise I would just do that):

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.