节拍器精度算法数学
metronome precision algorithm maths
简而言之:我有一个每秒调用 44,100 次的方法。我想知道在我需要在第 13781.25 个方法调用中勾选声音的情况下该怎么做 - 即每分钟 192 次)。我可以选择四舍五入该数字并在第 13781 个方法调用处发出声音滴答声,这意味着我在第 0.25 次发出声音滴答声太早了。这相当于早了 0.00000566893424 秒。
在 100 个刻度之后,我确信延迟肯定会加起来。是否有任何聪明的解决方法可以跟踪延迟,当延迟超过某个点时,也许±一些数字来保持节拍再次正常进行?
这是我到目前为止下面的代码..
int counter; // used to track down the amount of times the method has been called
signalMethod(){
if(counter % ceil(2,646,000/10) == 0){ //the ceil function turns the decimal point into a whole number so it can be used for analysis. but this will cut off delay.. and over time im sure it will add up.. which will cause the beats to fluctuate...
playSound();
}
counter++;
}
您的问题只是"布雷森汉姆算法"问题的另一种变体,但您不是增加以特定斜率绘制的线的 Y 坐标(斜率将是节拍频率),而是发出即时报价。
关于布雷森纳姆算法的维基百科
相关文章:
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 基于ELO的团队匹配算法
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- C++选择排序算法中的逻辑错误
- 正在将csv文件读取为双精度矢量
- 有没有办法将谓词中的元素偏移量传递给 std 算法?
- C++A*算法并不总是在路径中具有目标节点
- 排序算法c++
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- 我可以信任表示整数的浮点或双精度来保持精度吗
- 如何在C++中的同一函数中使用字符串和双精度
- 特征::矩阵<双精度,1,3> 结构类型函数中的返回类型函数
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 算法问题:查找从堆栈中弹出的所有序列
- 在C++中标记双精度损失的算法不会标记正确的位置
- 节拍器精度算法数学
- 光线投射算法中的精度问题
- 检验算法中的数值精度
- 对于需要精度的定点,最好的乘法算法是什么