@@ -212,7 +212,7 @@ impl WaveShaperNode {
212
212
panic ! ( "InvalidStateError - cannot assign curve twice" ) ;
213
213
}
214
214
215
- self . registration . post_message ( clone) ;
215
+ self . registration . post_message ( Some ( clone) ) ;
216
216
}
217
217
218
218
/// Returns the `oversample` faactor of this node
@@ -363,9 +363,7 @@ struct WaveShaperRenderer {
363
363
/// oversample factor
364
364
oversample : OverSampleType ,
365
365
/// distortion curve
366
- curve : Vec < f32 > ,
367
- /// whether the distortion curve has been set
368
- curve_set : bool ,
366
+ curve : Option < Vec < f32 > > ,
369
367
/// Sample rate (equals to audio context sample rate)
370
368
sample_rate : usize ,
371
369
/// Number of channels used to build the up/down sampler X2
@@ -401,9 +399,7 @@ impl AudioProcessor for WaveShaperRenderer {
401
399
402
400
* output = input. clone ( ) ;
403
401
404
- if self . curve_set {
405
- let curve = & self . curve ;
406
-
402
+ if let Some ( curve) = & self . curve {
407
403
match self . oversample {
408
404
OverSampleType :: None => {
409
405
output. modify_channels ( |channel| {
@@ -496,10 +492,8 @@ impl AudioProcessor for WaveShaperRenderer {
496
492
return ;
497
493
}
498
494
499
- if let Some ( curve) = msg. downcast_mut :: < Vec < f32 > > ( ) {
495
+ if let Some ( curve) = msg. downcast_mut :: < Option < Vec < f32 > > > ( ) {
500
496
std:: mem:: swap ( & mut self . curve , curve) ;
501
- self . curve_set = true ;
502
-
503
497
return ;
504
498
}
505
499
@@ -531,8 +525,7 @@ impl WaveShaperRenderer {
531
525
532
526
Self {
533
527
oversample,
534
- curve : Vec :: with_capacity ( 0 ) ,
535
- curve_set : false ,
528
+ curve : None ,
536
529
sample_rate,
537
530
channels_x2,
538
531
channels_x4,
0 commit comments