AudioUnitHosting patch - remembering
AudioUnitHosting patch - remembering
- Subject: AudioUnitHosting patch - remembering
- From: Marc Poirier <email@hidden>
- Date: Fri, 18 Jun 2004 20:16:12 -0400 (EDT)
Here's yet another of my AudioUnitHosting patches, in case it's useful to
anyone else...
I use AUH a lot when first developing an AU because it launches so quickly
and shows you the selected AU immediately. But when I'm relaunching and
relaunching over and over, the one thing that slows me down is that AUH
doesn't remember my previous AU selection, and so I have to also reselect
my AU each time (though thanks to Panther now letting us type menu
selections, which I love, that's gone down to just 2 tabs and then typing
some of the name, but still it's a slow-down). So my patch changes AUH to
store a preferences file that contains the last chosen AU.
Note that, before CFPreferences will work with AUH, you need to edit the
project to give it a bundle identifier (I used
"com.apple.AudioUnitHosting").
Next, you want to add these 2 AudioUnitHosting class methods and 1
convenience function to AudioUnitHosting.cpp (and add prototypes of the 2
class methods to the AudioUnitHosting class definition in
AudioUnitHosting.h):
int AudioUnitHosting::RestoreAUSelectionFromPreferences()
{
OSType auType = CFPreferencesGetAppIntegerValue(CFSTR(kAUPresetTypeKey), kCFPreferencesCurrentApplication, NULL);
OSType auSubtype = CFPreferencesGetAppIntegerValue(CFSTR(kAUPresetSubtypeKey), kCFPreferencesCurrentApplication, NULL);
OSType auManu = CFPreferencesGetAppIntegerValue(CFSTR(kAUPresetManufacturerKey), kCFPreferencesCurrentApplication, NULL);
for (int i=0; i < mNumUnits; i++)
{
if ( (mCompDescs[i].componentType == auType)
&& (mCompDescs[i].componentSubType == auSubtype)
&& (mCompDescs[i].componentManufacturer == auManu) )
return i;
}
return 0;
}
void AUH_AddNumToPreferences(CFStringRef inPrefKey, SInt32 inValue)
{
CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
if (number != NULL)
{
CFPreferencesSetAppValue(inPrefKey, number, kCFPreferencesCurrentApplication);
CFRelease(number);
}
}
void AudioUnitHosting::UpdatePreferencesAUSelection()
{
if (mCurrentTargetDesc != NULL)
{
AUH_AddNumToPreferences(CFSTR(kAUPresetTypeKey), mCurrentTargetDesc->componentType);
AUH_AddNumToPreferences(CFSTR(kAUPresetSubtypeKey), mCurrentTargetDesc->componentSubType);
AUH_AddNumToPreferences(CFSTR(kAUPresetManufacturerKey), mCurrentTargetDesc->componentManufacturer);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
}
Then change the end of AudioUnitHosting::CompleteInit() where it looks
like this:
SetTargetUnit (mCompDescs[0]);
to be this:
int targetUnitIndex = RestoreAUSelectionFromPreferences();
SetTargetUnit (mCompDescs[targetUnitIndex]);
mAUMenu->SetValue(targetUnitIndex + 1);
Finally, at the very end of AudioUnitHosting::SetTargetUnit() (right
before the final "return true;" line), add this:
UpdatePreferencesAUSelection();
Marc
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.