@@ -4,84 +4,76 @@ use divan::Bencher;
4
4
use rodio:: Source ;
5
5
6
6
mod shared;
7
- use shared:: TestSource ;
7
+ use shared:: music_wav ;
8
8
9
9
fn main ( ) {
10
10
divan:: main ( ) ;
11
11
}
12
12
13
13
#[ divan:: bench]
14
14
fn 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
+ } )
23
21
}
24
22
25
23
#[ divan:: bench]
26
24
fn high_pass ( bencher : Bencher ) {
27
25
bencher
28
- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
26
+ . with_inputs ( || music_wav ( ) . to_f32s ( ) )
29
27
. bench_values ( |source| source. high_pass ( 200 ) . for_each ( divan:: black_box_drop) )
30
28
}
31
29
32
30
#[ divan:: bench]
33
31
fn 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
+ } )
41
37
}
42
38
43
39
#[ divan:: bench]
44
40
fn amplify ( bencher : Bencher ) {
45
41
bencher
46
- . with_inputs ( || TestSource :: music_wav ( ) . to_f32s ( ) )
42
+ . with_inputs ( || music_wav ( ) )
47
43
. bench_values ( |source| source. amplify ( 0.8 ) . for_each ( divan:: black_box_drop) )
48
44
}
49
45
50
46
#[ divan:: bench]
51
47
fn 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
+ } )
64
58
}
65
59
66
60
#[ cfg( feature = "experimental" ) ]
67
61
#[ divan:: bench]
68
62
fn 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
+ ) ;
79
71
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 ) ;
83
75
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
+ } )
87
79
}
0 commit comments