summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudio.m
diff options
context:
space:
mode:
authordynaflash <[email protected]>2011-05-26 04:27:08 +0000
committerdynaflash <[email protected]>2011-05-26 04:27:08 +0000
commitc7bca57fa504cb0d7ead54c66b760ac7fcabb096 (patch)
tree08dc752ddde337f6fb238bb6c1147917b6f4f0a1 /macosx/HBAudio.m
parentc81154f023af608a50e01ccd8eb312d4d98a85ba (diff)
MacGui: Audio Gain Control initial implementation
- Adds a Circular Slider to implement gain from a range of -5 to +15 which is sane by any reasonable measure. - Note: the circular slider with this range puts the default of 0.0 at the three o'clock position on the slider which is kind of wonky. Any ideas to make it more intuitive are welcome. -The accompanying text field readout is left editable so values beyond the sliders range can be specified manually. - Gain is disabled for any passthru options obviously. - Though it has been in cli and lingui for some time, as a note my tests show that anything above +15 can get distorted quite easily. Of course that is open to opinion depending on source, I have yet to see a complaint about the volume of encoded audio being too high but we leave up to -5 there just for the corner cases. - Any existing presets not specifying gain will use a gain of 0.0 which means of course its unmodified. - Also as a sidenote takes care of blindjimmy's patch https://reviews.handbrake.fr/r/99/ as far as /macosx/HBQueueController.m git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4000 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudio.m')
-rw-r--r--macosx/HBAudio.m35
1 files changed, 35 insertions, 0 deletions
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index 7be16023f..0d0f42031 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -392,6 +392,7 @@ static NSMutableArray *masterBitRateArray = nil;
@synthesize sampleRate;
@synthesize bitRate;
@synthesize drc;
+@synthesize gain;
@synthesize videoContainerTag;
@synthesize controller;
@@ -417,6 +418,7 @@ static NSMutableArray *masterBitRateArray = nil;
[self setSampleRate: nil];
[self setBitRate: nil];
[self setDrc: nil];
+ [self setGain: nil];
[self setVideoContainerTag: nil];
[self setCodecs: nil];
[self setMixdowns: nil];
@@ -538,6 +540,22 @@ static NSMutableArray *masterBitRateArray = nil;
return retval;
}
+// Because we have indicated that the binding for the gain validates immediately we can implement the
+// key value binding method to ensure the gain stays in our accepted range.
+
+- (BOOL) validateGain: (id *) ioValue error: (NSError *) outError
+{
+ BOOL retval = YES;
+
+ if (nil != *ioValue) {
+ if (0.0 < [*ioValue floatValue] && 1.0 > [*ioValue floatValue]) {
+ *ioValue = [NSNumber numberWithFloat: 0.0];
+ }
+ }
+
+ return retval;
+}
+
#pragma mark -
#pragma mark Bindings Support
@@ -576,6 +594,20 @@ static NSMutableArray *masterBitRateArray = nil;
return retval;
}
+- (BOOL) PassThruDisabled
+
+{
+ BOOL retval = [self enabled];
+
+ if (YES == retval) {
+ int myCodecCodec = [[[self codec] objectForKey: keyAudioCodec] intValue];
+ if (HB_ACODEC_AC3_PASS == myCodecCodec || HB_ACODEC_DCA_PASS == myCodecCodec) {
+ retval = NO;
+ }
+ }
+ return retval;
+}
+
+ (NSSet *) keyPathsForValuesAffectingValueForKey: (NSString *) key
{
@@ -584,6 +616,9 @@ static NSMutableArray *masterBitRateArray = nil;
if (YES == [key isEqualToString: @"enabled"]) {
retval = [NSSet setWithObjects: @"track", nil];
}
+ else if (YES == [key isEqualToString: @"PassThruDisabled"]) {
+ retval = [NSSet setWithObjects: @"track", @"codec", nil];
+ }
else if (YES == [key isEqualToString: @"AC3Enabled"]) {
retval = [NSSet setWithObjects: @"track", @"codec", nil];
}