my script is following …
private var volume:float;
private var inRecord:boolean=false;
private var temp:GameObject;
function Start(){
temp=GameObject.CreatePrimitive(PrimitiveType.Cube);
temp.transform.position=Vector3(0,0,0);
temp.active=true;
}
function Update() {
if(!audio.isPlaying){
inRecord=false;
recordSound();
}else{
inRecord=true;
}
volume=analyzeSound();
if(temp.active && volume >.038){
temp.active=false;
audio.clip=null;
}
}
function recordSound(){
audio.loop=true;
audio.mute=true;
audio.clip=Microphone.Start("",true,1,24000);
while (!(Microphone.GetPosition("Built-in Microphone") > 0)) {
}
audio.Play();
}
function analyzeSound():float{
var data:float[]=new float[256];
var vol:float;
audio.GetSpectrumData(data,0,FFTWindow.Rectangular);
for(var i=0;i<256;i++){
vol+=Mathf.Abs(data*);*
- }*
- data=null;*
- return vol/256;*
}
I am getting Different value on different devices .why is it so .