Microphone.Start Manual     Reference     Scripting  
Scripting > Runtime Classes > Microphone
Microphone.Start

static function Start (deviceName : String, loop : boolean, lengthSec : int, frequency : int) : AudioClip

Parameters

NameDescription
deviceName the name of the device. Passing null or an empty string will pick the default device. Get device names with Microphone.devices
lengthSec is the length of the AudioClip produced by the recording.
loop indicates whether the recording should continue recording if lengthSec is reached, and wrap around and record from the beginning of the AudioClip.
frequency is the smaplerate of the AudioClip produced by the recording. Get minimum and maximum supported rates from [GetDeviceCaps].

Returns

AudioClip - the function returns null if the recording fails to start Note that if you want to use the Microphone class in the web player, you need to get the user's permission to do so. Call Application.RequestUserAuthorization before calling any Microphone methods.

Description

Start Recording with device

JavaScript
// Start recording with built-in Microphone and play the recorded audio right away
function Start() {
audio.clip = Microphone.Start("Built-in Microphone", true, 10, 44100);
audio.Play();
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Start() {
audio.clip = Microphone.Start("Built-in Microphone", true, 10, 44100);
audio.Play();
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Start():
audio.clip = Microphone.Start('Built-in Microphone', true, 10, 44100)
audio.Play()