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