Prevent asserts when declaring > 8 channels
I’ve got a plug-in which declares > 8 channels (VST…); when initializing the AAX version of this plug-in, it asserts.
Fixed by not calling createDescriptor() nor descriptor.AddComponent() if channelConfigs[i][0] > 8 or channelConfigs[i][1] > 8.
Parameters depending on the number of channels
I’ve got a plug-in whose parameters (automatable or not, names, etc.) vary depending on the i/o channel count of the plug-in.
Until now, with the RTAS wrapper, the AddControl() calls are done after the setPlayConfigDetails() call, then the plug-in knows its i/o channel count before declaring parameters.
But in the AAX wrapper, (in EffectInit()), the parameters are declared before the setPlayConfigDetails() (in preparePlugin()).
Fixed by calling preparePlugin() before addBypassParameter() and addAudioProcessorParameters() rather than after these calls.
SampleRate caching
The samplerate does not change during the lifetime of a plug-in instance (from doc). Therefore we can create a member for that: AAX_CSampleRate JuceAAXProcessor::sampleRate and initialize it at the beginning of EffectInit: check (Controller()->GetSampleRate (&sampleRate));. Then, the getSampleRate() method can disappear and its callers can use the new sampleRate member.
buffersize
I had an issue with the buffer size: indeed with AAX no buffersize can be predicted, however I wanted the plug-in to be informed of the buffer size through prepareToPlay, instead of being stuck with 0 and having to manually call it inside of the processBlock & processBlockBypassed. So, I added an int JuceAAXProcessor::mBufferSize member, initialized in EffectInit() to its max possible value (1024), and altered in process(), before the processBlock & processBlockBypassed calls:
[code]{
if (mBufferSize != bufferSize)
{
mBufferSize = bufferSize;
pluginInstance->prepareToPlay(sampleRate, mBufferSize);
}
const ScopedLocked sl (pluginInstance->getCallbackLock());
if (bypassed)
pluginInstance->processBlockBypassed (buffer, midiBuffer);
else
[...]
}[/code]
(and change bufferSize to mBufferSize in the setPlayConfigDetails() call parameters).
Current position retrieving
I also had issues with the GetTimelineSelectionStartPosition() call, which does not always return a usable value, and even asserts because of the check (probably because of the threading scope of the caller of getCurrentPosition()). It can be fixed by having a fallback call:
if (! info.isPlaying)
{
AAX_Result ret = transport.GetTimelineSelectionStartPosition (&info.timeInSamples);
if (ret != AAX_SUCCESS)
check (transport.GetCurrentNativeSampleLocation (&info.timeInSamples));
}
else
check (transport.GetCurrentNativeSampleLocation (&info.timeInSamples));
Non-automatable parameters
Why are non-automatable parameters not declared to the host?