diff options
author | dynaflash <[email protected]> | 2011-05-26 04:27:08 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2011-05-26 04:27:08 +0000 |
commit | c7bca57fa504cb0d7ead54c66b760ac7fcabb096 (patch) | |
tree | 08dc752ddde337f6fb238bb6c1147917b6f4f0a1 /macosx/HBAudioController.m | |
parent | c81154f023af608a50e01ccd8eb312d4d98a85ba (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/HBAudioController.m')
-rw-r--r-- | macosx/HBAudioController.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 1a602b48e..074533b18 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -91,6 +91,17 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [aDict setObject: [[anAudio mixdown] objectForKey: keyAudioMixdownName] forKey: [prefix stringByAppendingString: @"Mixdown"]]; [aDict setObject: [[anAudio sampleRate] objectForKey: keyAudioSampleRateName] forKey: [prefix stringByAppendingString: @"Samplerate"]]; [aDict setObject: [[anAudio bitRate] objectForKey: keyAudioBitrateName] forKey: [prefix stringByAppendingString: @"Bitrate"]]; + + // output is not passthru so apply gain + if (HB_ACODEC_AC3_PASS != [[[anAudio codec] objectForKey: keyAudioCodec] intValue] && HB_ACODEC_DCA_PASS != [[[anAudio codec] objectForKey: keyAudioCodec] intValue]) + { + [aDict setObject: [anAudio gain] forKey: [prefix stringByAppendingString: @"TrackGainSlider"]]; + } + else + { + // output is passthru - the Gain dial is disabled so don't apply its value + [aDict setObject: [NSNumber numberWithInt:0] forKey: [prefix stringByAppendingString: @"TrackGainSlider"]]; + } if ((HB_ACODEC_AC3 == [[[anAudio track] objectForKey: keyAudioInputCodec] intValue]) && (HB_ACODEC_AC3_PASS != [[[anAudio codec] objectForKey: keyAudioCodec] intValue])) { @@ -143,6 +154,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; audio->out.bitrate = [[[anAudio bitRate] objectForKey: keyAudioBitrate] intValue]; audio->out.samplerate = [sampleRateToUse intValue]; audio->out.dynamic_range_compression = [[anAudio drc] floatValue]; + audio->out.gain = [[anAudio gain] floatValue]; hb_audio_add(aJob, audio); free(audio); @@ -168,6 +180,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [dict setObject: [[anAudio sampleRate] objectForKey: keyAudioSampleRateName] forKey: @"AudioSamplerate"]; [dict setObject: [[anAudio bitRate] objectForKey: keyAudioBitrateName] forKey: @"AudioBitrate"]; [dict setObject: [anAudio drc] forKey: @"AudioTrackDRCSlider"]; + [dict setObject: [anAudio gain] forKey: @"AudioTrackGainSlider"]; [anArray addObject: dict]; [dict release]; } @@ -201,6 +214,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [newAudio setSampleRateFromName: [aQueue objectForKey: [base stringByAppendingString: @"Samplerate"]]]; [newAudio setBitRateFromName: [aQueue objectForKey: [base stringByAppendingString: @"Bitrate"]]]; [newAudio setDrc: [aQueue objectForKey: [base stringByAppendingString: @"TrackDRCSlider"]]]; + [newAudio setGain: [aQueue objectForKey: [base stringByAppendingString: @"TrackGainSlider"]]]; [newAudio release]; } } @@ -230,6 +244,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [aPreset objectForKey: [base stringByAppendingString: @"Samplerate"]], @"AudioSamplerate", [aPreset objectForKey: [base stringByAppendingString: @"Bitrate"]], @"AudioBitrate", [aPreset objectForKey: [base stringByAppendingString: @"TrackDRCSlider"]], @"AudioTrackDRCSlider", + [aPreset objectForKey: [base stringByAppendingString: @"TrackGainSlider"]], @"AudioTrackGainSlider", nil]]; } } @@ -243,7 +258,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; { NSEnumerator *enumerator = [templateAudioArray objectEnumerator]; - NSDictionary *dict; + NSMutableDictionary *dict; NSString *key; int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; @@ -269,6 +284,16 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; fallenBack = YES; } } + // If our preset does not contain a drc or gain value set it to a default of 0.0 + if (![dict objectForKey: @"AudioTrackDRCSlider"]) + { + [dict setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"]; + } + if (![dict objectForKey: @"AudioTrackGainSlider"]) + { + [dict setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackGainSlider"]; + } + // If our preset wants us to support a codec that the track does not support, instead // of changing the codec we remove the audio instead. if (YES == [newAudio setCodecFromName: key]) { @@ -278,6 +303,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [newAudio setBitRateFromName: [dict objectForKey: @"AudioBitrate"]]; } [newAudio setDrc: [dict objectForKey: @"AudioTrackDRCSlider"]]; + [newAudio setGain: [dict objectForKey: @"AudioTrackGainSlider"]]; } else { [self removeObjectFromAudioArrayAtIndex: [self countOfAudioArray] - 1]; @@ -325,6 +351,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; @"Auto", @"AudioSamplerate", @"160", @"AudioBitrate", [NSNumber numberWithFloat: 0.0], @"AudioTrackDRCSlider", + [NSNumber numberWithFloat: 0.0], @"AudioTrackGainSlider", nil]], @"AudioList", nil] retain]; } return retval; @@ -403,6 +430,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [newAudio setVideoContainerTag: [self videoContainerTag]]; [newAudio setTrack: noneTrack]; [newAudio setDrc: [NSNumber numberWithFloat: 0.0]]; + [newAudio setGain: [NSNumber numberWithFloat: 0.0]]; [newAudio release]; return; } |