Search code examples
unity-game-engineuwphololens

How can I adjust microphone input levels in HoloLens?


In our communications app, some people's voices are too quiet. So we want to be able to change the system level of their microphone input. I searched through all the Windows Universal App samples and Unity documentation and I couldn't find how to change the volume of the Windows microphone (on Windows or HoloLens).


Solution

  • I found that the property to adjust is the AudioDeviceController.VolumePercent property. The following code implements this:

    MediaCapture mediaCapture = new MediaCapture();
    var captureInitSettings = new MediaCaptureInitializationSettings
    {
        StreamingCaptureMode = StreamingCaptureMode.Audio
    };
    await mediaCapture.InitializeAsync(captureInitSettings);
    mediaCapture.AudioDeviceController.VolumePercent = volumeLevel;
    

    I confirmed that this code works on Desktop and HoloLens. It changes the system level, so it's automatically persisted, and would affect all apps.