我正在尝试将可视化器与正在使用生成器音频单元播放的音轨同步,子类型 audioFilePlayer 在 AUGraph 中。
我想使用 Core Audio 的 Clock API,但那里没有太多信息。我找到了这个,还有这个。
有谁知道英文的好例子或这个 API 上的任何文档?
The answer is that there is almost no documentation, and the only reference I found was an Apple list serv stating that it's not a fully developed API.
Instead, if you need audio clock data, register a render callback with your generator audio unit like this.
AudioUnitAddRenderNotify(m_generatorAudioUnit, auRenderCallback, this);
OSStatus auRenderCallback (
void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData
)
{
AudioEngineModel* pAudioEngineModel= (AudioEngineModel*)inRefCon;
pAudioEngineModel->m_f64SampleTime= inTimeStamp->mSampleTime;
return noErr;
}
You can get seconds by dividing the mSampleTime by the sampleRate.
你看过这个网站吗: http: //www.cocoadev.com/index.pl?CoreAudioAndAudioUnitsTutorial