Search Unity

Android microphone sensitivity different on several devices: blow detection problem

Discussion in 'Android' started by BenoitFreslon, Jan 22, 2018.

  1. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    163
    Hello,

    I'm trying to detect the blow detection on Android.

    An android devices' microphone's sensitivity may be different from another device. Even the manufacturers of the same company cannot comment on their sensitivities.

    For example on my LG G2 or my Motorola E I got a value of 60 when I blow in the microphone.
    However on an another device like a Wiko Rainbow or a OnePlus I got only 5.

    I'm using this script to get the average volume
    http://www.kaappine.fi/tutorials/using-microphone-input-in-unity3d/

    Code (CSharp):
    1. float GetAveragedVolume()
    2. {
    3.     float[] data = new float[256];
    4.     float a = 0;
    5.     audio.GetOutputData(data,0);
    6.     foreach(float s in data)
    7.     {
    8.         a += Mathf.Abs(s);
    9.     }
    10.     return a/256 *100f;
    11. }
     
  2. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Can't you just ask the user to calibrate it when they first install the app.
     
  3. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    163
    Actually it's a puzzle. For example you need to found by yourself how to blow a candle.
    So I can't ask him directly to blow.

    I can't know if the user is blowing because the values are random.
    They depend of the device.
     
  4. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Well yes that's why when the game is first run you ask to the player to blow so you can calibrate the for the max value given by the user and device.
     
  5. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    163
    I will not ask to the player to blow just to calibrate the microphone because It will spoil the puzzle.
    I already ask too much at the beginning of the game.

    I think I will calculate the average volume during a moment and check if the volume will increase drastically for short moment. I think it will determinate a blow in a microphone.
     
    Last edited: Jan 23, 2018