Microphone in 3.5 beta

Essentially I want to move an object based on the volume of the players voice (or failing that, simply move an object when the speaker is making noise) but I’m looking through the documentation on ‘Microphone’ and it’s not great:

// Start recording with built-in Microphone and play the recorded audio right away

function Start() {
audio.clip = Microphone.startRecord("Built-in Microphone", true, 10);
audio.Play();
}

The above code is from the unity script reference for Microphone.Start and it’s got a few problems. First, it’s Microphone.Start not Microphone.startRecord and second it’s suppose to have four arguments in it (string,boolean,int,int), not just three.

In short, the sample code doesn’t work so I’m having trouble working from it.

So to reiterate, I want to be able to move an object based on the volume of the sound input in the microphone.

So is anyone having any luck with dealing with Microphone input in the 3.5 beta and if so could you please help start me off on coding this?

I tried fixing the example code but I’m not sure what to put in for the frequency, although anything above 0 works it doesn’t seem to be doing anything (yes I have an audio source component on the scripted object and the camera/audio listener is close enough to hear things):

audio.clip = Microphone.Start(null, true, 10,??);
audio.Play();

Anyway, recording the audio is just half the problem, I need to analyze it on the fly, presumably using AudioClip.GetData in some fashion (not quite sure how I’d get the data for the part of the array that’s currently being recorded though, among other things).

Anyway, any help would be greatly appreciated.

Hi,
I had a similar problem but i was able to fix it, by expanding you first fixing:

function OnGUI()
{
  if (GUI.Button(Rect(10,10,60,50),"Record"))
  {	
    // null graift auf das standart microfon des jeweiligen users zu
    // soll nie Aufnahme geloopt werden (hier nciht -> false)
    // Aufnahme Zeit in Sekunden (hier momentan 3)
    // Aufnahme Fraquenz (hier 44100)
    audio.clip= Microphone.Start ( null, false, 3, 44100 ); 
  }
  if (GUI.Button(Rect(10,70,60,50),"Play"))
  {	
    //Aufnahme abspielen
    audio.Play();
  }
}