I've a application that output chunk of buffers that represent 1/96 of beat (lets call them pulses), using a Sample Rate of 44100.
At constant 120 BPM, I have 2 beat per second, so 22050 samples per beat, thus 229,6875 samples per pulse. These are the first values I got from the application:
0
230
459
689
919
1148
1378
1608
1838
2067
2297
2527
2756
2986
3216
3445
3675
3905
4134
4364
4594
4823
5053
5283
5512
5742
5972
6202
6431
Notice two things:
At constant 190 BPM instead, I have 145,0657895 samples per pulse. First values I got:
0
145
290
435
580
725
870
1015
1161
1306
1451
1596
1741
1886
2031
2176
2321
2466
2611
2756
2901
3046
3191
3337
3482
3627
3772
3917
4062
As before, Round half to Even, and the distance now can be 145 or 146.
Well, nothing hard till here. Now! If I start the application at 120 BPM and after 25 pulse I switch to 190 BPM, I got a weird distance after the switch:
0
230 // distance 230
459 // distance 229
689 // distance 230
919 // distance 230
1148 // distance 229
1378 // distance 230
1608 // distance 230
1838 // distance 230
2067 // distance 229
2297 // distance 230
2527 // distance 230
2756 // distance 229
2986 // distance 230
3216 // distance 230
3445 // distance 229
3675 // distance 230
3905 // distance 230
4134 // distance 229
4364 // distance 230
4594 // distance 230
4823 // distance 229
5053 // distance 230
5283 // distance 230
5512 // distance 229
5742 // distance 230 - here I switch
5887 // distance 145
6032 // distance 145
6177 // distance 145
6322 // distance 145
6468 // distance 146
Why that last 146 values (6468)?
In your opinion, due to "what" the distance between prev buffer is 146 and not 145? Tried to round next/prev at each iterations, but it seems correct to get 145 as value there. Instead its 146.
It's confusing all my counters. Any clues?
229.6875 * 25 = 5742.1875
145.0657895 * 5 = 725.3289475
5742.1875 + 725.3289475 = 6467.5164475 rounding to 6468
Note that underlying calculations are made in exact (merely float) numbers