【发布时间】:2012-03-06 02:24:40
【问题描述】:
我正在查看此example about sound generation on iOS,因为我需要做类似的事情,但有些部分我不明白,我希望有人可以帮助我。
在这部分代码中:
double theta_increment = 2.0 * M_PI * viewController->frequency / viewController->sampleRate;
// Generate the samples
for (UInt32 frame = 0; frame < inNumberFrames; frame++)
{
buffer[frame] = sin(theta) * amplitude;
theta += theta_increment;
if (theta > 2.0 * M_PI)
{
theta -= 2.0 * M_PI;
}
}
我不太明白theta += theta_increment; 部分的用途。对我来说,在 for 循环中做这样的事情更有意义:
buffer[frame] = sin(theta_increment * frame);
知道为什么那行不通吗?另外,我不知道这部分代码是干什么用的:if (theta > 2.0 * M_PI) 所以任何对此的解释也非常受欢迎。
【问题讨论】:
标签: ios audio sampling trigonometry