Audacity  2.2.2
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 #include "../Audacity.h"
22 #include "RecordingPrefs.h"
23 
24 #include <wx/defs.h>
25 #include <wx/textctrl.h>
26 #include <algorithm>
27 
28 #include "../AudioIO.h"
29 #include "../prefs/GUISettings.h"
30 #include "../Prefs.h"
31 #include "../ShuttleGui.h"
32 
33 #include "../Experimental.h"
34 #include "../Internat.h"
35 
36 #include "../widgets/Warning.h"
37 
38 using std::min;
39 
40 enum {
42 };
43 
44 BEGIN_EVENT_TABLE(RecordingPrefs, PrefsPanel)
45  EVT_CHECKBOX(UseCustomTrackNameID, RecordingPrefs::OnToggleCustomName)
47 
48 RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid)
49 : PrefsPanel(parent, winid, _("Recording"))
50 {
51  gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false);
52  mOldNameChoice = mUseCustomTrackName;
53  Populate();
54 }
55 
57 {
58 }
59 
61 {
62  //------------------------- Main section --------------------
63  // Now construct the GUI itself.
64  // Use 'eIsCreatingFromPrefs' so that the GUI is
65  // initialised with values from gPrefs.
68  // ----------------------- End of main section --------------
69 }
70 
72 {
73  S.SetBorder(2);
74  S.StartScroller();
75 
76  S.StartStatic(_("Playthrough"));
77  {
78  S.TieCheckBox(_("&Other tracks while recording (overdub)"),
79  wxT("/AudioIO/Duplex"),
80 #ifdef EXPERIMENTAL_DA
81  false);
82 #else
83  true);
84 #endif
85 
86 //#if defined(__WXMAC__)
87 // Bug 388. Feature not supported on any Mac Hardware.
88 #if 0
89  S.TieCheckBox(_("&Hardware Playthrough of input"),
90  wxT("/AudioIO/Playthrough"),
91  false);
92 #endif
93  S.TieCheckBox(_("&Software Playthrough of input"),
94  wxT("/AudioIO/SWPlaythrough"),
95  false);
96 #if !defined(__WXMAC__)
97  //S.AddUnits(wxString(wxT(" ")) + _("(uncheck when recording computer playback)"));
98 #endif
99  }
100  S.EndStatic();
101 
102  S.StartStatic(_("Sound Activated Recording"));
103  {
104  S.TieCheckBox(_("&Enable"),
105  wxT("/AudioIO/SoundActivatedRecord"),
106  false);
107 
108  S.StartMultiColumn(2, wxEXPAND);
109  {
110  S.SetStretchyCol(1);
111 
112  int dBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE);
113  S.TieSlider(_("Le&vel (dB):"),
114  wxT("/AudioIO/SilenceLevel"),
115  -50,
116  0,
117  -dBRange);
118  }
119  S.EndMultiColumn();
120  }
121  S.EndStatic();
122 
123  S.StartStatic(_("Name newly recorded tracks"));
124  {
125  // Nested multicolumns to indent by 'With:' width, in a way that works if
126  // translated.
127  // This extra step is worth doing to get the check boxes lined up nicely.
128  S.StartMultiColumn( 2 );
129  {
130  S.AddFixedText(_("With:")) ;
131  S.StartMultiColumn(3);
132  {
133  S.Id(UseCustomTrackNameID).TieCheckBox(_("Custom Track &Name"),
134  wxT("/GUI/TrackNames/RecordingNameCustom"),
135  mUseCustomTrackName ? true : false);
136 
138  wxT("/GUI/TrackNames/RecodingTrackName"),
139  _("Recorded_Audio"),
140  30);
141  mToggleCustomName->SetName(_("Custom name text"));
143  }
144  S.EndMultiColumn();
145 
146  S.AddFixedText( {} );
147  S.StartMultiColumn(3);
148  {
149  S.TieCheckBox(_("&Track Number"),
150  wxT("/GUI/TrackNames/TrackNumber"),
151  false);
152 
153  S.TieCheckBox(_("System &Date"),
154  wxT("/GUI/TrackNames/DateStamp"),
155  false);
156 
157  S.TieCheckBox(_("System T&ime"),
158  wxT("/GUI/TrackNames/TimeStamp"),
159  false);
160  }
161  S.EndMultiColumn();
162  }
163  S.EndMultiColumn();
164  }
165  S.EndStatic();
166 
167  S.StartStatic(_("Options"));
168  {
169  S.TieCheckBox(_("Always record on a new track"),
170  wxT("/GUI/PreferNewTrackRecord"),
171  false);
172 
173 /* i18n-hint: Dropout is a loss of a short sequence audio sample data from the recording */
174  S.TieCheckBox(_("Detect dropouts"),
175  WarningDialogKey(wxT("DropoutDetected")),
176  true);
177  }
178  S.EndStatic();
179 
180  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
181  S.StartStatic(_("Automated Recording Level Adjustment"));
182  {
183  S.TieCheckBox(_("Enable Automated Recording Level Adjustment."),
184  wxT("/AudioIO/AutomatedInputLevelAdjustment"),
185  false);
186 
187  S.StartMultiColumn(2, wxEXPAND);
188  {
189  S.SetStretchyCol(1);
190 
191  /* i18n-hint: Desired maximum (peak) volume for sound */
192  S.TieSlider(_("Target Peak:"),
193  wxT("/AudioIO/TargetPeak"),
194  AILA_DEF_TARGET_PEAK,
195  100,
196  0);
197 
198  S.TieSlider(_("Within:"),
199  wxT("/AudioIO/DeltaPeakVolume"),
200  AILA_DEF_DELTA_PEAK,
201  100,
202  0);
203  }
204  S.EndMultiColumn();
205 
206  S.StartThreeColumn();
207  {
208  S.TieNumericTextBox(_("Analysis Time:"),
209  wxT("/AudioIO/AnalysisTime"),
210  AILA_DEF_ANALYSIS_TIME,
211  9);
212  S.AddUnits(_("milliseconds (time of one analysis)"));
213 
214  S.TieNumericTextBox(_("Number of consecutive analysis:"),
215  wxT("/AudioIO/NumberAnalysis"),
216  AILA_DEF_NUMBER_ANALYSIS,
217  2);
218  S.AddUnits(_("0 means endless"));
219  }
220  S.EndThreeColumn();
221  }
222  S.EndStatic();
223  #endif
224  S.EndScroller();
225 
226 }
227 
229 {
230  ShuttleGui S(this, eIsSavingToPrefs);
232 
233  double latencyDuration = DEFAULT_LATENCY_DURATION;
234  gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
235  if (latencyDuration < 0) {
236  gPrefs->Write(wxT("/AudioIO/LatencyDuration"), DEFAULT_LATENCY_DURATION);
237  }
238 
239  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
240  double targetpeak, deltapeak;
241  gPrefs->Read(wxT("/AudioIO/TargetPeak"), &targetpeak);
242  gPrefs->Read(wxT("/AudioIO/DeltaPeakVolume"), &deltapeak);
243  if (targetpeak + deltapeak > 100.0 || targetpeak - deltapeak < 0.0)
244  {
245  gPrefs->Write(wxT("/AudioIO/DeltaPeakVolume"), min(100.0 - targetpeak, targetpeak));
246  }
247 
248  int value;
249  gPrefs->Read(wxT("/AudioIO/AnalysisTime"), &value);
250  if (value <= 0)
251  gPrefs->Write(wxT("/AudioIO/AnalysisTime"), AILA_DEF_ANALYSIS_TIME);
252 
253  gPrefs->Read(wxT("/AudioIO/NumberAnalysis"), &value);
254  if (value < 0)
255  gPrefs->Write(wxT("/AudioIO/NumberAnalysis"), AILA_DEF_NUMBER_ANALYSIS);
256  #endif
257  return true;
258 }
259 
260 void RecordingPrefs::OnToggleCustomName(wxCommandEvent & /* Evt */)
261 {
264 }
265 
267 {
268  return "Recording_Preferences";
269 }
270 
271 PrefsPanel *RecordingPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
272 {
273  wxASSERT(parent); // to justify safenew
274  return safenew RecordingPrefs(parent, winid);
275 }
virtual ~RecordingPrefs()
void EndThreeColumn()
Definition: ShuttleGui.h:128
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
void OnToggleCustomName(wxCommandEvent &)
#define ENV_DB_KEY
Definition: GUISettings.h:15
wxSlider * TieSlider(const wxString &Prompt, WrappedType &WrappedRef, const int max, const int min=0)
wxString WarningDialogKey(const wxString &internalDialogName)
Definition: Warning.cpp:114
void EndMultiColumn()
bool Commit() override
void EndScroller()
Definition: ShuttleGui.cpp:770
#define safenew
Definition: Audacity.h:223
void AddUnits(const wxString &Prompt)
Left aligned text string.
Definition: ShuttleGui.cpp:229
#define ENV_DB_RANGE
Definition: GUISettings.h:16
A PrefsPanel used to select recording options.
wxTextCtrl * mToggleCustomName
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:733
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:998
ShuttleGui & Id(int id)
wxTextCtrl * TieNumericTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)
void AddFixedText(const wxString &Str, bool bCenter=false)
Definition: ShuttleGui.cpp:356
int min(int a, int b)
void StartThreeColumn()
Definition: ShuttleGui.h:127
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:43
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
void PopulateOrExchange(ShuttleGui &S)
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:701
wxString HelpPageName() override
END_EVENT_TABLE()
#define DEFAULT_LATENCY_DURATION
Definition: AudioIO.h:84
void SetBorder(int Border)
Definition: ShuttleGui.h:251
bool mUseCustomTrackName
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:192
wxTextCtrl * TieTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)
PrefsPanel * operator()(wxWindow *parent, wxWindowID winid) override