Equalizer: Fix applying equalizer presets on automatic track change

CQTexperiment
Christopher Snowhill 2022-01-19 01:23:59 -08:00
parent 31e5cd9337
commit f2feb3bcd7
4 changed files with 9 additions and 10 deletions

View File

@ -760,7 +760,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
[playlistController setCurrentEntry:pe]; [playlistController setCurrentEntry:pe];
equalizerApplyGenre([pe genre]); if (_eq)
equalizerApplyGenre(_eq, [pe genre]);
lastPosition = -10; lastPosition = -10;

View File

@ -13,6 +13,8 @@
extern void scale_by_volume(float * buffer, size_t count, float volume); extern void scale_by_volume(float * buffer, size_t count, float volume);
static NSString *CogPlaybackDidBeginNotficiation = @"CogPlaybackDidBeginNotficiation";
@implementation OutputCoreAudio @implementation OutputCoreAudio
static void fillBuffers(AudioBufferList *ioData, float * inbuffer, size_t count, size_t offset) static void fillBuffers(AudioBufferList *ioData, float * inbuffer, size_t count, size_t offset)
@ -158,7 +160,6 @@ static OSStatus renderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.outputDevice" options:0 context:NULL]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.outputDevice" options:0 context:NULL];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQenable" options:0 context:NULL]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQenable" options:0 context:NULL];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:0 context:NULL];
} }
return self; return self;
@ -184,10 +185,6 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
[self setEqualizerEnabled:enabled]; [self setEqualizerEnabled:enabled];
} }
else if ([keyPath isEqualToString:@"values.GraphicEQpreset"]) {
if (_eq)
[outputController refreshEqualizer:_eq];
}
} }
- (void)signalEndOfStream - (void)signalEndOfStream
@ -755,7 +752,6 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQenable"]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQenable"];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQpreset"];
} }
- (void)pause - (void)pause

View File

@ -14,7 +14,7 @@
#import <AudioUnit/AudioUnit.h> #import <AudioUnit/AudioUnit.h>
#import <AudioToolbox/AudioToolbox.h> #import <AudioToolbox/AudioToolbox.h>
void equalizerApplyGenre(NSString *genre); void equalizerApplyGenre(AudioUnit au, NSString *genre);
void equalizerLoadPreset(AudioUnit au); void equalizerLoadPreset(AudioUnit au);
void equalizerApplyPreset(AudioUnit au, NSDictionary * preset); void equalizerApplyPreset(AudioUnit au, NSDictionary * preset);

View File

@ -233,7 +233,7 @@ static void loadPresets()
CFRelease(appUrlRef); CFRelease(appUrlRef);
} }
void equalizerApplyGenre(NSString *genre) { void equalizerApplyGenre(AudioUnit au, NSString *genre) {
equalizerGenre = genre; equalizerGenre = genre;
if ([[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"GraphicEQtrackgenre"]) { if ([[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"GraphicEQtrackgenre"]) {
loadPresets(); loadPresets();
@ -264,6 +264,8 @@ void equalizerApplyGenre(NSString *genre) {
if (preset) { if (preset) {
NSInteger index = [equalizer_presets_processed indexOfObject:preset]; NSInteger index = [equalizer_presets_processed indexOfObject:preset];
[[[NSUserDefaultsController sharedUserDefaultsController] defaults] setInteger:index forKey:@"GraphicEQpreset"]; [[[NSUserDefaultsController sharedUserDefaultsController] defaults] setInteger:index forKey:@"GraphicEQpreset"];
equalizerApplyPreset(au, preset);
} }
} }
} }
@ -683,7 +685,7 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) {
[[[NSUserDefaultsController sharedUserDefaultsController] defaults] setBool:enabled forKey:@"GraphicEQtrackgenre"]; [[[NSUserDefaultsController sharedUserDefaultsController] defaults] setBool:enabled forKey:@"GraphicEQtrackgenre"];
equalizerApplyGenre(equalizerGenre); equalizerApplyGenre(au, equalizerGenre);
[self changePreset:presetButton]; [self changePreset:presetButton];
} }