Created
October 22, 2020 21:33
-
-
Save martindevans/841bdda02a58df7cdc14cb4262f7862f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
class GetAecMetrics | |
: MonoBehaviour | |
{ | |
#if UNITY_IOS && !UNITY_EDITOR | |
private const string ImportString = "__Internal"; | |
private const CallingConvention Convention = default(CallingConvention); | |
#else | |
private const string ImportString = "AudioPluginDissonance"; | |
private const CallingConvention Convention = CallingConvention.Cdecl; | |
#endif | |
[DllImport(ImportString, CallingConvention = Convention)] | |
private static extern void Dissonance_GetAecMetrics(IntPtr floatBuffer, int bufferLength); | |
private static void LogDetails() | |
{ | |
var stats = new float[10]; | |
unsafe | |
{ | |
fixed (float* statsPtr = &stats[0]) | |
Dissonance_GetAecMetrics(new IntPtr(statsPtr), stats.Length); | |
Debug.Log( | |
$"Delay Median (samples): {stats[0]}\n" + | |
$"Delay Deviation: {stats[1]}\n" + | |
$"Fraction Poor Delays: {stats[2]}\n" + | |
$"Echo Return Loss: {stats[3]}\n" + | |
$"Echo Return Loss Enhancement: {stats[6]}\n" + | |
$"Residual Echo Likelihood: {stats[9]}" | |
); | |
} | |
} | |
public void Update() | |
{ | |
LogDetails(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment