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 | |
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
-rw-r--r-- | macosx/Controller.m | 6 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.xib | 232 | ||||
-rw-r--r-- | macosx/HBAudio.h | 2 | ||||
-rw-r--r-- | macosx/HBAudio.m | 35 | ||||
-rw-r--r-- | macosx/HBAudioController.m | 30 | ||||
-rw-r--r-- | macosx/HBQueueController.mm | 10 |
6 files changed, 284 insertions, 31 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 40121af1e..d3720ae7f 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -2405,9 +2405,10 @@ fWorkingCount = 0; [queueFileJob setObject:[NSString stringWithFormat:@"%d",[fPictureController deblock]] forKey:@"PictureDeblock"]; [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController grayscale]] forKey:@"VideoGrayScale"]; - + [self writeToActivityLog: "createQueueFileItem: Getting Audio from prepareAudioForQueueFileJob ..."]; /*Audio*/ - [fAudioDelegate prepareAudioForQueueFileJob: queueFileJob]; + [fAudioDelegate prepareAudioForQueueFileJob: queueFileJob]; + [self writeToActivityLog: "createQueueFileItem: Returned getting audio from prepareAudioForQueueFileJob"]; /* Subtitles*/ NSMutableArray *subtitlesArray = [[NSMutableArray alloc] initWithArray:[fSubtitlesDelegate getSubtitleArray] copyItems:YES]; @@ -3724,6 +3725,7 @@ bool one_burned = FALSE; /* We go ahead and assign values to our audio->out.<properties> */ audio->out.track = audio->in.track; audio->out.dynamic_range_compression = [[queueToApply objectForKey: [prefix stringByAppendingString: @"TrackDRCSlider"]] floatValue]; + audio->out.gain = [[queueToApply objectForKey: [prefix stringByAppendingString: @"TrackGainSlider"]] floatValue]; prefix = [NSString stringWithFormat: @"JobAudio%d", counter + 1]; audio->out.codec = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Encoder"]] intValue]; audio->out.mixdown = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Mixdown"]] intValue]; diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib index 66992fdc7..d76539541 100644 --- a/macosx/English.lproj/MainMenu.xib +++ b/macosx/English.lproj/MainMenu.xib @@ -12,7 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1478"/> + <integer value="2"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -112,7 +112,7 @@ <object class="NSTabViewItem" id="107038816"> <string key="NSIdentifier">1</string> <object class="NSView" key="NSView" id="1053078401"> - <reference key="NSNextResponder" ref="712502892"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -914,7 +914,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <string key="NSFrame">{{10, 25}, {714, 305}}</string> - <reference key="NSSuperview" ref="712502892"/> </object> <string key="NSLabel">Video</string> <reference key="NSColor" ref="242973447"/> @@ -923,7 +922,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSTabViewItem" id="157300012"> <string key="NSIdentifier">2</string> <object class="NSView" key="NSView" id="738554558"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder" ref="712502892"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -965,7 +964,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTableColumn" id="33212493"> <string key="NSIdentifier">track</string> - <double key="NSWidth">170</double> + <double key="NSWidth">159</double> <double key="NSMinWidth">40</double> <double key="NSMaxWidth">1000</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -1030,7 +1029,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <object class="NSTableColumn" id="200958136"> <string key="NSIdentifier">codec</string> - <double key="NSWidth">122</double> + <double key="NSWidth">121</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -1089,7 +1088,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <object class="NSTableColumn" id="590927656"> <string key="NSIdentifier">mixdown</string> - <double key="NSWidth">139</double> + <double key="NSWidth">130</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -1143,7 +1142,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <object class="NSTableColumn" id="1063255"> <string key="NSIdentifier">samplerate</string> - <double key="NSWidth">68</double> + <double key="NSWidth">63</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -1197,13 +1196,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <object class="NSTableColumn" id="596723553"> <string key="NSIdentifier">bitrate</string> - <double key="NSWidth">84</double> + <double key="NSWidth">66</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> - <string key="NSContents">Bitrate (kbps)</string> + <string key="NSContents">Bitrate</string> <reference key="NSSupport" ref="26"/> <reference key="NSBackgroundColor" ref="1045207104"/> <reference key="NSTextColor" ref="188451177"/> @@ -1249,9 +1248,74 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="792464451"/> </object> + <object class="NSTableColumn" id="7762140"> + <string key="NSIdentifier">gain</string> + <double key="NSWidth">32</double> + <double key="NSMinWidth">10</double> + <double key="NSMaxWidth">3.4028234663852886e+38</double> + <object class="NSTableHeaderCell" key="NSHeaderCell"> + <int key="NSCellFlags">75628096</int> + <int key="NSCellFlags2">134219776</int> + <string key="NSContents">Gain</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSBackgroundColor" ref="1045207104"/> + <reference key="NSTextColor" ref="188451177"/> + </object> + <object class="NSSliderCell" key="NSDataCell" id="723141526"> + <int key="NSCellFlags">-2079981824</int> + <int key="NSCellFlags2">131072</int> + <string key="NSContents"/> + <reference key="NSControlView" ref="792464451"/> + <double key="NSMaxValue">16</double> + <double key="NSMinValue">-5</double> + <double key="NSValue">0.0</double> + <double key="NSAltIncValue">0.0</double> + <int key="NSNumberOfTickMarks">21</int> + <int key="NSTickMarkPosition">1</int> + <bool key="NSAllowsTickMarkValuesOnly">YES</bool> + <bool key="NSVertical">NO</bool> + <int key="NSSliderType">1</int> + </object> + <int key="NSResizingMask">3</int> + <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> + <reference key="NSTableView" ref="792464451"/> + </object> + <object class="NSTableColumn" id="432964705"> + <string key="NSIdentifier">gainText</string> + <double key="NSWidth">18</double> + <double key="NSMinWidth">10</double> + <double key="NSMaxWidth">3.4028234663852886e+38</double> + <object class="NSTableHeaderCell" key="NSHeaderCell"> + <int key="NSCellFlags">75628096</int> + <int key="NSCellFlags2">2048</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="26"/> + <reference key="NSBackgroundColor" ref="1045207104"/> + <reference key="NSTextColor" ref="188451177"/> + </object> + <object class="NSTextFieldCell" key="NSDataCell" id="718953459"> + <int key="NSCellFlags">337772096</int> + <int key="NSCellFlags2">133120</int> + <string key="NSContents">Text Cell</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="792464451"/> + <object class="NSColor" key="NSBackgroundColor" id="355843302"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlBackgroundColor</string> + <reference key="NSColor" ref="458742033"/> + </object> + <reference key="NSTextColor" ref="701609070"/> + </object> + <int key="NSResizingMask">3</int> + <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> + <reference key="NSTableView" ref="792464451"/> + </object> <object class="NSTableColumn" id="393032802"> <string key="NSIdentifier">drc</string> - <double key="NSWidth">46</double> + <double key="NSWidth">35</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -1284,12 +1348,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <object class="NSTableColumn" id="581296833"> <string key="NSIdentifier">drctext</string> - <double key="NSWidth">28</double> + <double key="NSWidth">27</double> <double key="NSMinWidth">10</double> <double key="NSMaxWidth">3.4028229999999999e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> - <int key="NSCellFlags2">134219776</int> + <int key="NSCellFlags2">2048</int> <string key="NSContents"/> <reference key="NSSupport" ref="26"/> <reference key="NSBackgroundColor" ref="1045207104"/> @@ -1336,12 +1400,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="NSSuperview" ref="933946879"/> <reference key="NSNextKeyView" ref="792464451"/> <reference key="NSDocView" ref="792464451"/> - <object class="NSColor" key="NSBGColor" id="355843302"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">controlBackgroundColor</string> - <reference key="NSColor" ref="458742033"/> - </object> + <reference key="NSBGColor" ref="355843302"/> <int key="NScvFlags">4</int> </object> <object class="NSScroller" id="496546489"> @@ -1417,6 +1476,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <string key="NSFrame">{{10, 25}, {714, 305}}</string> + <reference key="NSSuperview" ref="712502892"/> </object> <string key="NSLabel">Audio</string> <reference key="NSColor" ref="242973447"/> @@ -2131,14 +2191,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="NSTabView" ref="712502892"/> </object> </object> - <reference key="NSSelectedTabViewItem" ref="107038816"/> + <reference key="NSSelectedTabViewItem" ref="157300012"/> <reference key="NSFont" ref="26"/> <int key="NSTvFlags">134217728</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1053078401"/> + <reference ref="738554558"/> </object> </object> <object class="NSTextField" id="586321835"> @@ -4594,6 +4654,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>bitRates.keyAudioBitrateName</string> <string>bitRate</string> <string>AC3Enabled</string> + <string>gain</string> + <string>PassThruEnabled</string> + <string>PassThruDisabled</string> </object> <bool key="NSEditable">YES</bool> <object class="_NSManagedProxy" key="_NSManagedProxy"/> @@ -6415,6 +6478,87 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <int key="connectionID">5828</int> </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: arrangedObjects.gain</string> + <reference key="source" ref="432964705"/> + <reference key="destination" ref="141316080"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="432964705"/> + <reference key="NSDestination" ref="141316080"/> + <string key="NSLabel">value: arrangedObjects.gain</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">arrangedObjects.gain</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">5875</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">enabled: arrangedObjects.PassThruDisabled</string> + <reference key="source" ref="432964705"/> + <reference key="destination" ref="141316080"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="432964705"/> + <reference key="NSDestination" ref="141316080"/> + <string key="NSLabel">enabled: arrangedObjects.PassThruDisabled</string> + <string key="NSBinding">enabled</string> + <string key="NSKeyPath">arrangedObjects.PassThruDisabled</string> + <object class="NSDictionary" key="NSOptions"> + <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> + <boolean value="NO" key="NS.object.0"/> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">5876</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: arrangedObjects.gain</string> + <reference key="source" ref="7762140"/> + <reference key="destination" ref="141316080"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="7762140"/> + <reference key="NSDestination" ref="141316080"/> + <string key="NSLabel">value: arrangedObjects.gain</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">arrangedObjects.gain</string> + <object class="NSDictionary" key="NSOptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSCreatesSortDescriptor</string> + <string>NSValidatesImmediately</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <boolean value="NO"/> + <boolean value="YES"/> + </object> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">5877</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">enabled: arrangedObjects.PassThruDisabled</string> + <reference key="source" ref="7762140"/> + <reference key="destination" ref="141316080"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="7762140"/> + <reference key="NSDestination" ref="141316080"/> + <string key="NSLabel">enabled: arrangedObjects.PassThruDisabled</string> + <string key="NSBinding">enabled</string> + <string key="NSKeyPath">arrangedObjects.PassThruDisabled</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">5878</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -8938,8 +9082,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="object" ref="577274772"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="933946879"/> <reference ref="883603583"/> + <reference ref="933946879"/> </object> <reference key="parent" ref="738554558"/> </object> @@ -8981,6 +9125,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference ref="590927656"/> <reference ref="200958136"/> <reference ref="33212493"/> + <reference ref="7762140"/> + <reference ref="432964705"/> </object> <reference key="parent" ref="933946879"/> </object> @@ -9239,6 +9385,34 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="object" ref="329026312"/> <reference key="parent" ref="888819828"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">5871</int> + <reference key="object" ref="7762140"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="723141526"/> + </object> + <reference key="parent" ref="792464451"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5872</int> + <reference key="object" ref="432964705"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="718953459"/> + </object> + <reference key="parent" ref="792464451"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5873</int> + <reference key="object" ref="718953459"/> + <reference key="parent" ref="432964705"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5874</int> + <reference key="object" ref="723141526"/> + <reference key="parent" ref="7762140"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -9876,6 +10050,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>5821.IBPluginDependency</string> <string>5822.IBPluginDependency</string> <string>5823.IBPluginDependency</string> + <string>5871.IBPluginDependency</string> + <string>5872.IBPluginDependency</string> + <string>5873.IBPluginDependency</string> + <string>5874.IBPluginDependency</string> <string>970.IBPluginDependency</string> <string>970.ImportedFromIB2</string> <string>971.IBPluginDependency</string> @@ -10154,10 +10332,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{-1006, 226}, {754, 556}}</string> + <string>{{147, 265}, {754, 556}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="YES"/> - <string>{{-1006, 226}, {754, 556}}</string> + <string>{{147, 265}, {754, 556}}</string> <integer value="1"/> <string>{{65, 541}, {760, 550}}</string> <boolean value="NO"/> @@ -10545,6 +10723,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> @@ -10568,7 +10750,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <nil key="sourceID"/> - <int key="maxID">5828</int> + <int key="maxID">5878</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/macosx/HBAudio.h b/macosx/HBAudio.h index 08d1b1903..6d243b965 100644 --- a/macosx/HBAudio.h +++ b/macosx/HBAudio.h @@ -27,6 +27,7 @@ extern NSString *keyAudioBitrate; NSDictionary *sampleRate; NSDictionary *bitRate; NSNumber *drc; + NSNumber *gain; NSNumber *videoContainerTag; HBAudioController *controller; NSMutableArray *codecs; @@ -40,6 +41,7 @@ extern NSString *keyAudioBitrate; @property (nonatomic, retain) NSDictionary *sampleRate; @property (nonatomic, retain) NSDictionary *bitRate; @property (nonatomic, retain) NSNumber *drc; +@property (nonatomic, retain) NSNumber *gain; @property (nonatomic, retain) NSNumber *videoContainerTag; @property (nonatomic, assign) HBAudioController *controller; 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]; } 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; } diff --git a/macosx/HBQueueController.mm b/macosx/HBQueueController.mm index a852bc2a1..2a0cefeb5 100644 --- a/macosx/HBQueueController.mm +++ b/macosx/HBQueueController.mm @@ -1063,19 +1063,23 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; NSString *base; NSString *detailString; NSNumber *drc; + NSNumber *gain; for (unsigned int i = 1; i <= ourMaximumNumberOfAudioTracks; i++) { base = [NSString stringWithFormat: @"Audio%d", i]; if (0 < [[item objectForKey: [base stringByAppendingString: @"Track"]] intValue]) { audioCodecSummary = [NSString stringWithFormat: @"%@", [item objectForKey: [base stringByAppendingString: @"Encoder"]]]; drc = [item objectForKey: [base stringByAppendingString: @"TrackDRCSlider"]]; - detailString = [NSString stringWithFormat: @"%@ Encoder: %@ Mixdown: %@ SampleRate: %@(khz) Bitrate: %@(kbps), DRC: %@", + gain = [item objectForKey: [base stringByAppendingString: @"TrackGainSlider"]]; + detailString = [NSString stringWithFormat: @"%@ Encoder: %@ Mixdown: %@ SampleRate: %@(khz) Bitrate: %@(kbps), DRC: %@, Gain: %@", [item objectForKey: [base stringByAppendingString: @"TrackDescription"]], [item objectForKey: [base stringByAppendingString: @"Encoder"]], [item objectForKey: [base stringByAppendingString: @"Mixdown"]], [item objectForKey: [base stringByAppendingString: @"Samplerate"]], [item objectForKey: [base stringByAppendingString: @"Bitrate"]], - (0.0 < [drc floatValue]) ? drc : @"Off" - ]; + (0.0 < [drc floatValue]) ? (NSObject *)drc : (NSObject *)@"Off", + (0.0 != [gain floatValue]) ? (NSObject *)gain : (NSObject *)@"Off" + ] + ; [audioDetails addObject: detailString]; } } |