blob: fba1f7cb625f7f49b94d1bd2b0bec83d7c1b27db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* Advanced Audio.cs
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
namespace Handbrake.ToolWindows
{
using System;
using System.Globalization;
using System.Windows.Forms;
using HandBrake.ApplicationServices.Model.Encoding;
/// <summary>
/// Advanced Audio Panel
/// </summary>
public partial class AdvancedAudio : Form
{
// Culture Info
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
/// <summary>
/// The Advanced Audio Panel
/// </summary>
public AdvancedAudio()
{
InitializeComponent();
}
private AudioTrack track;
/// <summary>
/// Gets or sets the Audio Track to alter.
/// </summary>
public AudioTrack Track
{
get
{
return this.track;
}
set
{
this.track = value;
if (this.track == null)
{
return;
}
// Set the Gain Control.
if (track.Gain == 0)
{
gainTrackBar.Value = 21; // The centre point
}
else if (track.Gain > 0)
{
gainTrackBar.Value = 21 + track.Gain;
}
else if (track.Gain < 0)
{
gainTrackBar.Value = 20 - Math.Abs(track.Gain);
}
lbl_GainValue.Text = string.Format("{0} dB", track.Gain);
// Set the DRC Control
double drcValue = 0;
int drcCalculated;
if (track.DRC != 0)
drcValue = ((track.DRC * 10) + 1) - 10;
int.TryParse(drcValue.ToString(Culture), out drcCalculated);
tb_drc.Value = drcCalculated;
lbl_drc.Text = track.DRC.ToString();
tb_drc.Enabled = track.TrackDisplay.Contains("(AC3)");
}
}
/// <summary>
/// Close the window
/// </summary>
/// <param name="sender">The Sender</param>
/// <param name="e">The Event Args</param>
private void btn_close_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
/// <summary>
/// Set the Gain value for the audio track.
/// </summary>
/// <param name="sender">The Sender</param>
/// <param name="e">The Event Arg</param>
private void gainTrackBar_Scroll(object sender, EventArgs e)
{
// Figure out the Gain.
int gain = 0;
if (gainTrackBar.Value == 21)
{
gain = 0;
}
else if (gainTrackBar.Value > 21)
{
gain = gainTrackBar.Value - 21;
}
else if (gainTrackBar.Value < 21)
{
gain = (-20 + gainTrackBar.Value);
}
lbl_GainValue.Text = string.Format("{0} dB", gain);
// Figure out the DRC Value
double drcValue = 0;
int drcCalculated;
if (track.DRC != 0)
drcValue = ((track.DRC * 10) + 1) - 10;
int.TryParse(drcValue.ToString(Culture), out drcCalculated);
tb_drc.Value = drcCalculated;
// Set the model.
if (this.track == null)
{
return;
}
this.Track.Gain = gain;
}
/// <summary>
/// The Dynamic Range Controller
/// </summary>
/// <param name="sender">The Sender</param>
/// <param name="e">The Event Args</param>
private void tb_drc_Scroll(object sender, EventArgs e)
{
double value;
if (tb_drc.Value == 0) value = 0;
else
value = ((tb_drc.Value - 1) / 10.0) + 1;
lbl_drc.Text = value.ToString();
track.DRC = value;
}
}
}
|