using System;
using System.Runtime.InteropServices.JavaScript;
using System.Threading.Tasks;
namespace Susurrus.WebAudio.Testbed
{
///
/// What the testbed needs from its page, mirroring testbed.js.
///
public static partial class TestbedInterop
{
private static Task loadTask;
public static Task EnsureLoadedAsync()
{
return loadTask ??= JSHost.ImportAsync("susurrus-testbed", "../testbed.js");
}
[JSImport("isTestMode", "susurrus-testbed")]
public static partial bool IsTestMode();
[JSImport("report", "susurrus-testbed")]
public static partial void Report(string line, string kind);
[JSImport("newOfflineContext", "susurrus-testbed")]
public static partial JSObject NewOfflineContext(int channelCount, int frameCount, int sampleRate);
[JSImport("newOfflineContextWithoutCodecs", "susurrus-testbed")]
public static partial JSObject NewOfflineContextWithoutCodecs(int channelCount, int frameCount, int sampleRate);
[JSImport("newSuspendedAudioContext", "susurrus-testbed")]
[return: JSMarshalAs>]
public static partial Task NewSuspendedAudioContext();
[JSImport("closeContext", "susurrus-testbed")]
public static partial void CloseContext(JSObject context);
[JSImport("pressPointer", "susurrus-testbed")]
public static partial void PressPointer();
[JSImport("render", "susurrus-testbed")]
[return: JSMarshalAs>]
public static partial Task Render(JSObject context);
[JSImport("renderWithTicks", "susurrus-testbed")]
[return: JSMarshalAs>]
public static partial Task RenderWithTicks(
JSObject context, double intervalSeconds, [JSMarshalAs] Action tick);
[JSImport("maxDifference", "susurrus-testbed")]
public static partial double MaxDifference(JSObject first, JSObject second, int channel);
[JSImport("peak", "susurrus-testbed")]
public static partial double Peak(JSObject buffer, int channel, int startFrame, int endFrame);
[JSImport("lastLoudFrame", "susurrus-testbed")]
public static partial int LastLoudFrame(JSObject buffer, int channel, double threshold);
}
}