@@ -8,16 +8,14 @@ namespace IntegrationTests.AudioNodeTests;
8
8
public class AnalyserNodeTest : AudioNodeWithAudioNodeOptions < AnalyserNode , AnalyserOptions >
9
9
{
10
10
public override Task < AnalyserNode > CreateAsync ( IJSRuntime jSRuntime , AudioContext context , AnalyserOptions ? options )
11
- => AnalyserNode . CreateAsync ( jSRuntime , context , options ) ;
11
+ => AnalyserNode . CreateAsync ( JSRuntime , AudioContext , options ) ;
12
12
13
13
[ Test ]
14
14
public async Task GetFloatFrequencyDataAsync_ShouldPopulateBuffer ( )
15
15
{
16
16
// Arrange
17
- await using AudioContext context = await GetAudioContextAsync ( ) ;
18
-
19
- await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , context ) ;
20
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
17
+ await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , AudioContext ) ;
18
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
21
19
await oscillator . ConnectAsync ( node ) ;
22
20
await oscillator . StartAsync ( ) ;
23
21
@@ -37,10 +35,8 @@ public async Task GetFloatFrequencyDataAsync_ShouldPopulateBuffer()
37
35
public async Task GetByteFrequencyDataAsync_ShouldPopulateBuffer ( )
38
36
{
39
37
// Arrange
40
- await using AudioContext context = await GetAudioContextAsync ( ) ;
41
-
42
- await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , context ) ;
43
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
38
+ await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , AudioContext ) ;
39
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
44
40
await oscillator . ConnectAsync ( node ) ;
45
41
await oscillator . StartAsync ( ) ;
46
42
@@ -59,10 +55,8 @@ public async Task GetByteFrequencyDataAsync_ShouldPopulateBuffer()
59
55
public async Task GetFloatTimeDomainDataAsync_ShouldPopulateBuffer ( )
60
56
{
61
57
// Arrange
62
- await using AudioContext context = await GetAudioContextAsync ( ) ;
63
-
64
- await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , context ) ;
65
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
58
+ await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , AudioContext ) ;
59
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
66
60
await oscillator . ConnectAsync ( node ) ;
67
61
await oscillator . StartAsync ( ) ;
68
62
@@ -81,10 +75,8 @@ public async Task GetFloatTimeDomainDataAsync_ShouldPopulateBuffer()
81
75
public async Task GetByteTimeDomainDataAsync_ShouldPopulateBuffer ( )
82
76
{
83
77
// Arrange
84
- await using AudioContext context = await GetAudioContextAsync ( ) ;
85
-
86
- await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , context ) ;
87
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
78
+ await using OscillatorNode oscillator = await OscillatorNode . CreateAsync ( JSRuntime , AudioContext ) ;
79
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
88
80
await oscillator . ConnectAsync ( node ) ;
89
81
await oscillator . StartAsync ( ) ;
90
82
@@ -106,13 +98,11 @@ public async Task GetByteTimeDomainDataAsync_ShouldPopulateBuffer()
106
98
public async Task GetFftSizeAsync_ShouldRetrieveFftSize ( ulong fftSize )
107
99
{
108
100
// Arrange
109
- await using AudioContext context = await GetAudioContextAsync ( ) ;
110
-
111
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
101
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
112
102
{
113
103
FftSize = fftSize
114
104
} ) ;
115
-
105
+
116
106
// Act
117
107
ulong readFftSize = await node . GetFftSizeAsync ( ) ;
118
108
@@ -126,9 +116,7 @@ public async Task GetFftSizeAsync_ShouldRetrieveFftSize(ulong fftSize)
126
116
public async Task SetFftSizeAsync_ShouldUpdateFftSize ( ulong fftSize )
127
117
{
128
118
// Arrange
129
- await using AudioContext context = await GetAudioContextAsync ( ) ;
130
-
131
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
119
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
132
120
133
121
// Act
134
122
await node . SetFftSizeAsync ( fftSize ) ;
@@ -144,9 +132,7 @@ public async Task SetFftSizeAsync_ShouldUpdateFftSize(ulong fftSize)
144
132
public async Task SetFftSizeAsync_ThrowsIndexSizeErrorException_WhenFftSizeIsOutOfBounds ( ulong fftSize )
145
133
{
146
134
// Arrange
147
- await using AudioContext context = await GetAudioContextAsync ( ) ;
148
-
149
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
135
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
150
136
151
137
// Act
152
138
Func < Task > action = async ( ) => await node . SetFftSizeAsync ( fftSize ) ;
@@ -161,9 +147,7 @@ public async Task SetFftSizeAsync_ThrowsIndexSizeErrorException_WhenFftSizeIsOut
161
147
public async Task SetFftSizeAsync_ThrowsIndexSizeErrorException_WhenFftSizeIsNotAPowerOfTwo ( ulong fftSize )
162
148
{
163
149
// Arrange
164
- await using AudioContext context = await GetAudioContextAsync ( ) ;
165
-
166
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
150
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
167
151
168
152
// Act
169
153
Func < Task > action = async ( ) => await node . SetFftSizeAsync ( fftSize ) ;
@@ -178,9 +162,7 @@ public async Task SetFftSizeAsync_ThrowsIndexSizeErrorException_WhenFftSizeIsNot
178
162
public async Task GetFrequencyBinCountAsync_ShouldRetrieveFrequncyBinCount ( ulong fftSize )
179
163
{
180
164
// Arrange
181
- await using AudioContext context = await GetAudioContextAsync ( ) ;
182
-
183
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
165
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
184
166
{
185
167
FftSize = fftSize
186
168
} ) ;
@@ -198,9 +180,7 @@ public async Task GetFrequencyBinCountAsync_ShouldRetrieveFrequncyBinCount(ulong
198
180
public async Task GetMaxDecibelsAsync_ShouldRetrieveMaxDecibels ( double maxDecibels )
199
181
{
200
182
// Arrange
201
- await using AudioContext context = await GetAudioContextAsync ( ) ;
202
-
203
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
183
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
204
184
{
205
185
MaxDecibels = maxDecibels
206
186
} ) ;
@@ -218,9 +198,7 @@ public async Task GetMaxDecibelsAsync_ShouldRetrieveMaxDecibels(double maxDecibe
218
198
public async Task SetMaxDecibelsAsync_ShouldUpdateMaxDecibels ( double maxDecibels )
219
199
{
220
200
// Arrange
221
- await using AudioContext context = await GetAudioContextAsync ( ) ;
222
-
223
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
201
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
224
202
225
203
// Act
226
204
await node . SetMaxDecibelsAsync ( maxDecibels ) ;
@@ -236,9 +214,7 @@ public async Task SetMaxDecibelsAsync_ShouldUpdateMaxDecibels(double maxDecibels
236
214
public async Task SetMaxDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetLowerThanMinDecibels ( double minDecibels , double maxDecibels )
237
215
{
238
216
// Arrange
239
- await using AudioContext context = await GetAudioContextAsync ( ) ;
240
-
241
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
217
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
242
218
{
243
219
MinDecibels = minDecibels ,
244
220
MaxDecibels = minDecibels + 1 ,
@@ -257,9 +233,7 @@ public async Task SetMaxDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetLower
257
233
public async Task GetMinDecibelsAsync_ShouldRetrieveMinDecibels ( double minDecibels )
258
234
{
259
235
// Arrange
260
- await using AudioContext context = await GetAudioContextAsync ( ) ;
261
-
262
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
236
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
263
237
{
264
238
MinDecibels = minDecibels
265
239
} ) ;
@@ -277,9 +251,7 @@ public async Task GetMinDecibelsAsync_ShouldRetrieveMinDecibels(double minDecibe
277
251
public async Task SetMinDecibelsAsync_ShouldUpdateMinDecibels ( double minDecibels )
278
252
{
279
253
// Arrange
280
- await using AudioContext context = await GetAudioContextAsync ( ) ;
281
-
282
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
254
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
283
255
284
256
// Act
285
257
await node . SetMinDecibelsAsync ( minDecibels ) ;
@@ -295,9 +267,7 @@ public async Task SetMinDecibelsAsync_ShouldUpdateMinDecibels(double minDecibels
295
267
public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetHigherThanMaxDecibels ( double minDecibels , double maxDecibels )
296
268
{
297
269
// Arrange
298
- await using AudioContext context = await GetAudioContextAsync ( ) ;
299
-
300
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
270
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
301
271
{
302
272
MinDecibels = maxDecibels - 1 ,
303
273
MaxDecibels = maxDecibels ,
@@ -316,9 +286,7 @@ public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetHighe
316
286
public async Task GetSmoothingTimeConstantAsync_ShouldRetrieveSmoothingTimeConstant ( double smoothingTimeConstant )
317
287
{
318
288
// Arrange
319
- await using AudioContext context = await GetAudioContextAsync ( ) ;
320
-
321
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context , new ( )
289
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext , new ( )
322
290
{
323
291
SmoothingTimeConstant = smoothingTimeConstant
324
292
} ) ;
@@ -336,9 +304,7 @@ public async Task GetSmoothingTimeConstantAsync_ShouldRetrieveSmoothingTimeConst
336
304
public async Task SetSmoothingTimeConstantAsync_ShouldUpdateSmoothingTimeConstant ( double smoothingTimeConstant )
337
305
{
338
306
// Arrange
339
- await using AudioContext context = await GetAudioContextAsync ( ) ;
340
-
341
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
307
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
342
308
343
309
// Act
344
310
await node . SetSmoothingTimeConstantAsync ( smoothingTimeConstant ) ;
@@ -354,9 +320,7 @@ public async Task SetSmoothingTimeConstantAsync_ShouldUpdateSmoothingTimeConstan
354
320
public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetToValueOutsideRange ( double smoothingTimeConstant )
355
321
{
356
322
// Arrange
357
- await using AudioContext context = await GetAudioContextAsync ( ) ;
358
-
359
- await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , context ) ;
323
+ await using AnalyserNode node = await AnalyserNode . CreateAsync ( JSRuntime , AudioContext ) ;
360
324
361
325
// Act
362
326
Func < Task > action = async ( ) => await node . SetSmoothingTimeConstantAsync ( smoothingTimeConstant ) ;
0 commit comments