@@ -1060,7 +1060,7 @@ impl AudioParamProcessor {
10601060
10611061 // fill buffer with current intrinsic value until `event.time`
10621062 if infos. is_a_rate {
1063- let end_index = ( ( time - infos. block_time ) . max ( 0. ) / infos. dt ) as usize ;
1063+ let end_index = ( ( time - infos. block_time ) . max ( 0. ) / infos. dt ) . round ( ) as usize ;
10641064 let end_index_clipped = end_index. min ( infos. count ) ;
10651065
10661066 for _ in self . buffer . len ( ) ..end_index_clipped {
@@ -1110,9 +1110,9 @@ impl AudioParamProcessor {
11101110
11111111 if infos. is_a_rate {
11121112 let start_index = self . buffer . len ( ) ;
1113- // we need to ` ceil()` because if `end_time` is between two samples
1114- // we actually want the sample before `end_time` to be computed
1115- let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . ceil ( ) as usize ;
1113+ // TODO use ceil() or round() when `end_time` is between two samples?
1114+ // <https://github.com/orottier/web-audio-api-rs/pull/460>
1115+ let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . round ( ) as usize ;
11161116 let end_index_clipped = end_index. min ( infos. count ) ;
11171117
11181118 // compute "real" value according to `t` then clamp it
@@ -1212,10 +1212,9 @@ impl AudioParamProcessor {
12121212
12131213 if infos. is_a_rate {
12141214 let start_index = self . buffer . len ( ) ;
1215- // we need to `ceil()` because if `end_time` is between two samples
1216- // we actually want the sample before `end_time` to be computed
1217- // @todo - more tests
1218- let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . ceil ( ) as usize ;
1215+ // TODO use ceil() or round() when `end_time` is between two samples?
1216+ // <https://github.com/orottier/web-audio-api-rs/pull/460>
1217+ let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . round ( ) as usize ;
12191218 let end_index_clipped = end_index. min ( infos. count ) ;
12201219
12211220 if end_index_clipped > start_index {
@@ -1338,10 +1337,9 @@ impl AudioParamProcessor {
13381337
13391338 if infos. is_a_rate {
13401339 let start_index = self . buffer . len ( ) ;
1341- // we need to `ceil()` because if `end_time` is between two samples
1342- // we actually want the sample before `end_time` to be computed
1343- // @todo - more tests
1344- let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . ceil ( ) as usize ;
1340+ // TODO use ceil() or round() when `end_time` is between two samples?
1341+ // <https://github.com/orottier/web-audio-api-rs/pull/460>
1342+ let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . round ( ) as usize ;
13451343 let end_index_clipped = end_index. min ( infos. count ) ;
13461344
13471345 if end_index_clipped > start_index {
@@ -1439,10 +1437,9 @@ impl AudioParamProcessor {
14391437
14401438 if infos. is_a_rate {
14411439 let start_index = self . buffer . len ( ) ;
1442- // we need to `ceil()` because if `end_time` is between two samples
1443- // we actually want the sample before `end_time` to be computed
1444- // @todo - more tests
1445- let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . ceil ( ) as usize ;
1440+ // TODO use ceil() or round() when `end_time` is between two samples?
1441+ // <https://github.com/orottier/web-audio-api-rs/pull/460>
1442+ let end_index = ( ( end_time - infos. block_time ) . max ( 0. ) / infos. dt ) . round ( ) as usize ;
14461443 let end_index_clipped = end_index. min ( infos. count ) ;
14471444
14481445 if end_index_clipped > start_index {
0 commit comments