My Audio Unit v3 is trying to get the tempo from the host, but I'm a bit lost.
Apparently there is an AUHostMusicalContextBlock block property in my Audio Unit, but I can't figure out how to use it.
It's now part of my render block, but it crashes my plugin...
- (AUInternalRenderBlock)internalRenderBlock {
/
__block PluginKernel *plugin = &_kernel;
/
// get the tempo
double currentTempo;
if ( self.musicalContextBlock( ¤tTempo, NULL, NULL, NULL, NULL, NULL ) == YES ) {
plugin->handleTempoSetting(currentTempo);
}
// do the render process
Anyone already got this to work?
Thanks!
Bram
You're correct. This helped me solve it. Here's how I got it to work now:
A. declare an AUMusicalContextBlock variable in your implementation:
@implementation MyAudioUnit {
/
PluginKernel _kernel;
BufferedInputBus _inputBus;
AUHostMusicalContextBlock _musicalContext;
}
B. Capture it in allocateRenderResourcesAndReturnError:
//Tempo provided by host?
if (self.musicalContextBlock) { _musicalContext = self.musicalContextBlock; } else _musicalContext = nil;
C. Poll it in the renderblock:
// get tempo from host
double currentTempo;
if ( _musicalContext ) { // only use this if the host supports it...
if (_musicalContext( ¤tTempo, NULL, NULL, NULL, NULL, NULL ) ) {
plugin->handleTempoSetting(currentTempo);
}
}
I hope this helps someone!