Equalizer: Add option to toggle the equalizer on or off
parent
c8057e1037
commit
87c771c67c
|
@ -60,6 +60,7 @@ NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
|
||||||
{
|
{
|
||||||
NSDictionary *defaultsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
|
NSDictionary *defaultsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithDouble:100.0], @"volume",
|
[NSNumber numberWithDouble:100.0], @"volume",
|
||||||
|
[NSNumber numberWithBool:NO], @"GraphicEQenable",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
|
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
BOOL started;
|
BOOL started;
|
||||||
BOOL paused;
|
BOOL paused;
|
||||||
|
|
||||||
|
BOOL eqEnabled;
|
||||||
|
|
||||||
atomic_long bytesRendered;
|
atomic_long bytesRendered;
|
||||||
|
|
||||||
BOOL listenerapplied;
|
BOOL listenerapplied;
|
||||||
|
@ -62,4 +64,6 @@
|
||||||
|
|
||||||
- (void)setVolume:(double) v;
|
- (void)setVolume:(double) v;
|
||||||
|
|
||||||
|
- (void)setEqualizerEnabled:(BOOL)enabled;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -153,6 +153,7 @@ static OSStatus renderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
readSemaphore = [[Semaphore alloc] init];
|
readSemaphore = [[Semaphore alloc] init];
|
||||||
|
|
||||||
[[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];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -173,6 +174,11 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
|
|
||||||
[self setOutputDeviceWithDeviceDict:device];
|
[self setOutputDeviceWithDeviceDict:device];
|
||||||
}
|
}
|
||||||
|
else if ([keyPath isEqualToString:@"values.GraphicEQenable"]) {
|
||||||
|
BOOL enabled = [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"GraphicEQenable"] boolValue];
|
||||||
|
|
||||||
|
[self setEqualizerEnabled:enabled];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)signalEndOfStream
|
- (void)signalEndOfStream
|
||||||
|
@ -443,6 +449,9 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
NSError *err;
|
NSError *err;
|
||||||
AVAudioFormat *renderFormat;
|
AVAudioFormat *renderFormat;
|
||||||
|
|
||||||
|
[outputController incrementAmountPlayed:[[outputController buffer] bufferedLength]];
|
||||||
|
[[outputController buffer] empty];
|
||||||
|
|
||||||
_deviceFormat = format;
|
_deviceFormat = format;
|
||||||
deviceFormat = *(format.streamDescription);
|
deviceFormat = *(format.streamDescription);
|
||||||
|
|
||||||
|
@ -506,6 +515,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
AudioUnitReset (_eq, kAudioUnitScope_Output, 0);
|
AudioUnitReset (_eq, kAudioUnitScope_Output, 0);
|
||||||
|
|
||||||
AudioUnitReset (_eq, kAudioUnitScope_Global, 0);
|
AudioUnitReset (_eq, kAudioUnitScope_Global, 0);
|
||||||
|
|
||||||
|
eqEnabled = [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"GraphicEQenable"] boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -569,6 +580,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
|
|
||||||
__block AudioUnit eq = _eq;
|
__block AudioUnit eq = _eq;
|
||||||
__block AudioStreamBasicDescription *format = &deviceFormat;
|
__block AudioStreamBasicDescription *format = &deviceFormat;
|
||||||
|
__block BOOL *eqEnabled = &self->eqEnabled;
|
||||||
|
__block void *refCon = (__bridge void *)self;
|
||||||
|
|
||||||
_au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags * _Nonnull actionFlags, const AudioTimeStamp * _Nonnull timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList * _Nonnull inputData)
|
_au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags * _Nonnull actionFlags, const AudioTimeStamp * _Nonnull timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList * _Nonnull inputData)
|
||||||
{
|
{
|
||||||
|
@ -590,7 +603,12 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
ioData->mBuffers[i].mDataByteSize = frameCount * sizeof(float);
|
ioData->mBuffers[i].mDataByteSize = frameCount * sizeof(float);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus ret = AudioUnitRender(eq, actionFlags, timestamp, (UInt32) inputBusNumber, frameCount, ioData);
|
OSStatus ret;
|
||||||
|
|
||||||
|
if (*eqEnabled)
|
||||||
|
ret = AudioUnitRender(eq, actionFlags, timestamp, (UInt32) inputBusNumber, frameCount, ioData);
|
||||||
|
else
|
||||||
|
ret = renderCallback(refCon, actionFlags, timestamp, (UInt32) inputBusNumber, frameCount, ioData);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -649,6 +667,19 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
volume = v * 0.01f;
|
volume = v * 0.01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setEqualizerEnabled:(BOOL)enabled
|
||||||
|
{
|
||||||
|
if (enabled && !eqEnabled) {
|
||||||
|
if (_eq) {
|
||||||
|
AudioUnitReset (_eq, kAudioUnitScope_Input, 0);
|
||||||
|
AudioUnitReset (_eq, kAudioUnitScope_Output, 0);
|
||||||
|
AudioUnitReset (_eq, kAudioUnitScope_Global, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eqEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)start
|
- (void)start
|
||||||
{
|
{
|
||||||
[self threadEntry:nil];
|
[self threadEntry:nil];
|
||||||
|
@ -694,6 +725,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
[self stop];
|
[self stop];
|
||||||
|
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"];
|
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"];
|
||||||
|
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQenable"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pause
|
- (void)pause
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19162" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19162"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
|
@ -24,99 +24,99 @@
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
||||||
<rect key="frame" x="69" y="438" width="37" height="14"/>
|
<rect key="frame" x="60" y="438" width="45" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Artist:" id="10">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Artist:" id="10">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="11">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="11">
|
||||||
<rect key="frame" x="63" y="416" width="43" height="14"/>
|
<rect key="frame" x="62" y="416" width="43" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Album:" id="12">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Album:" id="12">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="13">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="13">
|
||||||
<rect key="frame" x="68" y="372" width="38" height="14"/>
|
<rect key="frame" x="67" y="372" width="38" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Track:" id="14">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Track:" id="14">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="15">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="15">
|
||||||
<rect key="frame" x="61" y="350" width="45" height="14"/>
|
<rect key="frame" x="60" y="350" width="45" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Length:" id="16">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Length:" id="16">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||||
<rect key="frame" x="74" y="328" width="32" height="14"/>
|
<rect key="frame" x="73" y="328" width="32" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Year:" id="18">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Year:" id="18">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="19">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="19">
|
||||||
<rect key="frame" x="66" y="306" width="40" height="14"/>
|
<rect key="frame" x="65" y="306" width="40" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Genre:" id="20">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Genre:" id="20">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="21">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="21">
|
||||||
<rect key="frame" x="33" y="262" width="73" height="14"/>
|
<rect key="frame" x="32" y="262" width="73" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Sample Rate:" id="22">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Sample Rate:" id="22">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="27">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="27">
|
||||||
<rect key="frame" x="49" y="240" width="57" height="14"/>
|
<rect key="frame" x="48" y="240" width="57" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Channels:" id="28">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Channels:" id="28">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="29">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="29">
|
||||||
<rect key="frame" x="64" y="218" width="42" height="14"/>
|
<rect key="frame" x="63" y="218" width="42" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bitrate:" id="32">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Bitrate:" id="32">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="30">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="30">
|
||||||
<rect key="frame" x="17" y="196" width="89" height="14"/>
|
<rect key="frame" x="15" y="196" width="90" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bits Per Sample:" id="31">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Bits Per Sample:" id="31">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="23">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="23">
|
||||||
<rect key="frame" x="74" y="394" width="32" height="14"/>
|
<rect key="frame" x="73" y="394" width="32" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Title:" id="24">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Title:" id="24">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
@ -260,9 +260,9 @@
|
||||||
</connections>
|
</connections>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QPg-Mb-Urn">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QPg-Mb-Urn">
|
||||||
<rect key="frame" x="66" y="174" width="40" height="14"/>
|
<rect key="frame" x="60" y="174" width="45" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Codec:" id="cbq-TT-CZX">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Codec:" id="cbq-TT-CZX">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
@ -281,9 +281,9 @@
|
||||||
</connections>
|
</connections>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="84">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="84">
|
||||||
<rect key="frame" x="50" y="284" width="56" height="14"/>
|
<rect key="frame" x="49" y="284" width="56" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Filename:" id="85">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Filename:" id="85">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
@ -316,16 +316,16 @@
|
||||||
</connections>
|
</connections>
|
||||||
</imageView>
|
</imageView>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vB6-9J-5qg">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vB6-9J-5qg">
|
||||||
<rect key="frame" x="33" y="460" width="72" height="14"/>
|
<rect key="frame" x="18" y="460" width="87" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Album Artist:" id="LFJ-QQ-gGr">
|
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Album Artist:" id="LFJ-QQ-gGr">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cj0-Tw-xpq" customClass="ToolTipTextField">
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cj0-Tw-xpq" customClass="ToolTipTextField">
|
||||||
<rect key="frame" x="112" y="460" width="170" height="14"/>
|
<rect key="frame" x="113" y="460" width="170" height="14"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" title="N/A" id="B8w-o8-ZBw">
|
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" title="N/A" id="B8w-o8-ZBw">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<windowStyleMask key="styleMask" titled="YES"/>
|
<windowStyleMask key="styleMask" titled="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="70" y="875" width="506" height="100"/>
|
<rect key="contentRect" x="70" y="875" width="506" height="100"/>
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
|
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
|
||||||
<value key="minSize" type="size" width="104.43300000000001" height="50"/>
|
<value key="minSize" type="size" width="104.43300000000001" height="50"/>
|
||||||
<view key="contentView" id="6">
|
<view key="contentView" id="6">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="506" height="100"/>
|
<rect key="frame" x="0.0" y="0.0" width="506" height="100"/>
|
||||||
|
|
|
@ -16,19 +16,9 @@
|
||||||
@interface AUPluginUI : NSObject
|
@interface AUPluginUI : NSObject
|
||||||
{
|
{
|
||||||
AudioUnit au;
|
AudioUnit au;
|
||||||
int prefheight;
|
|
||||||
int prefwidth;
|
|
||||||
|
|
||||||
BOOL windowOpen;
|
BOOL windowOpen;
|
||||||
|
|
||||||
BOOL resizable;
|
|
||||||
int min_width;
|
|
||||||
int min_height;
|
|
||||||
int req_width;
|
|
||||||
int req_height;
|
|
||||||
int alo_width;
|
|
||||||
int alo_height;
|
|
||||||
|
|
||||||
/* Cocoa */
|
/* Cocoa */
|
||||||
|
|
||||||
NSWindow* cocoa_window;
|
NSWindow* cocoa_window;
|
||||||
|
@ -40,12 +30,18 @@
|
||||||
- (void) dealloc;
|
- (void) dealloc;
|
||||||
|
|
||||||
- (BOOL) isOpen;
|
- (BOOL) isOpen;
|
||||||
- (BOOL) isForeground;
|
|
||||||
|
|
||||||
- (void) bringToFront;
|
- (void) bringToFront;
|
||||||
|
|
||||||
- (NSInteger) windowNumber;
|
@end
|
||||||
|
|
||||||
|
@interface AUPluginWindow : NSWindow<NSSplitViewDelegate> {
|
||||||
|
NSView *topView;
|
||||||
|
NSView *auView;
|
||||||
|
NSSplitView *splitView;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithAuView:(NSView *)_auView bringToFront:(BOOL)front relativeToWindow:(NSInteger)window;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,20 +19,12 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AUPluginUI
|
@implementation AUPluginUI
|
||||||
|
|
||||||
- (id) initWithSampler:(AudioUnit)_au bringToFront:(BOOL)front orWindowNumber:(NSInteger)window
|
- (id) initWithSampler:(AudioUnit)_au bringToFront:(BOOL)front orWindowNumber:(NSInteger)window
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
au = _au;
|
au = _au;
|
||||||
resizable = NO;
|
|
||||||
min_width = 0;
|
|
||||||
min_height = 0;
|
|
||||||
req_width = 0;
|
|
||||||
req_height = 0;
|
|
||||||
alo_width = 0;
|
|
||||||
alo_height = 0;
|
|
||||||
|
|
||||||
windowOpen = NO;
|
windowOpen = NO;
|
||||||
|
|
||||||
|
@ -46,33 +38,15 @@
|
||||||
|
|
||||||
if (au_view)
|
if (au_view)
|
||||||
{
|
{
|
||||||
cocoa_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, req_width, req_height)
|
cocoa_window = [[AUPluginWindow alloc] initWithAuView:au_view bringToFront:front relativeToWindow:window];
|
||||||
styleMask:(NSWindowStyleMaskTitled |
|
|
||||||
NSWindowStyleMaskClosable)
|
|
||||||
backing:NSBackingStoreBuffered
|
|
||||||
defer:NO];
|
|
||||||
|
|
||||||
[cocoa_window setAutodisplay:YES];
|
|
||||||
[cocoa_window setOneShot:YES];
|
|
||||||
|
|
||||||
[cocoa_window setContentView:au_view];
|
|
||||||
|
|
||||||
if (front)
|
|
||||||
{
|
|
||||||
[cocoa_window orderFront:cocoa_window];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
[cocoa_window orderWindow:NSWindowBelow relativeTo:window];
|
|
||||||
|
|
||||||
[cocoa_window setReleasedWhenClosed:NO];
|
|
||||||
|
|
||||||
[cocoa_window setFrameUsingName:@"EqualizerWindowPosition"];
|
|
||||||
|
|
||||||
|
if (cocoa_window) {
|
||||||
windowOpen = YES;
|
windowOpen = YES;
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowClosed:) name:NSWindowWillCloseNotification object:cocoa_window];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowClosed:) name:NSWindowWillCloseNotification object:cocoa_window];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -99,14 +73,9 @@
|
||||||
[cocoa_window orderFront:cocoa_window];
|
[cocoa_window orderFront:cocoa_window];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger) windowNumber
|
|
||||||
{
|
|
||||||
return cocoa_window.windowNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)windowClosed:(NSNotification*)notification
|
- (void)windowClosed:(NSNotification*)notification
|
||||||
{
|
{
|
||||||
[cocoa_window saveFrameUsingName:@"EqualizerWindowPosition"];
|
[cocoa_window saveFrameUsingName:@"GraphicEQ.position"];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
windowOpen = NO;
|
windowOpen = NO;
|
||||||
}
|
}
|
||||||
|
@ -221,13 +190,89 @@
|
||||||
[(AUGenericView *)au_view setShowsExpertParameters:1];
|
[(AUGenericView *)au_view setShowsExpertParameters:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the initial size of the new AU View's frame
|
|
||||||
NSRect frame = [au_view frame];
|
|
||||||
min_width = req_width = CGRectGetWidth(NSRectToCGRect(frame));
|
|
||||||
min_height = req_height = CGRectGetHeight(NSRectToCGRect(frame));
|
|
||||||
resizable = [au_view autoresizingMask];
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation AUPluginWindow
|
||||||
|
- (id) initWithAuView:(NSView *)_auView bringToFront:(BOOL)front relativeToWindow:(NSInteger)window
|
||||||
|
{
|
||||||
|
NSRect frame = [_auView frame];
|
||||||
|
CGFloat req_width = frame.size.width;
|
||||||
|
CGFloat req_height = frame.size.height;
|
||||||
|
//BOOL resizable = [_auView autoresizingMask];
|
||||||
|
|
||||||
|
self = [super initWithContentRect:NSMakeRect(0, 0, req_width, req_height + 32)
|
||||||
|
styleMask:(NSWindowStyleMaskTitled |
|
||||||
|
NSWindowStyleMaskClosable)
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:NO];
|
||||||
|
if (self)
|
||||||
|
{
|
||||||
|
auView = _auView;
|
||||||
|
|
||||||
|
[self setAutodisplay:YES];
|
||||||
|
[self setOneShot:YES];
|
||||||
|
|
||||||
|
if (front)
|
||||||
|
{
|
||||||
|
[self orderFront:self];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self orderWindow:NSWindowBelow relativeTo:window];
|
||||||
|
|
||||||
|
[self setReleasedWhenClosed:NO];
|
||||||
|
|
||||||
|
NSRect topRect = NSMakeRect(0, 0, req_width, 32);
|
||||||
|
|
||||||
|
topView = [[NSView alloc] initWithFrame:topRect];
|
||||||
|
|
||||||
|
NSRect topFrame = NSMakeRect(0, req_height, req_width, req_height);
|
||||||
|
NSRect newFrame = NSMakeRect(0, 0, req_width, topRect.size.height);
|
||||||
|
|
||||||
|
topRect = NSMakeRect(0, 0, req_width, req_height + topRect.size.height);
|
||||||
|
|
||||||
|
splitView = [[NSSplitView alloc] initWithFrame:topRect];
|
||||||
|
|
||||||
|
[splitView setSubviews:[NSArray arrayWithObjects:topView, auView, nil]];
|
||||||
|
|
||||||
|
[self setContentView:splitView];
|
||||||
|
|
||||||
|
[topView setFrame:topFrame];
|
||||||
|
[auView setFrame:newFrame];
|
||||||
|
|
||||||
|
BOOL enabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"GraphicEQenable"];
|
||||||
|
|
||||||
|
NSButton *button = [NSButton checkboxWithTitle:@"Enabled" target:self action:@selector(toggleEnable:)];
|
||||||
|
[button setState:enabled ? NSControlStateValueOn : NSControlStateValueOff];
|
||||||
|
|
||||||
|
NSRect buttonFrame = [button frame];
|
||||||
|
buttonFrame.origin = NSMakePoint( 18, 4 );
|
||||||
|
[button setFrame:buttonFrame];
|
||||||
|
|
||||||
|
[topView addSubview:button];
|
||||||
|
|
||||||
|
[splitView adjustSubviews];
|
||||||
|
|
||||||
|
[splitView setDelegate:self];
|
||||||
|
|
||||||
|
[self setFrameUsingName:@"GraphicEQ.position"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex
|
||||||
|
{
|
||||||
|
return NSZeroRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) toggleEnable:(id)sender
|
||||||
|
{
|
||||||
|
BOOL enabled = [sender state] == NSControlStateValueOn;
|
||||||
|
|
||||||
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"GraphicEQenable"];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue