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

#include <Contrast.h>

Inheritance diagram for ContrastDialog:
[legend]
Collaboration diagram for ContrastDialog:
[legend]

Public Member Functions

 ContrastDialog (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- 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 OnChar (wxKeyEvent &event)
 
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 27 of file Contrast.h.

Constructor & Destructor Documentation

◆ ContrastDialog()

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

Definition at line 193 of file Contrast.cpp.

195  :
196  wxDialogWrapper(parent, id, title, pos, wxDefaultSize,
197  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX )
198 {
199  SetName();
200 
201  mT0 = 0.0;
202  mT1 = 0.0;
203  foregrounddB = 0.0;
204  backgrounddB = 0.0;
205  mForegroundIsDefined = false;
206  mBackgroundIsDefined = false;
207 
208  // NULL out the control members until the controls are created.
209  mForegroundStartT = NULL;
210  mForegroundEndT = NULL;
211  mBackgroundStartT = NULL;
212  mBackgroundEndT = NULL;
213  wxString number;
214 
215  auto p = FindProjectFromWindow( this );
217 
218  const auto options = NumericTextCtrl::Options{}
219  .AutoPos(true)
220  .MenuEnabled(false)
221  .ReadOnly(true);
222 
223  ShuttleGui S(this, eIsCreating);
224 
225  S.SetBorder(5);
226  S.StartHorizontalLay(wxCENTER, false);
227  {
228  S.AddTitle(
229  /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
230  XO("Contrast Analyzer, for measuring RMS volume differences between two selections of audio."));
231  }
232  S.EndHorizontalLay();
233  S.StartStatic( XO("Parameters") );
234  {
235  S.StartMultiColumn(5, wxEXPAND);
236  {
237 
238  // Headings
239  S.AddFixedText( {} ); // spacer
240  S.AddFixedText(XO("Start"));
241  S.AddFixedText(XO("End"));
242  S.AddFixedText( {} ); // spacer
243  S.AddFixedText(XO("Volume "));
244 
245  //Foreground
246  S.AddFixedText(XO("&Foreground:"), false);
247  if (S.GetMode() == eIsCreating)
248  {
250  NumericTextCtrl(S.GetParent(), ID_FOREGROUNDSTART_T,
253  0.0,
254  mProjectRate,
255  options);
256  }
257  S.Name(XO("Foreground start time"))
258  .AddWindow(mForegroundStartT);
259 
260  if (S.GetMode() == eIsCreating)
261  {
263  NumericTextCtrl(S.GetParent(), ID_FOREGROUNDEND_T,
266  0.0,
267  mProjectRate,
268  options);
269  }
270  S.Name(XO("Foreground end time"))
271  .AddWindow(mForegroundEndT);
272 
273  m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(XXO("&Measure selection"));
275  .ConnectRoot(wxEVT_KEY_DOWN,
277  .AddTextBox( {}, wxT(""), 17);
278 
279  //Background
280  S.AddFixedText(XO("&Background:"));
281  if (S.GetMode() == eIsCreating)
282  {
284  NumericTextCtrl(S.GetParent(), ID_BACKGROUNDSTART_T,
287  0.0,
288  mProjectRate,
289  options);
290  }
291  S.Name(XO("Background start time"))
292  .AddWindow(mBackgroundStartT);
293 
294  if (S.GetMode() == eIsCreating)
295  {
297  NumericTextCtrl(S.GetParent(), ID_BACKGROUNDEND_T,
300  0.0,
301  mProjectRate,
302  options);
303  }
304  S.Name(XO("Background end time"))
305  .AddWindow(mBackgroundEndT);
306 
307  m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(XXO("Mea&sure selection"));
309  .ConnectRoot(wxEVT_KEY_DOWN,
311  .AddTextBox( {}, wxT(""), 17);
312  }
313  S.EndMultiColumn();
314  }
315  S.EndStatic();
316 
317  //Result
318  S.StartStatic( XO("Result") );
319  {
320  S.StartMultiColumn(3, wxCENTER);
321  {
322  auto label = XO("Co&ntrast Result:");
323  S.AddFixedText(label);
325  .Name(label)
326  .ConnectRoot(wxEVT_KEY_DOWN,
328  .AddTextBox( {}, wxT(""), 50);
329  m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(XXO("R&eset"));
330 
331  label = XO("&Difference:");
332  S.AddFixedText(label);
334  .Name(label)
335  .ConnectRoot(wxEVT_KEY_DOWN,
337  .AddTextBox( {}, wxT(""), 50);
338  m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(XXO("E&xport..."));
339  }
340  S.EndMultiColumn();
341  }
342  S.EndStatic();
343  S.AddStandardButtons(eCloseButton |eHelpButton);
344 #if 0
345  S.StartMultiColumn(3, wxEXPAND);
346  {
347  S.SetStretchyCol(1);
348  m_pButton_GetURL = S.Id(ID_BUTTON_GETURL).AddButton(XO("&Help"));
349  S.AddFixedText({}); // spacer
350  m_pButton_Close = S.Id(ID_BUTTON_CLOSE).AddButton(XO("&Close"));
351  }
352  S.EndMultiColumn();
353 #endif
354  Layout();
355  Fit();
356  SetMinSize(GetSize());
357  Center();
358 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTitle(), ShuttleGuiBase::AddWindow(), NumericTextCtrl::Options::AutoPos(), backgrounddB, ShuttleGui::ConnectRoot(), eCloseButton, eHelpButton, eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), FindProjectFromWindow(), foregrounddB, ProjectRate::Get(), ShuttleGui::GetMode(), ShuttleGuiBase::GetParent(), ProjectRate::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, ShuttleGui::Name(), OnChar(), NumericTextCtrl::Options::ReadOnly(), safenew, ShuttleGuiBase::SetBorder(), wxDialogWrapper::SetName(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), NumericConverter::TIME, XO, and XXO.

Here is the call graph for this function:

Member Function Documentation

◆ GetDB()

bool ContrastDialog::GetDB ( float &  dB)
private

Definition at line 51 of file Contrast.cpp.

52 {
53  float rms = float(0.0);
54 
55  // For stereo tracks: sqrt((mean(L)+mean(R))/2)
56  double meanSq = 0.0;
57 
58  auto p = FindProjectFromWindow( this );
59  auto range =
60  TrackList::Get( *p ).SelectedLeaders< const WaveTrack >();
61  auto numberSelectedTracks = range.size();
62  if (numberSelectedTracks > 1) {
64  nullptr,
65  XO("You can only measure one track at a time."),
66  XO("Error"),
67  wxOK);
68  m.ShowModal();
69  return false;
70  }
71  if(numberSelectedTracks == 0) {
73  nullptr,
74  XO("Please select an audio track."),
75  XO("Error"),
76  wxOK);
77  m.ShowModal();
78  return false;
79  }
80 
81  const auto channels = TrackList::Channels( *range.begin() );
82  for ( auto t : channels ) {
83  wxASSERT(mT0 <= mT1);
84 
85  // Ignore whitespace beyond ends of track.
86  if(mT0 < t->GetStartTime())
87  mT0 = t->GetStartTime();
88  if(mT1 > t->GetEndTime())
89  mT1 = t->GetEndTime();
90 
91  auto SelT0 = t->TimeToLongSamples(mT0);
92  auto SelT1 = t->TimeToLongSamples(mT1);
93 
94  if(SelT0 > SelT1)
95  {
97  nullptr,
98  XO("Invalid audio selection.\nPlease ensure that audio is selected."),
99  XO("Error"),
100  wxOK);
101  m.ShowModal();
102  return false;
103  }
104 
105  if(SelT0 == SelT1)
106  {
108  nullptr,
109  XO("Nothing to measure.\nPlease select a section of a track."),
110  XO("Error"),
111  wxOK);
112  m.ShowModal();
113  return false;
114  }
115 
116  // Don't throw in this analysis dialog
117  rms = t->GetRMS(mT0, mT1, false);
118  meanSq += rms * rms;
119  }
120  // TODO: This works for stereo, provided the audio clips are in both channels.
121  // We should really count gaps between clips as silence.
122  rms = (meanSq > 0.0)
123  ? sqrt( meanSq/static_cast<double>( channels.size() ) )
124  : 0.0;
125 
126  // Gives warning C4056, Overflow in floating-point constant arithmetic
127  // -INFINITY is intentional here.
128  // Looks like we are stuck with this warning, as
129  // #pragma warning( disable : 4056)
130  // even around the whole function does not disable it successfully.
131 
132  dB = (rms == 0.0)? -INFINITY : LINEAR_TO_DB(rms);
133  return true;
134 }

References TrackList::Channels(), FindProjectFromWindow(), TrackList::Get(), INFINITY, LINEAR_TO_DB, mT0, mT1, TrackList::SelectedLeaders(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), and XO.

Referenced by OnGetBackground(), and OnGetForeground().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnChar()

void ContrastDialog::OnChar ( wxKeyEvent &  event)
private

Definition at line 179 of file Contrast.cpp.

180 {
181  // Is this still required?
182  if (event.GetKeyCode() == WXK_TAB) {
183  // pass to next handler
184  event.Skip();
185  return;
186  }
187 
188  // ignore any other key
189  event.Skip(false);
190  return;
191 }

Referenced by ContrastDialog().

Here is the caller graph for this function:

◆ OnClose()

void ContrastDialog::OnClose ( wxCommandEvent &  event)
private

Definition at line 367 of file Contrast.cpp.

368 {
369  wxCommandEvent dummyEvent;
370  OnReset(dummyEvent);
371 
372  Show(false);
373 }

References OnReset().

Here is the call graph for this function:

◆ OnExport()

void ContrastDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 529 of file Contrast.cpp.

530 {
531  // TODO: Handle silence checks better (-infinity dB)
532  auto project = FindProjectFromWindow( this );
533  wxString fName = wxT("contrast.txt");
534 
535  fName = SelectFile(FileNames::Operation::Export,
536  XO("Export Contrast Result As:"),
537  wxEmptyString,
538  fName,
539  wxT("txt"),
541  wxFD_SAVE | wxRESIZE_BORDER,
542  this);
543 
544  if (fName.empty())
545  return;
546 
547  wxFFileOutputStream ffStream{ fName };
548 
549  if (!ffStream.IsOk()) {
550  AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
551  return;
552  }
553 
554  wxTextOutputStream ss(ffStream);
555 
556  ss
557  << wxT("===================================") << '\n'
558  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
559  << XO("WCAG 2.0 Success Criteria 1.4.7 Contrast Results") << '\n'
560  << '\n'
561  << XO("Filename = %s.").Format( ProjectFileIO::Get(*project).GetFileName() ) << '\n'
562  << '\n'
563  << XO("Foreground") << '\n';
564 
565  float t = (float)mForegroundStartT->GetValue();
566  int h = (int)(t/3600); // there must be a standard function for this!
567  int m = (int)((t - h*3600)/60);
568  float s = t - h*3600.0 - m*60.0;
569 
570  ss
571  << XO("Time started = %2d hour(s), %2d minute(s), %.2f seconds.")
572  .Format( h, m, s ) << '\n';
573 
574  t = (float)mForegroundEndT->GetValue();
575  h = (int)(t/3600);
576  m = (int)((t - h*3600)/60);
577  s = t - h*3600.0 - m*60.0;
578 
579  ss
580  << XO("Time ended = %2d hour(s), %2d minute(s), %.2f seconds.")
581  .Format( h, m, s ) << '\n'
582  << FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) << '\n'
583  << '\n'
584  << XO("Background") << '\n';
585 
586  t = (float)mBackgroundStartT->GetValue();
587  h = (int)(t/3600);
588  m = (int)((t - h*3600)/60);
589  s = t - h*3600.0 - m*60.0;
590 
591  ss
592  << XO("Time started = %2d hour(s), %2d minute(s), %.2f seconds.")
593  .Format( h, m, s ) << '\n';
594 
595  t = (float)mBackgroundEndT->GetValue();
596  h = (int)(t/3600);
597  m = (int)((t - h*3600)/60);
598  s = t - h*3600.0 - m*60.0;
599 
600  ss
601  << XO("Time ended = %2d hour(s), %2d minute(s), %.2f seconds.")
602  .Format( h, m, s ) << '\n'
603  << FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) << '\n'
604  << '\n'
605  << XO("Results") << '\n';
606 
607  float diffdB = foregrounddB - backgrounddB;
608 
609  ss
610  << FormatDifferenceForExport( diffdB ) << '\n'
611  << (( diffdB > 20. )
612  ? XO("Success Criteria 1.4.7 of WCAG 2.0: Pass")
613  : XO("Success Criteria 1.4.7 of WCAG 2.0: Fail")) << '\n'
614  << '\n'
615  << XO("Data gathered") << '\n';
616 
617  wxDateTime now = wxDateTime::Now();
618  int year = now.GetYear();
619  wxDateTime::Month month = now.GetMonth();
620  wxString monthName = now.GetMonthName(month);
621  int dom = now.GetDay();
622  int hour = now.GetHour();
623  int minute = now.GetMinute();
624  int second = now.GetSecond();
625  /* i18n-hint: day of month, month, year, hour, minute, second */
626  auto sNow = XO("%d %s %02d %02dh %02dm %02ds")
627  .Format( dom, monthName, year, hour, minute, second );
628 
629  ss <<
630  sNow << '\n'
631  << wxT("===================================") << '\n'
632  << '\n';
633 }

References FileNames::AllFiles, AudacityMessageBox(), backgrounddB, FindProjectFromWindow(), foregrounddB, anonymous_namespace{Contrast.cpp}::FormatDifferenceForExport(), anonymous_namespace{Contrast.cpp}::FormatRMSMessage(), ProjectFileIO::Get(), ProjectFileIO::GetFileName(), NumericConverter::GetValue(), mBackgroundEndT, mBackgroundIsDefined, mBackgroundStartT, mForegroundEndT, mForegroundIsDefined, mForegroundStartT, SelectFile(), FileNames::TextFiles, and XO.

Here is the call graph for this function:

◆ OnGetBackground()

void ContrastDialog::OnGetBackground ( wxCommandEvent &  event)
private

Definition at line 391 of file Contrast.cpp.

392 {
393  auto p = FindProjectFromWindow( this );
394  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
395 
396  if( TrackList::Get( *p ).Selected< const WaveTrack >() ) {
397  mBackgroundStartT->SetValue(selectedRegion.t0());
398  mBackgroundEndT->SetValue(selectedRegion.t1());
399  }
400 
403  m_pButton_UseCurrentB->SetFocus();
404  results();
405 }

References backgrounddB, FindProjectFromWindow(), ViewInfo::Get(), TrackList::Get(), GetDB(), m_pButton_UseCurrentB, mBackgroundEndT, mBackgroundIsDefined, mBackgroundStartT, results(), TrackList::Selected(), ViewInfo::selectedRegion, SetStartAndEndTime(), and NumericTextCtrl::SetValue().

Here is the call graph for this function:

◆ OnGetForeground()

void ContrastDialog::OnGetForeground ( wxCommandEvent &  event)
private

Definition at line 375 of file Contrast.cpp.

376 {
377  auto p = FindProjectFromWindow( this );
378  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
379 
380  if( TrackList::Get( *p ).Selected< const WaveTrack >() ) {
381  mForegroundStartT->SetValue(selectedRegion.t0());
382  mForegroundEndT->SetValue(selectedRegion.t1());
383  }
384 
387  m_pButton_UseCurrentF->SetFocus();
388  results();
389 }

References FindProjectFromWindow(), foregrounddB, ViewInfo::Get(), TrackList::Get(), GetDB(), m_pButton_UseCurrentF, mForegroundEndT, mForegroundIsDefined, mForegroundStartT, results(), TrackList::Selected(), ViewInfo::selectedRegion, SetStartAndEndTime(), and NumericTextCtrl::SetValue().

Here is the call graph for this function:

◆ OnGetURL()

void ContrastDialog::OnGetURL ( wxCommandEvent &  event)
private

Definition at line 360 of file Contrast.cpp.

361 {
362  // Original help page is back on-line (March 2016), but the manual should be more reliable.
363  // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
364  HelpSystem::ShowHelp(this, L"Contrast");
365 }

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnReset()

void ContrastDialog::OnReset ( wxCommandEvent &  event)
private

Definition at line 635 of file Contrast.cpp.

636 {
641  mForegroundIsDefined = false;
642  mBackgroundIsDefined = false;
643 
644  mForegroundRMSText->SetName(_("No foreground measured")); // Read by screen-readers
645  mBackgroundRMSText->SetName(_("No background measured"));
646  mForegroundRMSText->ChangeValue(wxT("")); // Displayed value
647  mBackgroundRMSText->ChangeValue(wxT(""));
648  mPassFailText->ChangeValue(wxT(""));
649  mDiffText->ChangeValue(wxT(""));
650 }

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

Referenced by OnClose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ results()

void ContrastDialog::results ( )
private

Definition at line 469 of file Contrast.cpp.

470 {
471  mPassFailText->SetName(wxT(""));
472  mPassFailText->ChangeValue(wxT(""));
473  mDiffText->ChangeValue(wxT(""));
474 
475  // foreground and background defined.
477  float diffdB = std::fabs(foregrounddB - backgrounddB);
478  if(foregrounddB > DB_MAX_LIMIT) {
479  mPassFailText->ChangeValue(_("Foreground level too high"));
480  }
481  else if (backgrounddB > DB_MAX_LIMIT) {
482  mPassFailText->ChangeValue(_("Background level too high"));
483  }
484  else if (backgrounddB > foregrounddB) {
485  mPassFailText->ChangeValue(_("Background higher than foreground"));
486  }
487  else if(diffdB > WCAG2_PASS) {
488  /* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */
489  mPassFailText->ChangeValue(_("WCAG2 Pass"));
490  }
491  else {
492  /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
493  mPassFailText->ChangeValue(_("WCAG2 Fail"));
494  }
495 
496  /* i18n-hint: i.e. difference in loudness at the moment. */
497  mDiffText->SetName(_("Current difference"));
498  mDiffText->ChangeValue( FormatDifference( diffdB ).Translation() );
499  }
500 
501  if (mForegroundIsDefined) {
502  mForegroundRMSText->SetName(_("Measured foreground level")); // Read by screen-readers
503  if(std::isinf(- foregrounddB))
504  mForegroundRMSText->ChangeValue(_("zero"));
505  else
506  // i18n-hint: short form of 'decibels'
507  mForegroundRMSText->ChangeValue(wxString::Format(_("%.2f dB"), foregrounddB));
508  }
509  else {
510  mForegroundRMSText->SetName(_("No foreground measured")); // Read by screen-readers
511  mForegroundRMSText->ChangeValue(wxT(""));
512  mPassFailText->ChangeValue(_("Foreground not yet measured"));
513  }
514 
515  if (mBackgroundIsDefined) {
516  mBackgroundRMSText->SetName(_("Measured background level"));
517  if(std::isinf(- backgrounddB))
518  mBackgroundRMSText->ChangeValue(_("zero"));
519  else
520  mBackgroundRMSText->ChangeValue(wxString::Format(_("%.2f dB"), backgrounddB));
521  }
522  else {
523  mBackgroundRMSText->SetName(_("No background measured"));
524  mBackgroundRMSText->ChangeValue(wxT(""));
525  mPassFailText->ChangeValue(_("Background not yet measured"));
526  }
527 }

References _, backgrounddB, DB_MAX_LIMIT, foregrounddB, anonymous_namespace{Contrast.cpp}::FormatDifference(), mBackgroundIsDefined, mBackgroundRMSText, mDiffText, mForegroundIsDefined, mForegroundRMSText, mPassFailText, and WCAG2_PASS.

Referenced by OnGetBackground(), and OnGetForeground().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetStartAndEndTime()

void ContrastDialog::SetStartAndEndTime ( )
private

Definition at line 136 of file Contrast.cpp.

137 {
138  auto p = FindProjectFromWindow( this );
139  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
140  mT0 = selectedRegion.t0();
141  mT1 = selectedRegion.t1();
142 }

References FindProjectFromWindow(), ViewInfo::Get(), mT0, mT1, and ViewInfo::selectedRegion.

Referenced by OnGetBackground(), and OnGetForeground().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ backgrounddB

float ContrastDialog::backgrounddB
private

Definition at line 71 of file Contrast.h.

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

◆ foregrounddB

float ContrastDialog::foregrounddB
private

Definition at line 70 of file Contrast.h.

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

◆ length

double ContrastDialog::length
private

Definition at line 81 of file Contrast.h.

◆ m_pButton_Close

wxButton* ContrastDialog::m_pButton_Close

Definition at line 39 of file Contrast.h.

Referenced by ContrastDialog().

◆ m_pButton_Export

wxButton* ContrastDialog::m_pButton_Export

Definition at line 37 of file Contrast.h.

Referenced by ContrastDialog().

◆ m_pButton_GetURL

wxButton* ContrastDialog::m_pButton_GetURL

Definition at line 36 of file Contrast.h.

Referenced by ContrastDialog().

◆ m_pButton_Reset

wxButton* ContrastDialog::m_pButton_Reset

Definition at line 38 of file Contrast.h.

Referenced by ContrastDialog().

◆ m_pButton_UseCurrentB

wxButton* ContrastDialog::m_pButton_UseCurrentB

Definition at line 35 of file Contrast.h.

Referenced by ContrastDialog(), and OnGetBackground().

◆ m_pButton_UseCurrentF

wxButton* ContrastDialog::m_pButton_UseCurrentF

Definition at line 34 of file Contrast.h.

Referenced by ContrastDialog(), and OnGetForeground().

◆ mBackgroundEndT

NumericTextCtrl* ContrastDialog::mBackgroundEndT

Definition at line 44 of file Contrast.h.

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

◆ mBackgroundIsDefined

bool ContrastDialog::mBackgroundIsDefined
private

Definition at line 73 of file Contrast.h.

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

◆ mBackgroundRMSText

wxTextCtrl* ContrastDialog::mBackgroundRMSText
private

Definition at line 66 of file Contrast.h.

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

◆ mBackgroundStartT

NumericTextCtrl* ContrastDialog::mBackgroundStartT

Definition at line 43 of file Contrast.h.

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

◆ mDiffText

wxTextCtrl* ContrastDialog::mDiffText
private

Definition at line 68 of file Contrast.h.

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

◆ mDoBackground

bool ContrastDialog::mDoBackground
private

Definition at line 77 of file Contrast.h.

◆ mEndTimeB

double ContrastDialog::mEndTimeB

Definition at line 52 of file Contrast.h.

◆ mEndTimeF

double ContrastDialog::mEndTimeF

Definition at line 50 of file Contrast.h.

◆ mForegroundEndT

NumericTextCtrl* ContrastDialog::mForegroundEndT

Definition at line 42 of file Contrast.h.

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

◆ mForegroundIsDefined

bool ContrastDialog::mForegroundIsDefined
private

Definition at line 72 of file Contrast.h.

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

◆ mForegroundRMSText

wxTextCtrl* ContrastDialog::mForegroundRMSText
private

Definition at line 65 of file Contrast.h.

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

◆ mForegroundStartT

NumericTextCtrl* ContrastDialog::mForegroundStartT

Definition at line 41 of file Contrast.h.

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

◆ mPassFailText

wxTextCtrl* ContrastDialog::mPassFailText
private

Definition at line 67 of file Contrast.h.

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

◆ mProjectRate

double ContrastDialog::mProjectRate

Definition at line 48 of file Contrast.h.

Referenced by ContrastDialog().

◆ mStartTimeB

double ContrastDialog::mStartTimeB

Definition at line 51 of file Contrast.h.

◆ mStartTimeF

double ContrastDialog::mStartTimeF

Definition at line 49 of file Contrast.h.

◆ mT0

double ContrastDialog::mT0

Definition at line 46 of file Contrast.h.

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

◆ mT0orig

double ContrastDialog::mT0orig
private

Definition at line 74 of file Contrast.h.

◆ mT1

double ContrastDialog::mT1

Definition at line 47 of file Contrast.h.

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

◆ mT1orig

double ContrastDialog::mT1orig
private

Definition at line 75 of file Contrast.h.


The documentation for this class was generated from the following files:
ID_BACKGROUNDDB_TEXT
@ ID_BACKGROUNDDB_TEXT
Definition: Contrast.cpp:165
ContrastDialog::mProjectRate
double mProjectRate
Definition: Contrast.h:48
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
ContrastDialog::mBackgroundEndT
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:44
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
ContrastDialog::mDiffText
wxTextCtrl * mDiffText
Definition: Contrast.h:68
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ContrastDialog::m_pButton_UseCurrentF
wxButton * m_pButton_UseCurrentF
Definition: Contrast.h:34
ProjectFileIO::GetFileName
const FilePath & GetFileName() const
Definition: ProjectFileIO.cpp:1502
ContrastDialog::mBackgroundIsDefined
bool mBackgroundIsDefined
Definition: Contrast.h:73
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
NumericTextCtrl::Options::AutoPos
Options & AutoPos(bool enable)
Definition: NumericTextCtrl.h:190
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:604
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
SelectFile
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
ContrastDialog::m_pButton_Export
wxButton * m_pButton_Export
Definition: Contrast.h:37
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
Format
Abstract base class used in importing a file.
NumericConverter::HundredthsFormat
static NumericFormatSymbol HundredthsFormat()
Definition: NumericTextCtrl.cpp:698
ContrastDialog::mPassFailText
wxTextCtrl * mPassFailText
Definition: Contrast.h:67
XO
#define XO(s)
Definition: Internat.h:31
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:266
ID_BUTTON_RESET
@ ID_BUTTON_RESET
Definition: Contrast.cpp:158
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
INFINITY
#define INFINITY
Definition: ffmpeg-2.3.6-single-header.h:572
ContrastDialog::backgrounddB
float backgrounddB
Definition: Contrast.h:71
FindProjectFromWindow
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
Definition: ProjectWindowBase.cpp:44
ContrastDialog::m_pButton_UseCurrentB
wxButton * m_pButton_UseCurrentB
Definition: Contrast.h:35
FileNames::AllFiles
FILES_API const FileType AllFiles
Definition: FileNames.h:71
NumericTextCtrl
Definition: NumericTextCtrl.h:172
WCAG2_PASS
#define WCAG2_PASS
Definition: Contrast.cpp:48
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
NumericTextCtrl::SetValue
void SetValue(double newValue)
Definition: NumericTextCtrl.cpp:1474
TrackList::SelectedLeaders
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1422
AudacityMessageDialog
Wrap wxMessageDialog so that caption IS translatable.
Definition: wxPanelWrapper.h:215
ContrastDialog::mT0
double mT0
Definition: Contrast.h:46
NumericTextCtrl::Options
Definition: NumericTextCtrl.h:178
ContrastDialog::mForegroundRMSText
wxTextCtrl * mForegroundRMSText
Definition: Contrast.h:65
DB_MAX_LIMIT
#define DB_MAX_LIMIT
Definition: Contrast.cpp:47
ID_BACKGROUNDEND_T
@ ID_BACKGROUNDEND_T
Definition: Contrast.cpp:163
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
XXO
#define XXO(s)
Definition: Internat.h:44
label
TranslatableString label
Definition: Tags.cpp:756
FileNames::TextFiles
FILES_API const FileType TextFiles
Definition: FileNames.h:74
ContrastDialog::GetDB
bool GetDB(float &dB)
Definition: Contrast.cpp:51
ID_BUTTON_USECURRENTF
@ ID_BUTTON_USECURRENTF
Definition: Contrast.cpp:154
ContrastDialog::SetStartAndEndTime
void SetStartAndEndTime()
Definition: Contrast.cpp:136
ID_BUTTON_EXPORT
@ ID_BUTTON_EXPORT
Definition: Contrast.cpp:157
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:52
NumericTextCtrl::Options::MenuEnabled
Options & MenuEnabled(bool enable)
Definition: NumericTextCtrl.h:192
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
anonymous_namespace{Contrast.cpp}::FormatDifference
TranslatableString FormatDifference(float diffdB)
Definition: Contrast.cpp:438
ContrastDialog::results
void results()
Definition: Contrast.cpp:469
ContrastDialog::OnReset
void OnReset(wxCommandEvent &event)
Definition: Contrast.cpp:635
anonymous_namespace{Contrast.cpp}::FormatDifferenceForExport
TranslatableString FormatDifferenceForExport(float diffdB)
Definition: Contrast.cpp:453
ContrastDialog::mBackgroundRMSText
wxTextCtrl * mBackgroundRMSText
Definition: Contrast.h:66
anonymous_namespace{Contrast.cpp}::FormatRMSMessage
TranslatableString FormatRMSMessage(float *pValue)
Definition: Contrast.cpp:413
ContrastDialog::m_pButton_GetURL
wxButton * m_pButton_GetURL
Definition: Contrast.h:36
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
ContrastDialog::m_pButton_Close
wxButton * m_pButton_Close
Definition: Contrast.h:39
_
#define _(s)
Definition: Internat.h:75
ID_BUTTON_USECURRENTB
@ ID_BUTTON_USECURRENTB
Definition: Contrast.cpp:155
ContrastDialog::OnChar
void OnChar(wxKeyEvent &event)
Definition: Contrast.cpp:179
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:610
ID_FOREGROUNDDB_TEXT
@ ID_FOREGROUNDDB_TEXT
Definition: Contrast.cpp:164
NumericTextCtrl::Options::ReadOnly
Options & ReadOnly(bool enable)
Definition: NumericTextCtrl.h:191
ContrastDialog::mT1
double mT1
Definition: Contrast.h:47
ID_RESULTSDB_TEXT
@ ID_RESULTSDB_TEXT
Definition: Contrast.cpp:167
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
ContrastDialog::foregrounddB
float foregrounddB
Definition: Contrast.h:70
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:631
ID_FOREGROUNDEND_T
@ ID_FOREGROUNDEND_T
Definition: Contrast.cpp:161
ContrastDialog::mForegroundStartT
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:41
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
ContrastDialog::mBackgroundStartT
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:43
safenew
#define safenew
Definition: MemoryX.h:10
ID_FOREGROUNDSTART_T
@ ID_FOREGROUNDSTART_T
Definition: Contrast.cpp:160
NumericConverter::GetValue
double GetValue()
Definition: NumericTextCtrl.cpp:1174
ContrastDialog::mForegroundEndT
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:42
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
ID_RESULTS_TEXT
@ ID_RESULTS_TEXT
Definition: Contrast.cpp:166
ID_BACKGROUNDSTART_T
@ ID_BACKGROUNDSTART_T
Definition: Contrast.cpp:162
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
ContrastDialog::m_pButton_Reset
wxButton * m_pButton_Reset
Definition: Contrast.h:38
ContrastDialog::mForegroundIsDefined
bool mForegroundIsDefined
Definition: Contrast.h:72