Audacity  2.3.1
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 169 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.

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

Referenced by OnGetBackground(), and OnGetForeground().

44 {
45  float rms = float(0.0);
46 
47  // For stereo tracks: sqrt((mean(L)+mean(R))/2)
48  double meanSq = 0.0;
49 
51  auto range =
52  p->GetTracks()->SelectedLeaders< const WaveTrack >();
53  auto numberSelectedTracks = range.size();
54  if (numberSelectedTracks > 1) {
55  AudacityMessageDialog m(NULL, _("You can only measure one track at a time."), _("Error"), wxOK);
56  m.ShowModal();
57  return false;
58  }
59  if(numberSelectedTracks == 0) {
60  wxMessageDialog m(NULL, _("Please select an audio track."), _("Error"), wxOK);
61  m.ShowModal();
62  return false;
63  }
64 
65  const auto channels = TrackList::Channels( *range.begin() );
66  for ( auto t : channels ) {
67  wxASSERT(mT0 <= mT1);
68 
69  // Ignore whitespace beyond ends of track.
70  if(mT0 < t->GetStartTime())
71  mT0 = t->GetStartTime();
72  if(mT1 > t->GetEndTime())
73  mT1 = t->GetEndTime();
74 
75  auto SelT0 = t->TimeToLongSamples(mT0);
76  auto SelT1 = t->TimeToLongSamples(mT1);
77 
78  if(SelT0 > SelT1)
79  {
80  AudacityMessageDialog m(NULL, _("Invalid audio selection.\nPlease ensure that audio is selected."), _("Error"), wxOK);
81  m.ShowModal();
82  return false;
83  }
84 
85  if(SelT0 == SelT1)
86  {
87  AudacityMessageDialog m(NULL, _("Nothing to measure.\nPlease select a section of a track."), _("Error"), wxOK);
88  m.ShowModal();
89  return false;
90  }
91 
92  // Don't throw in this analysis dialog
93  rms = t->GetRMS(mT0, mT1, false);
94  meanSq += rms * rms;
95  }
96  // TODO: This works for stereo, provided the audio clips are in both channels.
97  // We should really count gaps between clips as silence.
98  rms = (meanSq > 0.0)
99  ? sqrt( meanSq/static_cast<double>( channels.size() ) )
100  : 0.0;
101 
102  // Gives warning C4056, Overflow in floating-point constant arithmetic
103  // -INFINITY is intentional here.
104  // Looks like we are stuck with this warning, as
105  // #pragma warning( disable : 4056)
106  // even around the whole function does not disable it successfully.
107 
108  dB = (rms == 0.0)? -INFINITY : LINEAR_TO_DB(rms);
109  return true;
110 }
double mT1
Definition: Contrast.h:49
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1297
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:174
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:311
TrackList * GetTracks()
Definition: Project.h:209
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1356
void ContrastDialog::OnClose ( wxCommandEvent &  event)
private

Definition at line 335 of file Contrast.cpp.

References OnReset().

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

Definition at line 493 of file Contrast.cpp.

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

494 {
495  // TODO: Handle silence checks better (-infinity dB)
496  AudacityProject * project = GetActiveProject();
497  wxString fName = wxT("contrast.txt");
498 
500  _("Export Contrast Result As:"),
501  wxEmptyString,
502  fName,
503  wxT("txt"),
504  wxT("*.txt"),
505  wxFD_SAVE | wxRESIZE_BORDER,
506  this);
507 
508  if (fName == wxT(""))
509  return;
510 
511  wxTextFile f(fName);
512 #ifdef __WXMAC__
513  wxFile{}.Create(fName);
514 #else
515  f.Create();
516 #endif
517  f.Open();
518  if (!f.IsOpened()) {
520  wxString::Format( _("Couldn't write to file: %s"), fName) );
521  return;
522  }
523 
524  f.AddLine(wxT("==================================="));
525  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
526  f.AddLine(_("WCAG 2.0 Success Criteria 1.4.7 Contrast Results"));
527  f.AddLine(wxT(""));
528  f.AddLine(wxString::Format(_("Filename = %s."), project->GetFileName() ));
529  f.AddLine(wxT(""));
530  f.AddLine(_("Foreground"));
531  float t = (float)mForegroundStartT->GetValue();
532  int h = (int)(t/3600); // there must be a standard function for this!
533  int m = (int)((t - h*3600)/60);
534  float s = t - h*3600.0 - m*60.0;
535  f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
536  t = (float)mForegroundEndT->GetValue();
537  h = (int)(t/3600);
538  m = (int)((t - h*3600)/60);
539  s = t - h*3600.0 - m*60.0;
540  f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
541  f.AddLine( FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) );
542  f.AddLine(wxT(""));
543  f.AddLine(_("Background"));
544  t = (float)mBackgroundStartT->GetValue();
545  h = (int)(t/3600);
546  m = (int)((t - h*3600)/60);
547  s = t - h*3600.0 - m*60.0;
548  f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
549  t = (float)mBackgroundEndT->GetValue();
550  h = (int)(t/3600);
551  m = (int)((t - h*3600)/60);
552  s = t - h*3600.0 - m*60.0;
553  f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
554  f.AddLine( FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) );
555  f.AddLine(wxT(""));
556  f.AddLine(_("Results"));
557  float diffdB = foregrounddB - backgrounddB;
558 
559  f.AddLine( FormatDifferenceForExport( diffdB ) );
560  if( diffdB > 20. )
561  f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Pass"));
562  else
563  f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Fail"));
564 
565  f.AddLine(wxT(""));
566  f.AddLine(_("Data gathered"));
567  wxString sNow;
568  wxDateTime now = wxDateTime::Now();
569  int year = now.GetYear();
570  wxDateTime::Month month = now.GetMonth();
571  wxString monthName = now.GetMonthName(month);
572  int dom = now.GetDay();
573  int hour = now.GetHour();
574  int minute = now.GetMinute();
575  int second = now.GetSecond();
576  sNow = wxString::Format(wxT("%d %s %02d %02dh %02dm %02ds"),
577  dom, monthName, year, hour, minute, second);
578  f.AddLine(sNow);
579 
580  f.AddLine(wxT("==================================="));
581  f.AddLine(wxT(""));
582 
583 #ifdef __WXMAC__
584  f.Write(wxTextFileType_Mac);
585 #else
586  f.Write();
587 #endif
588  f.Close();
589 }
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:174
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:425
_("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:311
float foregrounddB
Definition: Contrast.h:71
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:45
float backgrounddB
Definition: Contrast.h:72
const wxString & GetFileName()
Definition: Project.h:319
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 358 of file Contrast.cpp.

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

359 {
361 
362  if( p->GetTracks()->Selected< const WaveTrack >() ) {
365  }
366 
369  m_pButton_UseCurrentB->SetFocus();
370  results();
371 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:162
void results()
Definition: Contrast.cpp:434
double t1() const
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1263
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
void SetStartAndEndTime()
Definition: Contrast.cpp:112
wxButton * m_pButton_UseCurrentB
Definition: Contrast.h:37
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
ViewInfo mViewInfo
Definition: Project.h:555
bool GetDB(float &dB)
Definition: Contrast.cpp:43
void SetValue(double newValue)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
TrackList * GetTracks()
Definition: Project.h:209
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 343 of file Contrast.cpp.

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

344 {
346 
347  if( p->GetTracks()->Selected< const WaveTrack >() ) {
350  }
351 
354  m_pButton_UseCurrentF->SetFocus();
355  results();
356 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:162
bool mForegroundIsDefined
Definition: Contrast.h:73
void results()
Definition: Contrast.cpp:434
wxButton * m_pButton_UseCurrentF
Definition: Contrast.h:36
double t1() const
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1263
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
void SetStartAndEndTime()
Definition: Contrast.cpp:112
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:43
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
ViewInfo mViewInfo
Definition: Project.h:555
bool GetDB(float &dB)
Definition: Contrast.cpp:43
void SetValue(double newValue)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
float foregrounddB
Definition: Contrast.h:71
TrackList * GetTracks()
Definition: Project.h:209
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:44
void ContrastDialog::OnGetURL ( wxCommandEvent &  event)
private

Definition at line 328 of file Contrast.cpp.

References HelpSystem::ShowHelp().

329 {
330  // Original help page is back on-line (March 2016), but the manual should be more reliable.
331  // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
332  HelpSystem::ShowHelp(this, wxT("Contrast"));
333 }
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 591 of file Contrast.cpp.

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

Referenced by OnClose().

592 {
597  mForegroundIsDefined = false;
598  mBackgroundIsDefined = false;
599 
600  mForegroundRMSText->SetName(_("No foreground measured")); // Read by screen-readers
601  mBackgroundRMSText->SetName(_("No background measured"));
602  mForegroundRMSText->ChangeValue(wxT("")); // Displayed value
603  mBackgroundRMSText->ChangeValue(wxT(""));
604  mPassFailText->ChangeValue(wxT(""));
605  mDiffText->ChangeValue(wxT(""));
606 }
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 434 of file Contrast.cpp.

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

Referenced by OnGetBackground(), and OnGetForeground().

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

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

Referenced by OnGetBackground(), and OnGetForeground().

113 {
117 }
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:162
double mT1
Definition: Contrast.h:49
double t1() const
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
ViewInfo mViewInfo
Definition: Project.h:555
double mT0
Definition: Contrast.h:48
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311

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: