AU prepareToPlay() not called?


#1

My plugin runs fine under Win and Mac in RTAS and VST format. AU runs too, but it seems that prepareToPlay() doesn’t get called in AU. I tried two hosts, Reaper and Peak Pro.

Any idea what is going on?


#2

Having a quick look at the code, it certainly looks like it’ll be called… Have you tried putting breakpoints in the AU wrapper code?


#3

just tried that, it seems that in both hosts prepareToPlay() only gets called once during loading of the plugin.


#4

Well, it only needs to be called when the sample rate changes or there’s some other interruption to the flow. As long as it actually does get called before your process method is called, surely that’s ok?


#5

I think it should be called every time the stream starts, just like in the VST, where it does.

I looked at the wrapper code and specifically this function:

    ComponentResult Reset (AudioUnitScope inScope, AudioUnitElement inElement)
    {
        if (! prepared)
            prepareToPlay();

        if (juceFilter != 0)
            juceFilter->reset();

        return JuceAUBaseClass::Reset (inScope, inElement);
    }

It gets called every time I hit play, but the status of bool prepared prevent to run preparedToPlay()


#6

What do you mean by the stream ‘starting’? The stream’s stopping and starting has nothing to do with the host starting to play, even if some VST hosts choose to stop and start the stream when you do that. It’s perfectly reasonable for a host to start the stream once and leave it running continuously.

If you need to know when play is pressed, you should check the PlayHead object to see when it changes. Or use the reset() callback as a signal that you should reset your voices, etc.


#7

I mean start playback.

Why is Juce behaving differently between AU and VST? In VST it seems preparePlay() is being called while in AU reset() as is shown by setting a breakpoint.

I thought that the preparePlay() function was meant to be called before playback, like the documentation says, as it does in the VST hosts I have tested. Now I understand I have to use reset() instead? It is a bit confusing.


#8

Even that answer is ambiguous!

As far as the plugin is concerned, starting playback means that it’s starting to be given samples to process. That has nothing whatsoever to do with the user hitting ‘play’ or ‘stop’, and usually the host will actually keep the plugins playing when the transport is stopped.

There’s no difference between the AU and VST code in this respect, so anything you’re seeing is probably just differences between the hosts. If a VST host chooses to leave the audio running when stopped, then it’d also appear to only call prepareToPlay once.


#9

Even that answer is ambiguous!

As far as the plugin is concerned, starting playback means that it’s starting to be given samples to process. That has nothing whatsoever to do with the user hitting ‘play’ or ‘stop’, and usually the host will actually keep the plugins playing when the transport is stopped.[/quote]

I understand, this is what I see in some of the hosts.

They keep it running, but they do call releaseResources and the preparePlay again directly after a stop as far as I saw. The difference between AU and VST is that the preparePlay() in AU it is prevented by the boolean if it was prepared once and reset gets called instead.

Anyway, as I understand the preparePlay() method in Juce is called if something is changed, like the samplerate. If I need to know if play was hit I have to find out with the PlayHead object.