From 6586e82aca08560fed57b99df6a487e69cec3c87 Mon Sep 17 00:00:00 2001 From: KristofferStrube Date: Mon, 3 Jun 2024 15:23:54 +0200 Subject: [PATCH] Ensured that the main keyboard node is disconnected on dispose. --- .../Pages/Keyboard.razor | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/samples/KristofferStrube.Blazor.WebAudio.WasmExample/Pages/Keyboard.razor b/samples/KristofferStrube.Blazor.WebAudio.WasmExample/Pages/Keyboard.razor index f7a49e3..9d0487a 100644 --- a/samples/KristofferStrube.Blazor.WebAudio.WasmExample/Pages/Keyboard.razor +++ b/samples/KristofferStrube.Blazor.WebAudio.WasmExample/Pages/Keyboard.razor @@ -1,6 +1,7 @@ @page "/Keyboard" @inject IJSRuntime JSRuntime @using KristofferStrube.Blazor.WebAudio.WasmExample.ADSREditor +@implements IAsyncDisposable WebAudio - Keyboard

Keyboard

@@ -212,6 +213,24 @@ var halfStepDifference = noteIndex - A4Index; return (float)(A4 * Math.Pow(a, halfStepDifference)); } + + public async ValueTask DisposeAsync() + { + if (context is not null) + { + await context.DisposeAsync(); + } + if (mainNode is not null) + { + await mainNode.DisconnectAsync(); + await mainNode.DisposeAsync(); + } + if (compressor is not null) + { + await compressor.DisconnectAsync(); + await compressor.DisposeAsync(); + } + } }