@@ -394,6 +394,7 @@ mod tests {
394
394
}
395
395
}
396
396
397
+ /// A context to put abstracted methods commonly reused for tests.
397
398
struct TestContext {
398
399
processor : Processor ,
399
400
num_samples : usize ,
@@ -441,6 +442,7 @@ mod tests {
441
442
final_erl - initial_erl
442
443
}
443
444
445
+ /// Warm up the AEC and then measure ERL
444
446
fn measure_steady_state_performance (
445
447
& mut self ,
446
448
render_frame : & [ f32 ] ,
@@ -456,7 +458,7 @@ mod tests {
456
458
warmup_iterations,
457
459
) ;
458
460
459
- // Measure steady state
461
+ // Measure steady state and sum up the ERL reduction
460
462
let mut total_reduction = 0.0 ;
461
463
for _ in 0 ..measurement_count {
462
464
let mut test_capture = capture_frame. clone ( ) ;
@@ -608,9 +610,7 @@ mod tests {
608
610
/// Measures baseline echo cancellation performance using industry metrics.
609
611
///
610
612
/// Uses a pure sine wave to create ideal test conditions. Verifies the AEC
611
- /// achieves at least 18dB Echo Return Loss Enhancement (ERLE)
612
- ///
613
- /// Most echo cancellers are able to apply 18 to 35 dB ERLE.
613
+ /// achieves at least 18dB ERL.
614
614
#[ test]
615
615
fn test_echo_cancellation_effectiveness ( ) {
616
616
let mut context = TestContext :: new ( 1 ) ;
@@ -635,7 +635,6 @@ mod tests {
635
635
636
636
/// Verifies that different AEC configurations produce measurably different results.
637
637
///
638
- /// Compares Mobile vs Full modes under realistic conditions (noise + attenuation).
639
638
/// These modes should have distinct echo cancellation behaviors by design.
640
639
#[ test]
641
640
fn test_aec3_configuration_impact ( ) {
@@ -663,11 +662,80 @@ mod tests {
663
662
) ;
664
663
}
665
664
665
+ /// Verifies that unique AEC configurations produce measurably different results.
666
+ ///
667
+ /// This test is used to verify that a AEC3 configuration will apply and output
668
+ /// different results (in this case, 4dB of ERL).
669
+ #[ test]
670
+ fn test_aec3_configuration_tuning ( ) {
671
+ // Strong suppression configuration
672
+ let strong_config = Config {
673
+ echo_canceller : Some ( EchoCanceller :: default ( ) ) ,
674
+ aec3_config : Some ( EchoCanceller3Config {
675
+ suppressor : Suppressor {
676
+ dominant_nearend_detection : DominantNearendDetection {
677
+ enr_threshold : 0.75 ,
678
+ snr_threshold : 20.0 ,
679
+ ..Default :: default ( )
680
+ } ,
681
+ high_bands_suppression : HighBandsSuppression {
682
+ enr_threshold : 0.8 ,
683
+ max_gain_during_echo : 0.3 ,
684
+ ..Default :: default ( )
685
+ } ,
686
+ ..Default :: default ( )
687
+ } ,
688
+ ..Default :: default ( )
689
+ } ) ,
690
+ ..Default :: default ( )
691
+ } ;
692
+
693
+ // Light suppression configuration
694
+ let light_config = Config {
695
+ echo_canceller : Some ( EchoCanceller :: default ( ) ) ,
696
+ aec3_config : Some ( EchoCanceller3Config {
697
+ suppressor : Suppressor {
698
+ dominant_nearend_detection : DominantNearendDetection {
699
+ enr_threshold : 0.25 ,
700
+ snr_threshold : 30.0 ,
701
+ ..Default :: default ( )
702
+ } ,
703
+ high_bands_suppression : HighBandsSuppression {
704
+ enr_threshold : 1.2 ,
705
+ max_gain_during_echo : 0.8 ,
706
+ ..Default :: default ( )
707
+ } ,
708
+ ..Default :: default ( )
709
+ } ,
710
+ ..Default :: default ( )
711
+ } ) ,
712
+ ..Default :: default ( )
713
+ } ;
714
+
715
+ let mut context = TestContext :: new ( 2 ) ;
716
+ let render_frame = context. generate_sine_frame ( 440.0 ) ;
717
+
718
+ // Test strong suppression
719
+ context. processor . set_config ( strong_config) ;
720
+ let strong_reduction = context. measure_steady_state_performance ( & render_frame, 50 , 10 ) ;
721
+
722
+ // Test light suppression
723
+ context. processor . set_config ( light_config) ;
724
+ let light_reduction = context. measure_steady_state_performance ( & render_frame, 50 , 10 ) ;
725
+
726
+ // Verify the configurations produce measurably different results
727
+ assert ! (
728
+ strong_reduction > light_reduction + 3.0 ,
729
+ "Strong suppression ({:.1} dB) should achieve at least 3dB more reduction than light suppression ({:.1} dB)" ,
730
+ strong_reduction,
731
+ light_reduction
732
+ ) ;
733
+ }
734
+
666
735
/// Validates AEC configuration state management across processing modes.
667
736
///
668
737
/// Tests that AEC metrics and behavior remain consistent when switching
669
- /// between different modes (Full vs Mobile). Ensures configuration changes
670
- /// are properly applied and maintained during audio processing.
738
+ /// between different modes (Full vs Mobile).
671
739
#[ test]
672
740
fn test_aec3_configuration_behavior ( ) {
673
741
let mut context = TestContext :: new ( 2 ) ;
0 commit comments