简而言之: 我有一个方法被称为44,100次/秒。我想知道如果需要在13781.25号方法调用中打勾声音,那么该怎么办 - 这是每分钟192次)。我可以选择将这个数字四舍五入,并在13781st方法调用中使声音打勾,这意味着我会让声音在第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++;
}
音频应用中这样做的一个标准方法是建立一个双T,最初为零。每个样本,将t增加1.0/44100.0,并检查t>(60.0/192.0)。如果是这样,请调用节拍器功能并将t减60.0/192.0。 t一旦减少,剩下的金额将按照第二段描述的方式执行,以防止随着时间的推移而出现错误。 –