Equalizer: Fix the app switching presets in the background versus the open equalizer dialog

This should fix #198
CQTexperiment
Christopher Snowhill 2022-01-23 20:40:48 -08:00
parent fe4e17a4a0
commit f35c632f00
1 changed files with 11 additions and 3 deletions

View File

@ -614,7 +614,7 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
param.mParameterID = kGraphicEQParam_NumberOfBands; param.mParameterID = kGraphicEQParam_NumberOfBands;
AUListenerAddParameter(listenerRef, (__bridge void *)self, &param); AUListenerAddParameter(listenerRef, (__bridge void *)self, &param);
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:0 context:nil]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:nil];
// Time to hack the auView // Time to hack the auView
NSButton * flattenButton = nil; NSButton * flattenButton = nil;
@ -652,7 +652,7 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
if (listenerRef) { if (listenerRef) {
AUListenerDispose(listenerRef); AUListenerDispose(listenerRef);
} }
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQpreset"]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQpreset" context:nil];
} }
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
@ -663,7 +663,15 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
if (index < 0 || index > [equalizer_presets_processed count]) if (index < 0 || index > [equalizer_presets_processed count])
index = [equalizer_presets_processed count]; index = [equalizer_presets_processed count];
NSInteger selectedIndex = [presetButton indexOfSelectedItem];
// Don't want to get into an observe/modify loop here
if (selectedIndex != index)
{
[presetButton selectItemAtIndex:index]; [presetButton selectItemAtIndex:index];
[self changePreset:presetButton];
}
} }
} }