Missing kAudioUnitProperty_MaximumFramesPerSlice

Hey Jules, it appears kAudioUnitProperty_MaximumFramesPerSlice needs to be set when initializing AudioUnits. It solves the issue of AudioUnits stopping working (and other odd behaviour) when the buffer size is too large (that number being dependent on plugin it seems). The problem was identified by the return code of AudioUnitRender, which was kAudioUnitErr_TooManyFramesToProcess.

Here is an Apple Technical Article regarding kAudioUnitProperty_MaximumFramesPerSlice: http://developer.apple.com/library/mac/#qa/qa1533/_index.html

Below is how I’ve implemented a basic fix. It’s tested on OSX 10.7 with the latest JUCE.

In juce_AudioUnitPluginFormat.mm, AudioUnitPluginInstance::prepareToPlay

            for (int i = 0; i < numOutputBusses; ++i)
                AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SampleRate, kAudioUnitScope_Output, i, &sampleRateOut, &sampleRateSize);

                if (sampleRateOut != sr)
                    AudioUnitSetProperty (audioUnit, kAudioUnitProperty_SampleRate, kAudioUnitScope_Output, i, &sr, sizeof (sr));
            //THE FIX
           AudioUnitSetProperty(audioUnit, kAudioUnitProperty_MaximumFramesPerSlice,
                                 kAudioUnitScope_Global, 0, & estimatedSamplesPerBlock, sizeof(estimatedSamplesPerBlock));

            setPlayConfigDetails (numInputBusChannels * numInputBusses,
                                  numOutputBusChannels * numOutputBusses,
                                  sampleRate_, estimatedSamplesPerBlock);

Nice one, thanks!