in Source/AUMIDIBase.cpp [125:194]
OSStatus AUMIDIBase::DelegateSetProperty(AudioUnitPropertyID inID, AudioUnitScope inScope,
AudioUnitElement inElement, const void* inData, UInt32 inDataSize)
{
(void)inScope;
(void)inElement;
(void)inData;
(void)inDataSize;
OSStatus result = noErr;
switch (inID) {
#if AUSDK_HAVE_MIDI_MAPPING
case kAudioUnitProperty_AddParameterMIDIMapping: {
AUSDK_Require(mMIDIMapper, kAudioUnitErr_InvalidProperty);
AUSDK_Require(inScope == kAudioUnitScope_Global, kAudioUnitErr_InvalidScope);
AUSDK_Require(inElement == 0, kAudioUnitErr_InvalidElement);
const auto* const maps = static_cast<const AUParameterMIDIMapping*>(inData);
mMIDIMapper->AddParameterMapping(
maps, (inDataSize / sizeof(AUParameterMIDIMapping)), mAUBaseInstance);
mAUBaseInstance.PropertyChanged(
kAudioUnitProperty_AllParameterMIDIMappings, kAudioUnitScope_Global, 0);
result = noErr;
break;
}
case kAudioUnitProperty_RemoveParameterMIDIMapping: {
AUSDK_Require(mMIDIMapper, kAudioUnitErr_InvalidProperty);
AUSDK_Require(inScope == kAudioUnitScope_Global, kAudioUnitErr_InvalidScope);
AUSDK_Require(inElement == 0, kAudioUnitErr_InvalidElement);
const auto* const maps = static_cast<const AUParameterMIDIMapping*>(inData);
bool didChange = false;
mMIDIMapper->RemoveParameterMapping(
maps, (inDataSize / sizeof(AUParameterMIDIMapping)), didChange);
if (didChange) {
mAUBaseInstance.PropertyChanged(
kAudioUnitProperty_AllParameterMIDIMappings, kAudioUnitScope_Global, 0);
}
result = noErr;
break;
}
case kAudioUnitProperty_HotMapParameterMIDIMapping: {
AUSDK_Require(mMIDIMapper, kAudioUnitErr_InvalidProperty);
AUSDK_Require(inScope == kAudioUnitScope_Global, kAudioUnitErr_InvalidScope);
AUSDK_Require(inElement == 0, kAudioUnitErr_InvalidElement);
const auto& map = *static_cast<const AUParameterMIDIMapping*>(inData);
mMIDIMapper->SetHotMapping(map);
result = noErr;
break;
}
case kAudioUnitProperty_AllParameterMIDIMappings: {
AUSDK_Require(mMIDIMapper, kAudioUnitErr_InvalidProperty);
AUSDK_Require(inScope == kAudioUnitScope_Global, kAudioUnitErr_InvalidScope);
AUSDK_Require(inElement == 0, kAudioUnitErr_InvalidElement);
const auto* const mappings = static_cast<const AUParameterMIDIMapping*>(inData);
mMIDIMapper->ReplaceAllMaps(
mappings, (inDataSize / sizeof(AUParameterMIDIMapping)), mAUBaseInstance);
result = noErr;
break;
}
#endif
default:
result = kAudioUnitErr_InvalidProperty;
break;
}
return result;
}