Hey so i was wondering would it be possible to say make a player jump when the microphone of a device gets some input like if i make a sound into the microphone my player would jump or move or a simpliar version would be something like flappy bird where if i make noise into my device the bird goes up and when no noise it falls again
I have absolutely no clue on to weather or not its, possible in unity but now I want to try this. If I had to guess the mic. would input some flavor of float, perhaps you could the set a range with a min and max variable for what you consider sound then have you action trigger for something like
If(SoundLvl > MinSound (&& or ||...not sure which off the top of my head) SoundLvl < MaxSound)
{
Jump()
}
You may only need the min sound level, sense you not looking for a specific frequency. I’d Have to play around with what the mic does before I’d know for certain.
Hello, as far I know you can not process Microphone input at real time (I am not sure about this don’t quote on me). but you can record audio clips using microphone class .
what I am suggesting to you is, you can just record very short clips, (lets say 10ms long) and then you can read every sample in that record. to is if there is some noise or not. but this will be work with a quiet delay. (jump action will be executed at least 2 frames late) while it depends on your game mechanics, this delay may be tolerable. if you can tolerate this kind of delay.
just check this links in order :
2-) microphone script referance
3-) audio clip
I was done something similar before.
here how I detect speech before.
void SpeechDetection ()
{
A = AnalizeSound();
if (A >=criticalSoundValue)
{
isTalking = true;
} else
{
isTalking=false;
}
}
float AnalizeSound()
{
float a = 0;
_audio.GetOutputData(Sample,0);
foreach(float s in Sample)
{
a += Mathf.Abs(s);
}
return a;
}
you can first record a AudioClip then you can analize it with some code similar like this to check if user talking or not.
I hope this helps, If you need further help just comment below.