forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecordingPrefs.cpp
More file actions
313 lines (263 loc) · 9.11 KB
/
Copy pathRecordingPrefs.cpp
File metadata and controls
313 lines (263 loc) · 9.11 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/**********************************************************************
Audacity: A Digital Audio Editor
RecordingPrefs.cpp
Joshua Haberman
Dominic Mazzoni
James Crook
*******************************************************************//**
\class RecordingPrefs
\brief A PrefsPanel used to select recording options.
Presents interface for user to update the various recording options
like playthrough, latency correction, and others.
*//********************************************************************/
#include "../Audacity.h"
#include "RecordingPrefs.h"
#include <wx/defs.h>
#include <wx/textctrl.h>
#include <algorithm>
#include "../prefs/GUISettings.h"
#include "../Prefs.h"
#include "../ShuttleGui.h"
using std::min;
enum {
UseCustomTrackNameID = 1000,
};
BEGIN_EVENT_TABLE(RecordingPrefs, PrefsPanel)
EVT_CHECKBOX(UseCustomTrackNameID, RecordingPrefs::OnToggleCustomName)
END_EVENT_TABLE()
RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, XO("Recording"))
{
gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false);
mOldNameChoice = mUseCustomTrackName;
Populate();
}
RecordingPrefs::~RecordingPrefs()
{
}
ComponentInterfaceSymbol RecordingPrefs::GetSymbol()
{
return RECORDING_PREFS_PLUGIN_SYMBOL;
}
TranslatableString RecordingPrefs::GetDescription()
{
return XO("Preferences for Recording");
}
wxString RecordingPrefs::HelpPageName()
{
return "Recording_Preferences";
}
void RecordingPrefs::Populate()
{
//------------------------- Main section --------------------
// Now construct the GUI itself.
// Use 'eIsCreatingFromPrefs' so that the GUI is
// initialised with values from gPrefs.
ShuttleGui S(this, eIsCreatingFromPrefs);
PopulateOrExchange(S);
// ----------------------- End of main section --------------
}
void RecordingPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.SetBorder(2);
S.StartScroller();
S.StartStatic(XO("Options"));
{
// Start wording of options with a verb, if possible.
S.TieCheckBox(XXO("Play &other tracks while recording (overdub)"),
{wxT("/AudioIO/Duplex"),
#ifdef EXPERIMENTAL_DA
false
#else
true
#endif
});
//#if defined(__WXMAC__)
// Bug 388. Feature not supported on any Mac Hardware.
#if 0
S.TieCheckBox(XO("Use &hardware to play other tracks"),
{wxT("/AudioIO/Playthrough"),
false});
#endif
S.TieCheckBox(XXO("&Software playthrough of input"),
{wxT("/AudioIO/SWPlaythrough"),
false});
#if !defined(__WXMAC__)
//S.AddUnits(XO(" (uncheck when recording computer playback)"));
#endif
S.TieCheckBox(XXO("Record on a new track"),
{wxT("/GUI/PreferNewTrackRecord"),
false});
/* i18n-hint: Dropout is a loss of a short sequence audio sample data from the recording */
S.TieCheckBox(XXO("Detect dropouts"),
{WarningDialogKey(wxT("DropoutDetected")),
true});
}
S.EndStatic();
S.StartStatic(XO("Sound Activated Recording"));
{
S.TieCheckBox(XXO("&Enable"),
{wxT("/AudioIO/SoundActivatedRecord"),
false});
S.StartMultiColumn(2, wxEXPAND);
{
S.SetStretchyCol(1);
S.TieSlider(XXO("Le&vel (dB):"),
{wxT("/AudioIO/SilenceLevel"),
-50},
0,
-gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE));
}
S.EndMultiColumn();
}
S.EndStatic();
/* i18n-hint: start of two-part phrase, "Name newly recorded tracks with:" */
S.StartStatic(XO("Name newly recorded tracks"));
{
// Nested multicolumns to indent by 'With:' width, in a way that works if
// translated.
// This extra step is worth doing to get the check boxes lined up nicely.
S.StartMultiColumn( 2 );
{
/* i18n-hint: end of two-part phrase, "Name newly recorded tracks with:" */
S.AddFixedText(XO("With:")) ;
S.StartMultiColumn(3);
{
S.Id(UseCustomTrackNameID).TieCheckBox(XXO("Custom Track &Name"),
{wxT("/GUI/TrackNames/RecordingNameCustom"),
mUseCustomTrackName});
mToggleCustomName = S
.Name(XO("Custom name text"))
.Disable(!mUseCustomTrackName)
.TieTextBox( {},
{wxT("/GUI/TrackNames/RecodingTrackName"),
_("Recorded_Audio")},
30);
}
S.EndMultiColumn();
S.AddFixedText( {} );
S.StartMultiColumn(3);
{
S.TieCheckBox(XXO("&Track Number"),
{wxT("/GUI/TrackNames/TrackNumber"),
false});
S.TieCheckBox(XXO("System &Date"),
{wxT("/GUI/TrackNames/DateStamp"),
false});
S.TieCheckBox(XXO("System T&ime"),
{wxT("/GUI/TrackNames/TimeStamp"),
false});
}
S.EndMultiColumn();
}
S.EndMultiColumn();
}
S.EndStatic();
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
S.StartStatic(XO("Automated Recording Level Adjustment"));
{
S.TieCheckBox(XXO("Enable Automated Recording Level Adjustment."),
{wxT("/AudioIO/AutomatedInputLevelAdjustment"),
false});
S.StartMultiColumn(2, wxEXPAND);
{
S.SetStretchyCol(1);
/* i18n-hint: Desired maximum (peak) volume for sound */
S.TieSlider(XXO("Target Peak:"),
{wxT("/AudioIO/TargetPeak"),
AILA_DEF_TARGET_PEAK},
100,
0);
S.TieSlider(XXO("Within:"),
{wxT("/AudioIO/DeltaPeakVolume"),
AILA_DEF_DELTA_PEAK},
100,
0);
}
S.EndMultiColumn();
S.StartThreeColumn();
{
S.TieIntegerTextBox(XXO("Analysis Time:"),
{wxT("/AudioIO/AnalysisTime"),
AILA_DEF_ANALYSIS_TIME},
9);
S.AddUnits(XO("milliseconds (time of one analysis)"));
S.TieIntegerTextBox(XXO("Number of consecutive analysis:"),
{wxT("/AudioIO/NumberAnalysis"),
AILA_DEF_NUMBER_ANALYSIS},
2);
S.AddUnits(XO("0 means endless"));
}
S.EndThreeColumn();
}
S.EndStatic();
#endif
#ifdef EXPERIMENTAL_PUNCH_AND_ROLL
S.StartStatic(XO("Punch and Roll Recording"));
{
S.StartThreeColumn();
{
auto w = S
.NameSuffix(XO("seconds"))
.TieNumericTextBox(XXO("Pre-ro&ll:"),
{AUDIO_PRE_ROLL_KEY,
DEFAULT_PRE_ROLL_SECONDS},
9);
S.AddUnits(XO("seconds"));
}
{
auto w = S
.NameSuffix(XO("milliseconds"))
.TieNumericTextBox(XXO("Cross&fade:"),
{AUDIO_ROLL_CROSSFADE_KEY,
DEFAULT_ROLL_CROSSFADE_MS},
9);
S.AddUnits(XO("milliseconds"));
}
S.EndThreeColumn();
}
S.EndStatic();
#endif
S.EndScroller();
}
bool RecordingPrefs::Commit()
{
ShuttleGui S(this, eIsSavingToPrefs);
PopulateOrExchange(S);
double latencyDuration = DEFAULT_LATENCY_DURATION;
gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
if (latencyDuration < 0) {
gPrefs->Write(wxT("/AudioIO/LatencyDuration"), DEFAULT_LATENCY_DURATION);
}
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
double targetpeak, deltapeak;
gPrefs->Read(wxT("/AudioIO/TargetPeak"), &targetpeak);
gPrefs->Read(wxT("/AudioIO/DeltaPeakVolume"), &deltapeak);
if (targetpeak + deltapeak > 100.0 || targetpeak - deltapeak < 0.0)
{
gPrefs->Write(wxT("/AudioIO/DeltaPeakVolume"), min(100.0 - targetpeak, targetpeak));
}
int value;
gPrefs->Read(wxT("/AudioIO/AnalysisTime"), &value);
if (value <= 0)
gPrefs->Write(wxT("/AudioIO/AnalysisTime"), AILA_DEF_ANALYSIS_TIME);
gPrefs->Read(wxT("/AudioIO/NumberAnalysis"), &value);
if (value < 0)
gPrefs->Write(wxT("/AudioIO/NumberAnalysis"), AILA_DEF_NUMBER_ANALYSIS);
#endif
return true;
}
void RecordingPrefs::OnToggleCustomName(wxCommandEvent & /* Evt */)
{
mUseCustomTrackName = !mUseCustomTrackName;
mToggleCustomName->Enable(mUseCustomTrackName);
}
namespace{
PrefsPanel::Registration sAttachment{ "Recording",
[](wxWindow *parent, wxWindowID winid, AudacityProject *)
{
wxASSERT(parent); // to justify safenew
return safenew RecordingPrefs(parent, winid);
}
};
}