Equalizer: Store custom presets on change
Store custom presets on value changes, on half second intervals, as the listener observes the user changing the settings. Fixes #222 Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
5184c8e48b
commit
e695e36599
1 changed files with 19 additions and 1 deletions
|
@ -596,10 +596,11 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
|
||||||
|
|
||||||
[self setFrameUsingName:@"GraphicEQposition"];
|
[self setFrameUsingName:@"GraphicEQposition"];
|
||||||
|
|
||||||
AUListenerCreateWithDispatchQueue(&listenerRef, 0.25, dispatch_get_main_queue(), ^void(void *inObject, const AudioUnitParameter *inParameter, AudioUnitParameterValue inValue) {
|
AUListenerCreateWithDispatchQueue(&listenerRef, 0.5, dispatch_get_main_queue(), ^void(void *inObject, const AudioUnitParameter *inParameter, AudioUnitParameterValue inValue) {
|
||||||
AUPluginWindow * _self = (__bridge AUPluginWindow *) inObject;
|
AUPluginWindow * _self = (__bridge AUPluginWindow *) inObject;
|
||||||
|
|
||||||
if (inParameter->mParameterID >= 0 && inParameter->mParameterID <= 31) {
|
if (inParameter->mParameterID >= 0 && inParameter->mParameterID <= 31) {
|
||||||
|
[_self savePresetToDefaults];
|
||||||
if ([_self->presetButton indexOfSelectedItem] != [equalizer_presets_processed count]) {
|
if ([_self->presetButton indexOfSelectedItem] != [equalizer_presets_processed count]) {
|
||||||
[_self->presetButton selectItemAtIndex:[equalizer_presets_processed count]];
|
[_self->presetButton selectItemAtIndex:[equalizer_presets_processed count]];
|
||||||
[_self changePreset:_self->presetButton];
|
[_self changePreset:_self->presetButton];
|
||||||
|
@ -733,5 +734,22 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)savePresetToDefaults
|
||||||
|
{
|
||||||
|
OSStatus err;
|
||||||
|
CFPropertyListRef classData;
|
||||||
|
UInt32 size;
|
||||||
|
|
||||||
|
size = sizeof(classData);
|
||||||
|
err = AudioUnitGetProperty(au, kAudioUnitProperty_ClassInfo, kAudioUnitScope_Global, 0, &classData, &size);
|
||||||
|
if (err == noErr)
|
||||||
|
{
|
||||||
|
CFPreferencesSetAppValue(CFSTR("GraphEQ_Preset"), classData, kCFPreferencesCurrentApplication);
|
||||||
|
CFRelease(classData);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue