Audacity  3.0.3
RecordingPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  RecordingPrefs.cpp
6 
7  Joshua Haberman
8  Dominic Mazzoni
9  James Crook
10 
11 *******************************************************************//********************************************************************/
20 
21 
22 #include "RecordingPrefs.h"
23 
24 #include <wx/defs.h>
25 #include <wx/textctrl.h>
26 #include <algorithm>
27 
28 #include "../prefs/GUISettings.h"
29 #include "../Prefs.h"
30 #include "../ShuttleGui.h"
31 
32 using std::min;
33 
34 enum {
36 };
37 
38 BEGIN_EVENT_TABLE(RecordingPrefs, PrefsPanel)
41 
42 RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid)
43 : PrefsPanel(parent, winid, XO("Recording"))
44 {
45  gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false);
46  mOldNameChoice = mUseCustomTrackName;
47  Populate();
48 }
49 
51 {
52 }
53 
55 {
57 }
58 
60 {
61  return XO("Preferences for Recording");
62 }
63 
65 {
66  return "Recording_Preferences";
67 }
68 
70 {
71  //------------------------- Main section --------------------
72  // Now construct the GUI itself.
73  // Use 'eIsCreatingFromPrefs' so that the GUI is
74  // initialised with values from gPrefs.
77  // ----------------------- End of main section --------------
78 }
79 
81 {
82  S.SetBorder(2);
83  S.StartScroller();
84 
85  S.StartStatic(XO("Options"));
86  {
87  // Start wording of options with a verb, if possible.
88  S.TieCheckBox(XXO("Play &other tracks while recording (overdub)"),
89  {wxT("/AudioIO/Duplex"),
90 #ifdef EXPERIMENTAL_DA
91  false
92 #else
93  true
94 #endif
95  });
96 
97 //#if defined(__WXMAC__)
98 // Bug 388. Feature not supported on any Mac Hardware.
99 #if 0
100  S.TieCheckBox(XO("Use &hardware to play other tracks"),
101  {wxT("/AudioIO/Playthrough"),
102  false});
103 #endif
104  S.TieCheckBox(XXO("&Software playthrough of input"),
105  {wxT("/AudioIO/SWPlaythrough"),
106  false});
107 #if !defined(__WXMAC__)
108  //S.AddUnits(XO(" (uncheck when recording computer playback)"));
109 #endif
110 
111  S.TieCheckBox(XXO("Record on a new track"),
112  {wxT("/GUI/PreferNewTrackRecord"),
113  false});
114 
115 /* i18n-hint: Dropout is a loss of a short sequence audio sample data from the recording */
116  S.TieCheckBox(XXO("Detect dropouts"),
117  {WarningDialogKey(wxT("DropoutDetected")),
118  true});
119 
120 
121  }
122  S.EndStatic();
123 
124  S.StartStatic(XO("Sound Activated Recording"));
125  {
126  S.TieCheckBox(XXO("&Enable"),
127  {wxT("/AudioIO/SoundActivatedRecord"),
128  false});
129 
130  S.StartMultiColumn(2, wxEXPAND);
131  {
132  S.SetStretchyCol(1);
133 
134  S.TieSlider(XXO("Le&vel (dB):"),
135  {wxT("/AudioIO/SilenceLevel"),
136  -50},
137  0,
138  -gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE));
139  }
140  S.EndMultiColumn();
141  }
142  S.EndStatic();
143 
144  /* i18n-hint: start of two-part phrase, "Name newly recorded tracks with:" */
145  S.StartStatic(XO("Name newly recorded tracks"));
146  {
147  // Nested multicolumns to indent by 'With:' width, in a way that works if
148  // translated.
149  // This extra step is worth doing to get the check boxes lined up nicely.
150  S.StartMultiColumn( 2 );
151  {
152  /* i18n-hint: end of two-part phrase, "Name newly recorded tracks with:" */
153  S.AddFixedText(XO("With:")) ;
154  S.StartMultiColumn(3);
155  {
156  S.Id(UseCustomTrackNameID).TieCheckBox(XXO("Custom Track &Name"),
157  {wxT("/GUI/TrackNames/RecordingNameCustom"),
159 
161  .Name(XO("Custom name text"))
162  .Disable(!mUseCustomTrackName)
163  .TieTextBox( {},
164  {wxT("/GUI/TrackNames/RecodingTrackName"),
165  _("Recorded_Audio")},
166  30);
167  }
168 
169  S.EndMultiColumn();
170 
171  S.AddFixedText( {} );
172  S.StartMultiColumn(3);
173  {
174  S.TieCheckBox(XXO("&Track Number"),
175  {wxT("/GUI/TrackNames/TrackNumber"),
176  false});
177 
178  S.TieCheckBox(XXO("System &Date"),
179  {wxT("/GUI/TrackNames/DateStamp"),
180  false});
181 
182  S.TieCheckBox(XXO("System T&ime"),
183  {wxT("/GUI/TrackNames/TimeStamp"),
184  false});
185  }
186  S.EndMultiColumn();
187  }
188  S.EndMultiColumn();
189  }
190  S.EndStatic();
191 
192  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
193  S.StartStatic(XO("Automated Recording Level Adjustment"));
194  {
195  S.TieCheckBox(XXO("Enable Automated Recording Level Adjustment."),
196  {wxT("/AudioIO/AutomatedInputLevelAdjustment"),
197  false});
198 
199  S.StartMultiColumn(2, wxEXPAND);
200  {
201  S.SetStretchyCol(1);
202 
203  /* i18n-hint: Desired maximum (peak) volume for sound */
204  S.TieSlider(XXO("Target Peak:"),
205  {wxT("/AudioIO/TargetPeak"),
206  AILA_DEF_TARGET_PEAK},
207  100,
208  0);
209 
210  S.TieSlider(XXO("Within:"),
211  {wxT("/AudioIO/DeltaPeakVolume"),
212  AILA_DEF_DELTA_PEAK},
213  100,
214  0);
215  }
216  S.EndMultiColumn();
217 
218  S.StartThreeColumn();
219  {
220  S.TieIntegerTextBox(XXO("Analysis Time:"),
221  {wxT("/AudioIO/AnalysisTime"),
222  AILA_DEF_ANALYSIS_TIME},
223  9);
224  S.AddUnits(XO("milliseconds (time of one analysis)"));
225 
226  S.TieIntegerTextBox(XXO("Number of consecutive analysis:"),
227  {wxT("/AudioIO/NumberAnalysis"),
228  AILA_DEF_NUMBER_ANALYSIS},
229  2);
230  S.AddUnits(XO("0 means endless"));
231  }
232  S.EndThreeColumn();
233  }
234  S.EndStatic();
235  #endif
236 
237 #ifdef EXPERIMENTAL_PUNCH_AND_ROLL
238  S.StartStatic(XO("Punch and Roll Recording"));
239  {
240  S.StartThreeColumn();
241  {
242  auto w = S
243  .NameSuffix(XO("seconds"))
244  .TieNumericTextBox(XXO("Pre-ro&ll:"),
247  9);
248  S.AddUnits(XO("seconds"));
249  }
250  {
251  auto w = S
252  .NameSuffix(XO("milliseconds"))
253  .TieNumericTextBox(XXO("Cross&fade:"),
256  9);
257  S.AddUnits(XO("milliseconds"));
258  }
259  S.EndThreeColumn();
260  }
261  S.EndStatic();
262 #endif
263 
264  S.EndScroller();
265 }
266 
268 {
269  ShuttleGui S(this, eIsSavingToPrefs);
271 
272  double latencyDuration = DEFAULT_LATENCY_DURATION;
273  gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
274  if (latencyDuration < 0) {
275  gPrefs->Write(wxT("/AudioIO/LatencyDuration"), DEFAULT_LATENCY_DURATION);
276  }
277 
278  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
279  double targetpeak, deltapeak;
280  gPrefs->Read(wxT("/AudioIO/TargetPeak"), &targetpeak);
281  gPrefs->Read(wxT("/AudioIO/DeltaPeakVolume"), &deltapeak);
282  if (targetpeak + deltapeak > 100.0 || targetpeak - deltapeak < 0.0)
283  {
284  gPrefs->Write(wxT("/AudioIO/DeltaPeakVolume"), min(100.0 - targetpeak, targetpeak));
285  }
286 
287  int value;
288  gPrefs->Read(wxT("/AudioIO/AnalysisTime"), &value);
289  if (value <= 0)
290  gPrefs->Write(wxT("/AudioIO/AnalysisTime"), AILA_DEF_ANALYSIS_TIME);
291 
292  gPrefs->Read(wxT("/AudioIO/NumberAnalysis"), &value);
293  if (value < 0)
294  gPrefs->Write(wxT("/AudioIO/NumberAnalysis"), AILA_DEF_NUMBER_ANALYSIS);
295  #endif
296  return true;
297 }
298 
299 void RecordingPrefs::OnToggleCustomName(wxCommandEvent & /* Evt */)
300 {
303 }
304 
305 namespace{
307  [](wxWindow *parent, wxWindowID winid, AudacityProject *)
308  {
309  wxASSERT(parent); // to justify safenew
310  return safenew RecordingPrefs(parent, winid);
311  }
312 };
313 }
RecordingPrefs::mToggleCustomName
wxTextCtrl * mToggleCustomName
Definition: RecordingPrefs.h:58
ShuttleGui::NameSuffix
ShuttleGui & NameSuffix(const TranslatableString &suffix)
Definition: ShuttleGui.h:678
TranslatableString
Definition: Types.h:290
UseCustomTrackNameID
@ UseCustomTrackNameID
Definition: RecordingPrefs.cpp:35
ShuttleGuiBase::TieIntegerTextBox
virtual wxTextCtrl * TieIntegerTextBox(const TranslatableString &Prompt, const SettingSpec< int > &Setting, const int nChars)
Definition: ShuttleGui.cpp:1906
ShuttleGuiBase::EndThreeColumn
void EndThreeColumn()
Definition: ShuttleGui.h:377
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
ENV_DB_RANGE
#define ENV_DB_RANGE
Definition: GUISettings.h:16
RECORDING_PREFS_PLUGIN_SYMBOL
#define RECORDING_PREFS_PLUGIN_SYMBOL
Definition: RecordingPrefs.h:31
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1603
ShuttleGuiBase::TieSlider
wxSlider * TieSlider(const TranslatableString &Prompt, int &pos, const int max, const int min=0)
Definition: ShuttleGui.cpp:1661
PrefsPanel::Registration
Definition: PrefsPanel.h:84
XO
#define XO(s)
Definition: Internat.h:32
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
RecordingPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: RecordingPrefs.cpp:80
RecordingPrefs::Populate
void Populate()
Definition: RecordingPrefs.cpp:69
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1626
DEFAULT_PRE_ROLL_SECONDS
#define DEFAULT_PRE_ROLL_SECONDS
Definition: RecordingPrefs.h:37
RecordingPrefs::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: RecordingPrefs.cpp:54
RecordingPrefs::~RecordingPrefs
virtual ~RecordingPrefs()
Definition: RecordingPrefs.cpp:50
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:964
DEFAULT_ROLL_CROSSFADE_MS
#define DEFAULT_ROLL_CROSSFADE_MS
Definition: RecordingPrefs.h:40
RecordingPrefs::mUseCustomTrackName
bool mUseCustomTrackName
Definition: RecordingPrefs.h:59
XXO
#define XXO(s)
Definition: Internat.h:45
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:931
AUDIO_PRE_ROLL_KEY
#define AUDIO_PRE_ROLL_KEY
Definition: RecordingPrefs.h:36
RecordingPrefs::OnToggleCustomName
void OnToggleCustomName(wxCommandEvent &)
Definition: RecordingPrefs.cpp:299
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
RecordingPrefs::HelpPageName
wxString HelpPageName() override
Definition: RecordingPrefs.cpp:64
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:256
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:433
anonymous_namespace{RecordingPrefs.cpp}::sAttachment
PrefsPanel::Registration sAttachment
Definition: RecordingPrefs.cpp:306
ShuttleGuiBase::StartThreeColumn
void StartThreeColumn()
Definition: ShuttleGui.h:376
ENV_DB_KEY
#define ENV_DB_KEY
Definition: GUISettings.h:15
AUDIO_ROLL_CROSSFADE_KEY
#define AUDIO_ROLL_CROSSFADE_KEY
Definition: RecordingPrefs.h:39
RecordingPrefs.h
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:46
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
_
#define _(s)
Definition: Internat.h:76
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
WarningDialogKey
wxString WarningDialogKey(const wxString &internalDialogName)
Definition: Prefs.cpp:368
RecordingPrefs::Commit
bool Commit() override
Definition: RecordingPrefs.cpp:267
RecordingPrefs::GetDescription
TranslatableString GetDescription() override
Definition: RecordingPrefs.cpp:59
PrefsPanel
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:45
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
safenew
#define safenew
Definition: MemoryX.h:8
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
RecordingPrefs
A PrefsPanel used to select recording options.
Definition: RecordingPrefs.h:43
DEFAULT_LATENCY_DURATION
#define DEFAULT_LATENCY_DURATION
Definition: RecordingPrefs.h:33
END_EVENT_TABLE
END_EVENT_TABLE()
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638