@@ -4,84 +4,76 @@ use divan::Bencher;
44use rodio:: Source ;
55
66mod shared;
7- use shared:: TestSource ;
7+ use shared:: music_wav ;
88
99fn main ( ) {
1010 divan:: main ( ) ;
1111}
1212
1313#[ divan:: bench]
1414fn reverb ( bencher : Bencher ) {
15- bencher
16- . with_inputs ( || TestSource :: music_wav ( ) )
17- . bench_values ( |source| {
18- source
19- . buffered ( )
20- . reverb ( Duration :: from_secs_f32 ( 0.05 ) , 0.3 )
21- . for_each ( divan:: black_box_drop)
22- } )
15+ bencher. with_inputs ( || music_wav ( ) ) . bench_values ( |source| {
16+ source
17+ . buffered ( )
18+ . reverb ( Duration :: from_secs_f32 ( 0.05 ) , 0.3 )
19+ . for_each ( divan:: black_box_drop)
20+ } )
2321}
2422
2523#[ divan:: bench]
2624fn high_pass ( bencher : Bencher ) {
2725 bencher
28- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
26+ . with_inputs ( || music_wav ( ) . to_f32s ( ) )
2927 . bench_values ( |source| source. high_pass ( 200 ) . for_each ( divan:: black_box_drop) )
3028}
3129
3230#[ divan:: bench]
3331fn fade_out ( bencher : Bencher ) {
34- bencher
35- . with_inputs ( || TestSource :: music_wav ( ) )
36- . bench_values ( |source| {
37- source
38- . fade_out ( Duration :: from_secs ( 5 ) )
39- . for_each ( divan:: black_box_drop)
40- } )
32+ bencher. with_inputs ( || music_wav ( ) ) . bench_values ( |source| {
33+ source
34+ . fade_out ( Duration :: from_secs ( 5 ) )
35+ . for_each ( divan:: black_box_drop)
36+ } )
4137}
4238
4339#[ divan:: bench]
4440fn amplify ( bencher : Bencher ) {
4541 bencher
46- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
42+ . with_inputs ( || music_wav ( ) )
4743 . bench_values ( |source| source. amplify ( 0.8 ) . for_each ( divan:: black_box_drop) )
4844}
4945
5046#[ divan:: bench]
5147fn agc_enabled ( bencher : Bencher ) {
52- bencher
53- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
54- . bench_values ( |source| {
55- source
56- . automatic_gain_control (
57- 1.0 , // target_level
58- 4.0 , // attack_time (in seconds)
59- 0.005 , // release_time (in seconds)
60- 5.0 , // absolute_max_gain
61- )
62- . for_each ( divan:: black_box_drop)
63- } )
48+ bencher. with_inputs ( || music_wav ( ) ) . bench_values ( |source| {
49+ source
50+ . automatic_gain_control (
51+ 1.0 , // target_level
52+ 4.0 , // attack_time (in seconds)
53+ 0.005 , // release_time (in seconds)
54+ 5.0 , // absolute_max_gain
55+ )
56+ . for_each ( divan:: black_box_drop)
57+ } )
6458}
6559
6660#[ cfg( feature = "experimental" ) ]
6761#[ divan:: bench]
6862fn agc_disabled ( bencher : Bencher ) {
69- bencher
70- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
71- . bench_values ( |source| {
72- // Create the AGC source
73- let amplified_source = source. automatic_gain_control (
74- 1.0 , // target_level
75- 4.0 , // attack_time (in seconds)
76- 0.005 , // release_time (in seconds)
77- 5.0 , // absolute_max_gain
78- ) ;
63+ bencher. with_inputs ( || music_wav ( ) ) . bench_values ( |source| {
64+ // Create the AGC source
65+ let amplified_source = source. automatic_gain_control (
66+ 1.0 , // target_level
67+ 4.0 , // attack_time (in seconds)
68+ 0.005 , // release_time (in seconds)
69+ 5.0 , // absolute_max_gain
70+ ) ;
7971
80- // Get the control handle and disable AGC
81- let agc_control = amplified_source. get_agc_control ( ) ;
82- agc_control. store ( false , std:: sync:: atomic:: Ordering :: Relaxed ) ;
72+ // Get the control handle and disable AGC
73+ let agc_control = amplified_source. get_agc_control ( ) ;
74+ agc_control. store ( false , std:: sync:: atomic:: Ordering :: Relaxed ) ;
8375
84- // Process the audio stream with AGC disabled
85- amplified_source. for_each ( divan:: black_box_drop)
86- } )
76+ // Process the audio stream with AGC disabled
77+ amplified_source. for_each ( divan:: black_box_drop)
78+ } )
8779}
0 commit comments