3

我正在尝试将可视化器与正在使用生成器音频单元播放的音轨同步,子类型 audioFilePlayer 在 AUGraph 中。

我想使用 Core Audio 的 Clock API,但那里没有太多信息。我找到了这个,还有这个

有谁知道英文的好例子或这个 API 上的任何文档?

4

2 回答 2

2

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.

于 2011-08-24T18:49:13.733 回答
1

你看过这个网站吗: http: //www.cocoadev.com/index.pl?CoreAudioAndAudioUnitsTutorial

于 2011-08-19T06:33:56.620 回答