Skip to content

Commit b141422

Browse files
committed
AudioParam end_time rounding, add TODO and link to discussion
1 parent 46a788f commit b141422

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/param.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,8 @@ impl AudioParamProcessor {
11101110

11111111
if infos.is_a_rate {
11121112
let start_index = self.buffer.len();
1113-
// we need to `round()` because if `end_time` is between two samples
1114-
// we actually want the sample before `end_time` to be computed
1113+
// TODO use ceil() or round() when `end_time` is between two samples?
1114+
// <https://github.com/orottier/web-audio-api-rs/pull/460>
11151115
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

@@ -1212,8 +1212,8 @@ impl AudioParamProcessor {
12121212

12131213
if infos.is_a_rate {
12141214
let start_index = self.buffer.len();
1215-
// we need to `round()` because if `end_time` is between two samples
1216-
// we actually want the sample before `end_time` to be computed
1215+
// TODO use ceil() or round() when `end_time` is between two samples?
1216+
// <https://github.com/orottier/web-audio-api-rs/pull/460>
12171217
let end_index = ((end_time - infos.block_time).max(0.) / infos.dt).round() as usize;
12181218
let end_index_clipped = end_index.min(infos.count);
12191219

@@ -1337,8 +1337,8 @@ impl AudioParamProcessor {
13371337

13381338
if infos.is_a_rate {
13391339
let start_index = self.buffer.len();
1340-
// we need to `round()` because if `end_time` is between two samples
1341-
// we actually want the sample before `end_time` to be computed
1340+
// TODO use ceil() or round() when `end_time` is between two samples?
1341+
// <https://github.com/orottier/web-audio-api-rs/pull/460>
13421342
let end_index = ((end_time - infos.block_time).max(0.) / infos.dt).round() as usize;
13431343
let end_index_clipped = end_index.min(infos.count);
13441344

@@ -1437,8 +1437,8 @@ impl AudioParamProcessor {
14371437

14381438
if infos.is_a_rate {
14391439
let start_index = self.buffer.len();
1440-
// we need to `round()` because if `end_time` is between two samples
1441-
// we actually want the sample before `end_time` to be computed
1440+
// TODO use ceil() or round() when `end_time` is between two samples?
1441+
// <https://github.com/orottier/web-audio-api-rs/pull/460>
14421442
let end_index = ((end_time - infos.block_time).max(0.) / infos.dt).round() as usize;
14431443
let end_index_clipped = end_index.min(infos.count);
14441444

0 commit comments

Comments
 (0)