预定的音频单元参数事件被延迟

时间:2023-01-23 17:53:02

I have a music sequencing app for iOS that uses AUSamplers and effects audio units.

我有一个适用于iOS的音乐排序应用程序,它使用AUSamplers和效果音频单元。

The main playback loop is implemented using a render notify callback to send note on & off events to the samplers. I have notes successfully playing on beat by calculating buffer offsets and passing those to the MusicDeviceMIDIEvent calls.

主回放循环使用渲染通知回调实现,以将记录开关事件发送到采样器。我通过计算缓冲区偏移并将它们传递给MusicDeviceMIDIEvent调用,成功地在节拍上播放。

I'm now trying to implement an automation feature that lets you define changes to effect parameters over time. For an initial test, I'm repeatedly ramping the master mixer volume from 0 to 1 every bar (i.e. every 2 sec at 120 bpm).

我现在正在尝试实现一种自动化功能,该功能允许您定义随时间变化影响参数的更改。对于初始测试,我每次反复将主混音器音量从0升到1(即每2秒120 bpm)。

I'm using AudioUnitScheduleParameters to schedule immediate events, once per render callback. However, the actual volume change seems to be slightly delayed. This is very obvious at the beginning of a bar when the volume drops from 1 to 0; any notes scheduled at the beginning of that bar play briefly at full volume before dropping to 0 and ramping up as expected. I have verified that parameter event has been scheduled at a buffer offset before the note on event.

我正在使用AudioUnitScheduleParameters来安排立即事件,每次渲染回调一次。但是,实际的音量变化似乎略有延迟。当音量从1降到0时,这在条形开始时非常明显;在该栏开头安排的任何音符会在完全音量时短暂播放,然后降至0并按预期上升。我已经验证参数事件已经安排在事件注释之前的缓冲区偏移处。

My current workaround is to run the automation "ahead" of the audio, where I add some offset to the sample count used to calculate the current volume level. I've determined the offset just by experimenting, though, and I'm not confident in the solution.

我目前的解决方法是在音频的“前方”运行自动化,我在其中为用于计算当前音量级别的样本计数添加一些偏移量。不过,我已经通过实验确定了偏移量,而且我对解决方案没有信心。

Is there some reason I'm missing that would cause scheduled parameter events to be delayed?

是否有某些原因我错过了会导致计划参数事件被延迟?

1 个解决方案

#1


0  

2 buffer delays may be the time required to pass a parameter update message from a downstream audio unit callback to an upstream callback that has already been called and is currently running (already mid-process mixing incoming audio buffers)

2缓冲延迟可能是将参数更新消息从下游音频单元回调传递到已经被调用并且当前正在运行的上游回调所需的时间(已经在中间进程混合传入的音频缓冲区)

#1


0  

2 buffer delays may be the time required to pass a parameter update message from a downstream audio unit callback to an upstream callback that has already been called and is currently running (already mid-process mixing incoming audio buffers)

2缓冲延迟可能是将参数更新消息从下游音频单元回调传递到已经被调用并且当前正在运行的上游回调所需的时间(已经在中间进程混合传入的音频缓冲区)