Skip to content

Commit

Permalink
Ensured that the main keyboard node is disconnected on dispose.
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferStrube committed Jun 3, 2024
1 parent 63af34d commit 6586e82
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@page "/Keyboard"
@inject IJSRuntime JSRuntime
@using KristofferStrube.Blazor.WebAudio.WasmExample.ADSREditor
@implements IAsyncDisposable

<PageTitle>WebAudio - Keyboard</PageTitle>
<h2>Keyboard</h2>
Expand Down Expand Up @@ -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();
}
}
}


0 comments on commit 6586e82

Please sign in to comment.