所以我想在一段时间内改变我的for循环中的变量。在我的代码中,我的音频回调基本上运行以下伪代码:
int start = 0, target = 100;
for (int i = 0; i < frames; i++) {
[object makeSineWave];
[object useNum:start];
if (target > start) {
// Increase start over the span of time frame
}
}
我想要做的是在一个时间间隔内以对数刻度增加目标值的开始(假设1秒钟保持简单)。如何在音频回调的for循环中跟踪时间?
编辑:猜猜我正在尝试进行滤波器扫描...我猜它现在类似于正弦扫描我想到了吗?更多代码 -OSStatus RenderTone(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
// Get Audio Data
AudioData *data = (__bridge AudioData *)inRefCon;
static Float32 phs = 0, sub_phs = 0;
Float32 freq = data->freq;
// Calculate phases
Float32 phs_incr = 2 * M_PI * freq / data->srate;
Float32 sample;
// Buffers
Float32 *bufL = (Float32 *)ioData->mBuffers[0].mData;
Float32 *bufR = (Float32 *)ioData->mBuffers[1].mData;
// Start at 1 hz, target is 500 hz
int start = 1, target = 500;
// Generate Samples
for (UInt32 i = 0; i < inNumberFrames; i++) {
// Sine waveform
sample = sinf(phs);
sample = [data->filter processFilter:sample fc:start];
// change start here using current time?
// should not increase to target immediately, over span of 1 second
bufL[i] = buf[R] = sample;
// Increment phase
phs += phs_incr;
// Wrap phase
phs = wrapPhase(phs);
}
}
答案 0 :(得分:0)
似乎我通过查看CCRMA的STK找到了如何做到这一点......我希望我之前找到的很好的资源!