File tree 1 file changed +6
-2
lines changed
samples/KristofferStrube.Blazor.WebAudio.WasmExample/Pages
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
@page " /Keyboard"
2
2
@inject IJSRuntime JSRuntime
3
3
@using KristofferStrube .Blazor .WebAudio .WasmExample .ADSREditor
4
+
4
5
<PageTitle >WebAudio - Keyboard</PageTitle >
5
6
<h2 >Keyboard</h2 >
6
7
62
63
63
64
AudioContext context = default ! ;
64
65
GainNode ? mainNode ;
66
+ DynamicsCompressorNode ? compressor ;
65
67
GainNode ? keyboardMain ;
66
68
OscillatorNode ? oscillator ;
67
69
91
93
92
94
public async Task InitializeContext ()
93
95
{
94
- if (context is null || mainNode is null )
96
+ if (context is null || mainNode is null || compressor is null )
95
97
{
96
98
context = await AudioContext .CreateAsync (JSRuntime );
97
99
mainNode = await GainNode .CreateAsync (JSRuntime , context , new () { Gain = 0 . 5 f });
100
+ compressor = await DynamicsCompressorNode .CreateAsync (JSRuntime , context );
98
101
await using AudioDestinationNode destination = await context .GetDestinationAsync ();
102
+ await compressor .ConnectAsync (mainNode );
99
103
await mainNode .ConnectAsync (destination );
100
104
}
101
105
}
121
125
keyboardMain = await GainNode .CreateAsync (JSRuntime , context , new () { Gain = 0 });
122
126
123
127
await oscillator .ConnectAsync (keyboardMain );
124
- await keyboardMain .ConnectAsync (mainNode ! );
128
+ await keyboardMain .ConnectAsync (compressor ! );
125
129
await oscillator .StartAsync ();
126
130
127
131
var time = await context .GetCurrentTimeAsync ();
You can’t perform that action at this time.
0 commit comments