@@ -1060,7 +1060,7 @@ impl AudioParamProcessor {
1060
1060
1061
1061
// fill buffer with current intrinsic value until `event.time`
1062
1062
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 ;
1064
1064
let end_index_clipped = end_index. min ( infos. count ) ;
1065
1065
1066
1066
for _ in self . buffer . len ( ) ..end_index_clipped {
@@ -1110,9 +1110,9 @@ impl AudioParamProcessor {
1110
1110
1111
1111
if infos. is_a_rate {
1112
1112
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 ;
1116
1116
let end_index_clipped = end_index. min ( infos. count ) ;
1117
1117
1118
1118
// compute "real" value according to `t` then clamp it
@@ -1212,10 +1212,9 @@ impl AudioParamProcessor {
1212
1212
1213
1213
if infos. is_a_rate {
1214
1214
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 ;
1219
1218
let end_index_clipped = end_index. min ( infos. count ) ;
1220
1219
1221
1220
if end_index_clipped > start_index {
@@ -1338,10 +1337,9 @@ impl AudioParamProcessor {
1338
1337
1339
1338
if infos. is_a_rate {
1340
1339
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 ;
1345
1343
let end_index_clipped = end_index. min ( infos. count ) ;
1346
1344
1347
1345
if end_index_clipped > start_index {
@@ -1439,10 +1437,9 @@ impl AudioParamProcessor {
1439
1437
1440
1438
if infos. is_a_rate {
1441
1439
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 ;
1446
1443
let end_index_clipped = end_index. min ( infos. count ) ;
1447
1444
1448
1445
if end_index_clipped > start_index {
0 commit comments