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