Re: AudioUnitV3 effect and "maximumFramesToRender"
Re: AudioUnitV3 effect and "maximumFramesToRender"
- Subject: Re: AudioUnitV3 effect and "maximumFramesToRender"
- From: Dave O'Neill <email@hidden>
- Date: Fri, 14 Dec 2018 13:38:29 -0800
The host is responsible for pointing all of the audioUnits' buffers where
they need to read from write and to, passing events, call each unit's
render block, and copying buffers to the hardware abstraction.
AVAudioEngine does all of this. Think of it as a host helper, filing many
of the host's roles, one of which is setting each audio unit's
maximumFramesToRender before calling allocateRenderResourcesAndReturnError
on it. So in your audio unit subclass you should
override allocateRenderResourcesAndReturnError, read the
maximumFramesToRender property and prepare for that many frames.
You can't guarantee that you'll get any specific buffer sizes during each
render call, just <= max. If you need fixed sizes or x2 sized buffers,
you'll have to add latency and cache enough data to be ready to render
maximumFramesToRender. The bad news is that AVAudioEngine sets max frames
to something like 4096 frames, even though you can request the hardware to
call a much smaller size when actually rendering.
Dave
On Fri, Dec 14, 2018 at 11:50 AM Waverly Edwards <email@hidden> wrote:
> I am running within my own applicaition using avaudioengine. I am not
> using an external host.
>
>
>
>
>
> *From:* Coreaudio-api [mailto:coreaudio-api-bounces+wedwards=
> email@hidden] *On Behalf Of *Paul Davis
> *Sent:* Friday, December 14, 2018 2:36 PM
> *To:* Howard Moon <email@hidden>
> *Cc:* CoreAudio API <email@hidden>
> *Subject:* Re: AudioUnitV3 effect and "maximumFramesToRender"
>
>
>
> Waverly .... what host are you running in?
>
>
>
> On Fri, Dec 14, 2018 at 2:04 PM Howard Moon <email@hidden>
> wrote:
>
> I think you guys missed the point. He's setting the maximum to 256, but
> he's getting 512. It's fine if he gets LESS than the max, but he's asking
> why he's getting MORE than the maximum!
>
>
>
> On Fri, Dec 14, 2018 at 11:02 AM Paul Davis <email@hidden>
> wrote:
>
> It's not even always macOS or iOS. The host can choose to "subdivide" a
> given block of audio into smaller blocks for its own reasons (automation is
> a common reason). The audio hardware may run with a 512 sample buffer, but
> your plugin may get called to process (12,193,307) samples just because the
> host decides to do it that way.
>
>
>
> As a plugin, you cannot control the buffer size chosen by the host (and
> ultimately by the user). You can tell the host that you need a minimum, but
> the host may then refuse to load/run the plugin.
>
>
>
>
>
> On Fri, Dec 14, 2018 at 1:34 PM Martin Man <email@hidden> wrote:
>
> From my experience this is the missing block you are asking for, a pity
> it’s not a part of the iOS/macOS SDKs
>
>
>
> https://github.com/michaeltyson/TPCircularBuffer
>
>
>
> In short, you can’t force macOS or iOS to work at fixed number of frames,
> be prepared to handle random numbers not bigger then
> maxNumberOfFramesPerSlice. It does happen and will happen to you that you
> will get asked for a number you never seen before :)
>
>
>
> Ciao,
>
> Martin
>
>
>
> On 14 Dec 2018, at 19:25, Waverly Edwards <email@hidden> wrote:
>
>
>
> >> The host determines how many frames are pulled.
>
>
>
> How is the “host” defined. I thought the host was defined as my
> application or audio unit.
>
> It would seem to me, if the host and the system were synonymous, it would
> be more clear to just say “system” instead of host.
>
>
>
> >> This can differ for each call.
>
>
>
> I can accept it, since your source is not always going to be a multiple of
> the buffer length, so you’re bound to a shortage but that’s the only case
> that comes to mind.
>
>
>
> >> This variable is just to tell the host what the maximum number is that
> can be processed at a time.
>
>
>
> I’m struggling with this idea because I have set the maximum value to 256
> and the number of frames pulled is 512. If I set the maximum value to 1024
> and I get 512, I’m not happy at all but that’s understandable based on this
> definition.
>
>
>
> Is there an alternative way to make the number of frames pulled a constant
> value?
>
>
>
> *From:* Bram Bos [mailto:email@hidden <email@hidden>]
> *Sent:* Friday, December 14, 2018 12:06 PM
> *To:* email@hidden
> *Cc:* email@hidden
> *Subject:* Re: AudioUnitV3 effect and "maximumFramesToRender"
>
>
>
> The host determines how many frames are pulled. This can differ for each
> call. This variable is just to tell the host what the maximum number is
> that can be processed at a time.
>
>
> On 14 Dec 2018, at 17:48, Waverly Edwards <email@hidden> wrote:
>
> init(componentDescription: AudioComponentDescription,options:
> AudioComponentInstantiationOptions = [])
>
>
>
> I created an AudioUnitV3 effect and I set the variable
> "maximumFramesToRender" within the above method. The effect does work but
> the system overwrites this value with 512 frames, leaving me with no way to
> alter how many frames are pulled.
>
>
>
>
> https://developer.apple.com/documentation/audiotoolbox/auaudiounit/1387654-maximumframestorender
>
>
>
> The documentation states you must be set before resources are allocated
> and I do so in my init. What else must I do in order to change how many
> frames are pulled in a single cycle.
>
>
>
> Does anyone have advice on this matter.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden