Audacity  2.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ContrastDialog Class Referencefinal

#include <Contrast.h>

Inheritance diagram for ContrastDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 ContrastDialog (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Public Attributes

wxButton * m_pButton_UseCurrentF
 
wxButton * m_pButton_UseCurrentB
 
wxButton * m_pButton_GetURL
 
wxButton * m_pButton_Export
 
wxButton * m_pButton_Reset
 
wxButton * m_pButton_Close
 
NumericTextCtrlmForegroundStartT
 
NumericTextCtrlmForegroundEndT
 
NumericTextCtrlmBackgroundStartT
 
NumericTextCtrlmBackgroundEndT
 
double mT0
 
double mT1
 
double mProjectRate
 
double mStartTimeF
 
double mEndTimeF
 
double mStartTimeB
 
double mEndTimeB
 

Private Member Functions

void OnGetURL (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnGetForeground (wxCommandEvent &event)
 
void OnGetBackground (wxCommandEvent &event)
 
void results ()
 
void OnReset (wxCommandEvent &event)
 
void OnClose (wxCommandEvent &event)
 
bool GetDB (float &dB)
 
void SetStartAndEndTime ()
 

Private Attributes

wxTextCtrl * mForegroundRMSText
 
wxTextCtrl * mBackgroundRMSText
 
wxTextCtrl * mPassFailText
 
wxTextCtrl * mDiffText
 
float foregrounddB
 
float backgrounddB
 
bool mForegroundIsDefined
 
bool mBackgroundIsDefined
 
double mT0orig
 
double mT1orig
 
bool mDoBackground
 
double length
 

Detailed Description

Definition at line 29 of file Contrast.h.

Constructor & Destructor Documentation

ContrastDialog::ContrastDialog ( wxWindow *  parent,
wxWindowID  id,
const wxString &  title,
const wxPoint &  pos 
)

Definition at line 170 of file Contrast.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTitle(), ShuttleGuiBase::AddWindow(), NumericTextCtrl::Options::AutoPos(), backgrounddB, eCloseButton, eHelpButton, eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), foregrounddB, GetActiveProject(), ShuttleGui::GetMode(), AudacityProject::GetRate(), NumericConverter::HundredthsFormat(), ShuttleGui::Id(), ID_BACKGROUNDDB_TEXT, ID_BACKGROUNDEND_T, ID_BACKGROUNDSTART_T, ID_BUTTON_EXPORT, ID_BUTTON_RESET, ID_BUTTON_USECURRENTB, ID_BUTTON_USECURRENTF, ID_FOREGROUNDDB_TEXT, ID_FOREGROUNDEND_T, ID_FOREGROUNDSTART_T, ID_RESULTS_TEXT, ID_RESULTSDB_TEXT, label, m_pButton_Close, m_pButton_Export, m_pButton_GetURL, m_pButton_Reset, m_pButton_UseCurrentB, m_pButton_UseCurrentF, mBackgroundEndT, mBackgroundIsDefined, mBackgroundRMSText, mBackgroundStartT, mDiffText, NumericTextCtrl::Options::MenuEnabled(), mForegroundEndT, mForegroundIsDefined, mForegroundRMSText, mForegroundStartT, mPassFailText, mProjectRate, mT0, mT1, OnChar(), NumericTextCtrl::Options::ReadOnly(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), and NumericConverter::TIME.

172  :
173  wxDialogWrapper(parent, id, title, pos, wxDefaultSize,
174  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX )
175 {
176  SetName(GetTitle());
177 
178  mT0 = 0.0;
179  mT1 = 0.0;
180  foregrounddB = 0.0;
181  backgrounddB = 0.0;
182  mForegroundIsDefined = false;
183  mBackgroundIsDefined = false;
184 
185  // NULL out the control members until the controls are created.
186  mForegroundStartT = NULL;
187  mForegroundEndT = NULL;
188  mBackgroundStartT = NULL;
189  mBackgroundEndT = NULL;
190  wxTextValidator vld(wxFILTER_NUMERIC);
191  wxString number;
192 
194  mProjectRate = p->GetRate();
195 
196  ShuttleGui S(this, eIsCreating);
197 
198  S.SetBorder(5);
199  S.StartHorizontalLay(wxCENTER, false);
200  {
201  /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
202  S.AddTitle(_("Contrast Analyzer, for measuring RMS volume differences between two selections of audio."));
203  }
204  S.EndHorizontalLay();
205  S.StartStatic( _("Parameters") );
206  {
207  S.StartMultiColumn(5, wxEXPAND);
208  {
209 
210  // Headings
211  S.AddFixedText( {} ); // spacer
212  S.AddFixedText(_("Start"));
213  S.AddFixedText(_("End"));
214  S.AddFixedText( {} ); // spacer
215  S.AddFixedText(_("Volume "));
216 
217  const auto options = NumericTextCtrl::Options{}
218  .AutoPos(true)
219  .MenuEnabled(false)
220  .ReadOnly(true);
221 
222  //Foreground
223  S.AddFixedText(_("&Foreground:"), false);
224  if (S.GetMode() == eIsCreating)
225  {
230  0.0,
231  mProjectRate,
232  options);
233  mForegroundStartT->SetName(_("Foreground start time"));
234  }
235  S.AddWindow(mForegroundStartT);
236 
237  if (S.GetMode() == eIsCreating)
238  {
243  0.0,
244  mProjectRate,
245  options);
246  mForegroundEndT->SetName(_("Foreground end time"));
247  }
248  S.AddWindow(mForegroundEndT);
249 
250  m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("&Measure selection"));
251  mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17);
252  mForegroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar);
253 
254  //Background
255  S.AddFixedText(_("&Background:"));
256  if (S.GetMode() == eIsCreating)
257  {
262  0.0,
263  mProjectRate,
264  options);
265  mBackgroundStartT->SetName(_("Background start time"));
266  }
267  S.AddWindow(mBackgroundStartT);
268 
269  if (S.GetMode() == eIsCreating)
270  {
275  0.0,
276  mProjectRate,
277  options);
278  mBackgroundEndT->SetName(_("Background end time"));
279  }
280  S.AddWindow(mBackgroundEndT);
281 
282  m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Mea&sure selection"));
283  mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17);
284  mBackgroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar);
285  }
286  S.EndMultiColumn();
287  }
288  S.EndStatic();
289 
290  //Result
291  S.StartStatic( _("Result") );
292  {
293  S.StartMultiColumn(3, wxCENTER);
294  {
295  wxString label = _("Co&ntrast Result:");
296  S.AddFixedText(label);
297  mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox( {}, wxT(""), 50);
298  mPassFailText->SetName(wxStripMenuCodes(label));
299  mPassFailText->Bind(wxEVT_KEY_DOWN, OnChar);
300  m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("R&eset"));
301 
302  label = _("&Difference:");
303  S.AddFixedText(label);
304  mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox( {}, wxT(""), 50);
305  mDiffText->SetName(wxStripMenuCodes(label));
306  mDiffText->Bind(wxEVT_KEY_DOWN, OnChar);
307  m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("E&xport..."));
308  }
309  S.EndMultiColumn();
310  }
311  S.EndStatic();
312  S.AddStandardButtons(eCloseButton |eHelpButton);
313 #if 0
314  S.StartMultiColumn(3, wxEXPAND);
315  {
316  S.SetStretchyCol(1);
317  m_pButton_GetURL = S.Id(ID_BUTTON_GETURL).AddButton(_("&Help"));
318  S.AddFixedText(wxT(" ")); // spacer
319  m_pButton_Close = S.Id(ID_BUTTON_CLOSE).AddButton(_("&Close"));
320  }
321  S.EndMultiColumn();
322 #endif
323  Layout();
324  Fit();
325  SetMinSize(GetSize());
326  Center();
327 }
double mProjectRate
Definition: Contrast.h:50
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
bool mForegroundIsDefined
Definition: Contrast.h:73
double mT1
Definition: Contrast.h:49
wxTextCtrl * mDiffText
Definition: Contrast.h:69
wxButton * m_pButton_Export
Definition: Contrast.h:39
wxString label
Definition: Tags.cpp:733
wxButton * m_pButton_UseCurrentF
Definition: Contrast.h:36
Options & AutoPos(bool enable)
wxButton * m_pButton_GetURL
Definition: Contrast.h:38
wxTextCtrl * mForegroundRMSText
Definition: Contrast.h:66
wxTextCtrl * mPassFailText
Definition: Contrast.h:68
#define safenew
Definition: Audacity.h:230
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:43
wxTextCtrl * mBackgroundRMSText
Definition: Contrast.h:67
wxButton * m_pButton_UseCurrentB
Definition: Contrast.h:37
wxButton * m_pButton_Close
Definition: Contrast.h:41
wxButton * m_pButton_Reset
Definition: Contrast.h:40
double mT0
Definition: Contrast.h:48
_("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
Options & ReadOnly(bool enable)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
float foregrounddB
Definition: Contrast.h:71
static NumericFormatId HundredthsFormat()
static void OnChar(wxKeyEvent &event)
Definition: Contrast.cpp:155
double GetRate() const
Definition: Project.h:199
Options & MenuEnabled(bool enable)
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:45
float backgrounddB
Definition: Contrast.h:72
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:44
bool mBackgroundIsDefined
Definition: Contrast.h:74
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:46

Member Function Documentation

bool ContrastDialog::GetDB ( float &  dB)
private

Definition at line 43 of file Contrast.cpp.

References _(), GetActiveProject(), AudacityProject::GetTracks(), LINEAR_TO_DB, mT0, mT1, and Track::Wave.

Referenced by OnGetBackground(), and OnGetForeground().

44 {
45  float rms = float(0.0);
46  int numberSelecteTracks = 0;
47 
48  // For stereo tracks: sqrt((mean(L)+mean(R))/2)
49  bool isStereo = false;
50  double meanSq = 0.0;
51 
54  WaveTrack *t = (WaveTrack *) iter.First();
55  while (t) {
56  numberSelecteTracks++;
57  if (numberSelecteTracks > 1 && !isStereo) {
58  AudacityMessageDialog m(NULL, _("You can only measure one track at a time."), _("Error"), wxOK);
59  m.ShowModal();
60  return false;
61  }
62  isStereo = t->GetLinked();
63 
64  wxASSERT(mT0 <= mT1);
65 
66  // Ignore whitespace beyond ends of track.
67  if(mT0 < t->GetStartTime())
68  mT0 = t->GetStartTime();
69  if(mT1 > t->GetEndTime())
70  mT1 = t->GetEndTime();
71 
72  auto SelT0 = t->TimeToLongSamples(mT0);
73  auto SelT1 = t->TimeToLongSamples(mT1);
74 
75  if(SelT0 > SelT1)
76  {
77  AudacityMessageDialog m(NULL, _("Invalid audio selection.\nPlease ensure that audio is selected."), _("Error"), wxOK);
78  m.ShowModal();
79  return false;
80  }
81 
82  if(SelT0 == SelT1)
83  {
84  AudacityMessageDialog m(NULL, _("Nothing to measure.\nPlease select a section of a track."), _("Error"), wxOK);
85  m.ShowModal();
86  return false;
87  }
88 
89  // Don't throw in this analysis dialog
90  rms = ((WaveTrack *)t)->GetRMS(mT0, mT1, false);
91  meanSq += rms * rms;
92  t = (WaveTrack *) iter.Next();
93  }
94  // TODO: This works for stereo, provided the audio clips are in both channels.
95  // We should really count gaps between clips as silence.
96  rms = (meanSq > 0.0)? sqrt(meanSq/(double)numberSelecteTracks) : 0.0;
97 
98  if(numberSelecteTracks == 0) {
99  AudacityMessageDialog m(NULL, _("Please select an audio track."), _("Error"), wxOK);
100  m.ShowModal();
101  return false;
102  }
103  // Gives warning C4056, Overflow in floating-point constant arithmetic
104  // -INFINITY is intentional here.
105  // Looks like we are stuck with this warning, as
106  // #pragma warning( disable : 4056)
107  // even around the whole function does not disable it successfully.
108 
109  dB = (rms == 0.0)? -INFINITY : LINEAR_TO_DB(rms);
110  return true;
111 }
double mT1
Definition: Contrast.h:49
Wrap wxMessageDialog so that caption IS translatable.
Definition: ErrorDialog.h:129
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
double mT0
Definition: Contrast.h:48
_("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
#define LINEAR_TO_DB(x)
Definition: Audacity.h:217
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
TrackList * GetTracks()
Definition: Project.h:192
void ContrastDialog::OnClose ( wxCommandEvent &  event)
private

Definition at line 336 of file Contrast.cpp.

References OnReset().

337 {
338  wxCommandEvent dummyEvent;
339  OnReset(dummyEvent);
340 
341  Show(false);
342 }
void OnReset(wxCommandEvent &event)
Definition: Contrast.cpp:594
void ContrastDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 496 of file Contrast.cpp.

References _(), AudacityMessageBox(), backgrounddB, FileNames::Export, foregrounddB, GetActiveProject(), AudacityProject::GetFileName(), NumericConverter::GetValue(), mBackgroundEndT, mBackgroundIsDefined, mBackgroundStartT, mForegroundEndT, mForegroundIsDefined, mForegroundStartT, and FileNames::SelectFile().

497 {
498  // TODO: Handle silence checks better (-infinity dB)
499  AudacityProject * project = GetActiveProject();
500  wxString fName = wxT("contrast.txt");
501 
503  _("Export Contrast Result As:"),
504  wxEmptyString,
505  fName,
506  wxT("txt"),
507  wxT("*.txt"),
508  wxFD_SAVE | wxRESIZE_BORDER,
509  this);
510 
511  if (fName == wxT(""))
512  return;
513 
514  wxTextFile f(fName);
515 #ifdef __WXMAC__
516  wxFile{}.Create(fName);
517 #else
518  f.Create();
519 #endif
520  f.Open();
521  if (!f.IsOpened()) {
523  wxString::Format( _("Couldn't write to file: %s"), fName) );
524  return;
525  }
526 
527  f.AddLine(wxT("==================================="));
528  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
529  f.AddLine(_("WCAG 2.0 Success Criteria 1.4.7 Contrast Results"));
530  f.AddLine(wxT(""));
531  f.AddLine(wxString::Format(_("Filename = %s."), project->GetFileName() ));
532  f.AddLine(wxT(""));
533  f.AddLine(_("Foreground"));
534  float t = (float)mForegroundStartT->GetValue();
535  int h = (int)(t/3600); // there must be a standard function for this!
536  int m = (int)((t - h*3600)/60);
537  float s = t - h*3600.0 - m*60.0;
538  f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
539  t = (float)mForegroundEndT->GetValue();
540  h = (int)(t/3600);
541  m = (int)((t - h*3600)/60);
542  s = t - h*3600.0 - m*60.0;
543  f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
544  f.AddLine( FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) );
545  f.AddLine(wxT(""));
546  f.AddLine(_("Background"));
547  t = (float)mBackgroundStartT->GetValue();
548  h = (int)(t/3600);
549  m = (int)((t - h*3600)/60);
550  s = t - h*3600.0 - m*60.0;
551  f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
552  t = (float)mBackgroundEndT->GetValue();
553  h = (int)(t/3600);
554  m = (int)((t - h*3600)/60);
555  s = t - h*3600.0 - m*60.0;
556  f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
557  f.AddLine( FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) );
558  f.AddLine(wxT(""));
559  f.AddLine(_("Results"));
560  float diffdB = foregrounddB - backgrounddB;
561 
562  f.AddLine( FormatDifferenceForExport( diffdB ) );
563  if( diffdB > 20. )
564  f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Pass"));
565  else
566  f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Fail"));
567 
568  f.AddLine(wxT(""));
569  f.AddLine(_("Data gathered"));
570  wxString sNow;
571  wxDateTime now = wxDateTime::Now();
572  int year = now.GetYear();
573  wxDateTime::Month month = now.GetMonth();
574  wxString monthName = now.GetMonthName(month);
575  int dom = now.GetDay();
576  int hour = now.GetHour();
577  int minute = now.GetMinute();
578  int second = now.GetSecond();
579  sNow = wxString::Format(wxT("%d %s %02d %02dh %02dm %02ds"),
580  dom, monthName, year, hour, minute, second);
581  f.AddLine(sNow);
582 
583  f.AddLine(wxT("==================================="));
584  f.AddLine(wxT(""));
585 
586 #ifdef __WXMAC__
587  f.Write(wxTextFileType_Mac);
588 #else
589  f.Write();
590 #endif
591  f.Close();
592 }
bool mForegroundIsDefined
Definition: Contrast.h:73
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:43
static wxString SelectFile(Operation op, const wxString &message, const wxString &default_path, const wxString &default_filename, const wxString &default_extension, const wxString &wildcard, int flags, wxWindow *parent)
Definition: FileNames.cpp:411
_("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
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
float foregrounddB
Definition: Contrast.h:71
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:45
float backgrounddB
Definition: Contrast.h:72
const wxString & GetFileName()
Definition: Project.h:302
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:44
bool mBackgroundIsDefined
Definition: Contrast.h:74
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:46
void ContrastDialog::OnGetBackground ( wxCommandEvent &  event)
private

Definition at line 360 of file Contrast.cpp.

References backgrounddB, GetActiveProject(), GetDB(), AudacityProject::GetTracks(), m_pButton_UseCurrentB, mBackgroundEndT, mBackgroundIsDefined, mBackgroundStartT, AudacityProject::mViewInfo, results(), ViewInfo::selectedRegion, SetStartAndEndTime(), NumericTextCtrl::SetValue(), SelectedRegion::t0(), SelectedRegion::t1(), and Track::Wave.

361 {
364 
365  for (Track *t = iter.First(); t; t = iter.Next()) {
368  }
369 
372  m_pButton_UseCurrentB->SetFocus();
373  results();
374 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
void results()
Definition: Contrast.cpp:437
double t1() const
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetStartAndEndTime()
Definition: Contrast.cpp:113
wxButton * m_pButton_UseCurrentB
Definition: Contrast.h:37
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
ViewInfo mViewInfo
Definition: Project.h:558
bool GetDB(float &dB)
Definition: Contrast.cpp:43
void SetValue(double newValue)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
TrackList * GetTracks()
Definition: Project.h:192
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:45
float backgrounddB
Definition: Contrast.h:72
bool mBackgroundIsDefined
Definition: Contrast.h:74
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:46
void ContrastDialog::OnGetForeground ( wxCommandEvent &  event)
private

Definition at line 344 of file Contrast.cpp.

References foregrounddB, GetActiveProject(), GetDB(), AudacityProject::GetTracks(), m_pButton_UseCurrentF, mForegroundEndT, mForegroundIsDefined, mForegroundStartT, AudacityProject::mViewInfo, results(), ViewInfo::selectedRegion, SetStartAndEndTime(), NumericTextCtrl::SetValue(), SelectedRegion::t0(), SelectedRegion::t1(), and Track::Wave.

345 {
348 
349  for (Track *t = iter.First(); t; t = iter.Next()) {
352  }
353 
356  m_pButton_UseCurrentF->SetFocus();
357  results();
358 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
bool mForegroundIsDefined
Definition: Contrast.h:73
void results()
Definition: Contrast.cpp:437
wxButton * m_pButton_UseCurrentF
Definition: Contrast.h:36
double t1() const
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetStartAndEndTime()
Definition: Contrast.cpp:113
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:43
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
ViewInfo mViewInfo
Definition: Project.h:558
bool GetDB(float &dB)
Definition: Contrast.cpp:43
void SetValue(double newValue)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
float foregrounddB
Definition: Contrast.h:71
TrackList * GetTracks()
Definition: Project.h:192
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:44
void ContrastDialog::OnGetURL ( wxCommandEvent &  event)
private

Definition at line 329 of file Contrast.cpp.

References HelpSystem::ShowHelp().

330 {
331  // Original help page is back on-line (March 2016), but the manual should be more reliable.
332  // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
333  HelpSystem::ShowHelp(this, wxT("Contrast"));
334 }
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:194
void ContrastDialog::OnReset ( wxCommandEvent &  event)
private

Definition at line 594 of file Contrast.cpp.

References _(), mBackgroundEndT, mBackgroundIsDefined, mBackgroundRMSText, mBackgroundStartT, mDiffText, mForegroundEndT, mForegroundIsDefined, mForegroundRMSText, mForegroundStartT, mPassFailText, and NumericTextCtrl::SetValue().

Referenced by OnClose().

595 {
600  mForegroundIsDefined = false;
601  mBackgroundIsDefined = false;
602 
603  mForegroundRMSText->SetName(_("No foreground measured")); // Read by screen-readers
604  mBackgroundRMSText->SetName(_("No background measured"));
605  mForegroundRMSText->ChangeValue(wxT("")); // Displayed value
606  mBackgroundRMSText->ChangeValue(wxT(""));
607  mPassFailText->ChangeValue(wxT(""));
608  mDiffText->ChangeValue(wxT(""));
609 }
bool mForegroundIsDefined
Definition: Contrast.h:73
wxTextCtrl * mDiffText
Definition: Contrast.h:69
wxTextCtrl * mForegroundRMSText
Definition: Contrast.h:66
wxTextCtrl * mPassFailText
Definition: Contrast.h:68
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:43
wxTextCtrl * mBackgroundRMSText
Definition: Contrast.h:67
void SetValue(double newValue)
_("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
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:45
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:44
bool mBackgroundIsDefined
Definition: Contrast.h:74
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:46
void ContrastDialog::results ( )
private

Definition at line 437 of file Contrast.cpp.

References _(), backgrounddB, DB_MAX_LIMIT, foregrounddB, mBackgroundIsDefined, mBackgroundRMSText, mDiffText, mForegroundIsDefined, mForegroundRMSText, mPassFailText, and WCAG2_PASS.

Referenced by OnGetBackground(), and OnGetForeground().

438 {
439  mPassFailText->SetName(wxT(""));
440  mPassFailText->ChangeValue(wxT(""));
441  mDiffText->ChangeValue(wxT(""));
442 
443  // foreground and background defined.
445  float diffdB = std::fabs(foregrounddB - backgrounddB);
446  if(foregrounddB > DB_MAX_LIMIT) {
447  mPassFailText->ChangeValue(_("Foreground level too high"));
448  }
449  else if (backgrounddB > DB_MAX_LIMIT) {
450  mPassFailText->ChangeValue(_("Background level too high"));
451  }
452  else if (backgrounddB > foregrounddB) {
453  mPassFailText->ChangeValue(_("Background higher than foreground"));
454  }
455  else if(diffdB > WCAG2_PASS) {
456  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
457  mPassFailText->ChangeValue(_("WCAG2 Pass"));
458  }
459  else {
460  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
461  mPassFailText->ChangeValue(_("WCAG2 Fail"));
462  }
463 
464  /* i18n-hint: i.e. difference in loudness at the moment. */
465  mDiffText->SetName(_("Current difference"));
466  mDiffText->ChangeValue( FormatDifference( diffdB ) );
467  }
468 
469  if (mForegroundIsDefined) {
470  mForegroundRMSText->SetName(_("Measured foreground level")); // Read by screen-readers
471  if(std::isinf(- foregrounddB))
472  mForegroundRMSText->ChangeValue(_("zero"));
473  else
474  mForegroundRMSText->ChangeValue(wxString::Format(_("%.2f dB"), foregrounddB)); // i18n-hint: short form of 'decibels'
475  }
476  else {
477  mForegroundRMSText->SetName(_("No foreground measured")); // Read by screen-readers
478  mForegroundRMSText->ChangeValue(wxT(""));
479  mPassFailText->ChangeValue(_("Foreground not yet measured"));
480  }
481 
482  if (mBackgroundIsDefined) {
483  mBackgroundRMSText->SetName(_("Measured background level"));
484  if(std::isinf(- backgrounddB))
485  mBackgroundRMSText->ChangeValue(_("zero"));
486  else
487  mBackgroundRMSText->ChangeValue(wxString::Format(_("%.2f dB"), backgrounddB));
488  }
489  else {
490  mBackgroundRMSText->SetName(_("No background measured"));
491  mBackgroundRMSText->ChangeValue(wxT(""));
492  mPassFailText->ChangeValue(_("Background not yet measured"));
493  }
494 }
#define WCAG2_PASS
Definition: Contrast.cpp:40
bool mForegroundIsDefined
Definition: Contrast.h:73
wxTextCtrl * mDiffText
Definition: Contrast.h:69
#define DB_MAX_LIMIT
Definition: Contrast.cpp:39
wxTextCtrl * mForegroundRMSText
Definition: Contrast.h:66
wxTextCtrl * mPassFailText
Definition: Contrast.h:68
wxTextCtrl * mBackgroundRMSText
Definition: Contrast.h:67
_("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
float foregrounddB
Definition: Contrast.h:71
float backgrounddB
Definition: Contrast.h:72
bool mBackgroundIsDefined
Definition: Contrast.h:74
void ContrastDialog::SetStartAndEndTime ( )
private

Definition at line 113 of file Contrast.cpp.

References GetActiveProject(), mT0, mT1, AudacityProject::mViewInfo, ViewInfo::selectedRegion, SelectedRegion::t0(), and SelectedRegion::t1().

Referenced by OnGetBackground(), and OnGetForeground().

114 {
118 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
double mT1
Definition: Contrast.h:49
double t1() const
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
ViewInfo mViewInfo
Definition: Project.h:558
double mT0
Definition: Contrast.h:48
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308

Member Data Documentation

float ContrastDialog::backgrounddB
private

Definition at line 72 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetBackground(), and results().

float ContrastDialog::foregrounddB
private

Definition at line 71 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetForeground(), and results().

double ContrastDialog::length
private

Definition at line 82 of file Contrast.h.

wxButton* ContrastDialog::m_pButton_Close

Definition at line 41 of file Contrast.h.

Referenced by ContrastDialog().

wxButton* ContrastDialog::m_pButton_Export

Definition at line 39 of file Contrast.h.

Referenced by ContrastDialog().

wxButton* ContrastDialog::m_pButton_GetURL

Definition at line 38 of file Contrast.h.

Referenced by ContrastDialog().

wxButton* ContrastDialog::m_pButton_Reset

Definition at line 40 of file Contrast.h.

Referenced by ContrastDialog().

wxButton* ContrastDialog::m_pButton_UseCurrentB

Definition at line 37 of file Contrast.h.

Referenced by ContrastDialog(), and OnGetBackground().

wxButton* ContrastDialog::m_pButton_UseCurrentF

Definition at line 36 of file Contrast.h.

Referenced by ContrastDialog(), and OnGetForeground().

NumericTextCtrl* ContrastDialog::mBackgroundEndT

Definition at line 46 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetBackground(), and OnReset().

bool ContrastDialog::mBackgroundIsDefined
private

Definition at line 74 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetBackground(), OnReset(), and results().

wxTextCtrl* ContrastDialog::mBackgroundRMSText
private

Definition at line 67 of file Contrast.h.

Referenced by ContrastDialog(), OnReset(), and results().

NumericTextCtrl* ContrastDialog::mBackgroundStartT

Definition at line 45 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetBackground(), and OnReset().

wxTextCtrl* ContrastDialog::mDiffText
private

Definition at line 69 of file Contrast.h.

Referenced by ContrastDialog(), OnReset(), and results().

bool ContrastDialog::mDoBackground
private

Definition at line 78 of file Contrast.h.

double ContrastDialog::mEndTimeB

Definition at line 54 of file Contrast.h.

double ContrastDialog::mEndTimeF

Definition at line 52 of file Contrast.h.

NumericTextCtrl* ContrastDialog::mForegroundEndT

Definition at line 44 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetForeground(), and OnReset().

bool ContrastDialog::mForegroundIsDefined
private

Definition at line 73 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetForeground(), OnReset(), and results().

wxTextCtrl* ContrastDialog::mForegroundRMSText
private

Definition at line 66 of file Contrast.h.

Referenced by ContrastDialog(), OnReset(), and results().

NumericTextCtrl* ContrastDialog::mForegroundStartT

Definition at line 43 of file Contrast.h.

Referenced by ContrastDialog(), OnExport(), OnGetForeground(), and OnReset().

wxTextCtrl* ContrastDialog::mPassFailText
private

Definition at line 68 of file Contrast.h.

Referenced by ContrastDialog(), OnReset(), and results().

double ContrastDialog::mProjectRate

Definition at line 50 of file Contrast.h.

Referenced by ContrastDialog().

double ContrastDialog::mStartTimeB

Definition at line 53 of file Contrast.h.

double ContrastDialog::mStartTimeF

Definition at line 51 of file Contrast.h.

double ContrastDialog::mT0

Definition at line 48 of file Contrast.h.

Referenced by ContrastDialog(), GetDB(), and SetStartAndEndTime().

double ContrastDialog::mT0orig
private

Definition at line 75 of file Contrast.h.

double ContrastDialog::mT1

Definition at line 49 of file Contrast.h.

Referenced by ContrastDialog(), GetDB(), and SetStartAndEndTime().

double ContrastDialog::mT1orig
private

Definition at line 76 of file Contrast.h.


The documentation for this class was generated from the following files: