@@ -749,12 +749,13 @@ impl AudioProcessor for AudioBufferSourceRenderer {
749749 if playback_rate >= 0. {
750750 let start_playhead =
751751 actual_loop_start * sample_rate;
752- let start_index =
753- if start_playhead. floor ( ) == start_playhead {
754- start_playhead as usize
755- } else {
756- start_playhead as usize + 1
757- } ;
752+ let start_index = if start_playhead. floor ( )
753+ == start_playhead
754+ {
755+ start_playhead as usize
756+ } else {
757+ start_playhead as usize + 1
758+ } ;
758759
759760 buffer_channel[ start_index]
760761 } else {
@@ -1292,7 +1293,7 @@ mod tests {
12921293 expected[ 1 ] = 1. ;
12931294 expected[ 129 ] = 1. ;
12941295
1295- assert_float_eq ! ( channel[ ..] , expected[ ..] , abs_all <= 0. ) ;
1296+ assert_float_eq ! ( channel[ ..] , expected[ ..] , abs_all <= 1e-10 ) ;
12961297 }
12971298
12981299 #[ test]
@@ -1580,17 +1581,19 @@ mod tests {
15801581 #[ test]
15811582 fn test_loop_out_of_bounds ( ) {
15821583 [
1583- ( -2. , -1. ) ,
1584- ( -1. , -2. ) ,
1585- ( 0. , 0. ) ,
1586- ( -1. , 2. ) ,
1587- ( 2. , -1. ) ,
1588- ( 1. , 1. ) ,
1589- ( 2. , 3. ) ,
1590- ( 3. , 2. ) ,
1584+ // these will go in fast track
1585+ ( -2. , -1. , 0. ) ,
1586+ ( -1. , -2. , 0. ) ,
1587+ ( 0. , 0. , 0. ) ,
1588+ ( -1. , 2. , 0. ) ,
1589+ // these will go in slow track
1590+ ( 2. , -1. , 1e-10 ) ,
1591+ ( 1. , 1. , 1e-10 ) ,
1592+ ( 2. , 3. , 1e-10 ) ,
1593+ ( 3. , 2. , 1e-10 ) ,
15911594 ]
15921595 . iter ( )
1593- . for_each ( |( loop_start, loop_end) | {
1596+ . for_each ( |( loop_start, loop_end, error ) | {
15941597 let sample_rate = 48_000. ;
15951598 let length = sample_rate as usize / 10 ;
15961599 let mut context = OfflineAudioContext :: new ( 1 , length, sample_rate) ;
@@ -1625,7 +1628,7 @@ mod tests {
16251628 expected[ i] = 1. ;
16261629 }
16271630
1628- assert_float_eq ! ( channel[ ..] , expected[ ..] , abs_all <= 0. ) ;
1631+ assert_float_eq ! ( channel[ ..] , expected[ ..] , abs_all <= error ) ;
16291632 } ) ;
16301633 }
16311634
0 commit comments