Audacity  3.0.3
Contrast.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Contrast.cpp
6 
7 \class ContrastDialog
8 \brief Dialog used for Contrast menu item
9 
10 *//*******************************************************************/
11 
12 
13 #include "Contrast.h"
14 
15 #include "../CommonCommandFlags.h"
16 #include "../WaveTrack.h"
17 #include "../Prefs.h"
18 #include "../Project.h"
19 #include "../ProjectFileIO.h"
20 #include "../ProjectSettings.h"
21 #include "../ProjectWindow.h"
22 #include "../ShuttleGui.h"
23 #include "../FileNames.h"
24 #include "../ViewInfo.h"
25 #include "../widgets/HelpSystem.h"
26 #include "../widgets/NumericTextCtrl.h"
27 #include "../widgets/AudacityMessageBox.h"
28 #include "../widgets/ErrorDialog.h"
29 
30 #include <cmath>
31 #include <limits>
32 
33 #if defined(__WXMSW__) && !defined(__CYGWIN__)
34 #include <float.h>
35 #define finite(x) _finite(x)
36 #endif
37 
38 #include <wx/button.h>
39 #include <wx/valtext.h>
40 #include <wx/log.h>
41 #include <wx/wfstream.h>
42 #include <wx/txtstrm.h>
43 
44 #include "../PlatformCompatibility.h"
45 
46 #define DB_MAX_LIMIT 0.0 // Audio is massively distorted.
47 #define WCAG2_PASS 20.0 // dB difference required to pass WCAG2 test.
48 
49 
50 bool ContrastDialog::GetDB(float &dB)
51 {
52  float rms = float(0.0);
53 
54  // For stereo tracks: sqrt((mean(L)+mean(R))/2)
55  double meanSq = 0.0;
56 
57  auto p = FindProjectFromWindow( this );
58  auto range =
59  TrackList::Get( *p ).SelectedLeaders< const WaveTrack >();
60  auto numberSelectedTracks = range.size();
61  if (numberSelectedTracks > 1) {
63  nullptr,
64  XO("You can only measure one track at a time."),
65  XO("Error"),
66  wxOK);
67  m.ShowModal();
68  return false;
69  }
70  if(numberSelectedTracks == 0) {
72  nullptr,
73  XO("Please select an audio track."),
74  XO("Error"),
75  wxOK);
76  m.ShowModal();
77  return false;
78  }
79 
80  const auto channels = TrackList::Channels( *range.begin() );
81  for ( auto t : channels ) {
82  wxASSERT(mT0 <= mT1);
83 
84  // Ignore whitespace beyond ends of track.
85  if(mT0 < t->GetStartTime())
86  mT0 = t->GetStartTime();
87  if(mT1 > t->GetEndTime())
88  mT1 = t->GetEndTime();
89 
90  auto SelT0 = t->TimeToLongSamples(mT0);
91  auto SelT1 = t->TimeToLongSamples(mT1);
92 
93  if(SelT0 > SelT1)
94  {
96  nullptr,
97  XO("Invalid audio selection.\nPlease ensure that audio is selected."),
98  XO("Error"),
99  wxOK);
100  m.ShowModal();
101  return false;
102  }
103 
104  if(SelT0 == SelT1)
105  {
107  nullptr,
108  XO("Nothing to measure.\nPlease select a section of a track."),
109  XO("Error"),
110  wxOK);
111  m.ShowModal();
112  return false;
113  }
114 
115  // Don't throw in this analysis dialog
116  rms = t->GetRMS(mT0, mT1, false);
117  meanSq += rms * rms;
118  }
119  // TODO: This works for stereo, provided the audio clips are in both channels.
120  // We should really count gaps between clips as silence.
121  rms = (meanSq > 0.0)
122  ? sqrt( meanSq/static_cast<double>( channels.size() ) )
123  : 0.0;
124 
125  // Gives warning C4056, Overflow in floating-point constant arithmetic
126  // -INFINITY is intentional here.
127  // Looks like we are stuck with this warning, as
128  // #pragma warning( disable : 4056)
129  // even around the whole function does not disable it successfully.
130 
131  dB = (rms == 0.0)? -INFINITY : LINEAR_TO_DB(rms);
132  return true;
133 }
134 
136 {
137  auto p = FindProjectFromWindow( this );
138  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
139  mT0 = selectedRegion.t0();
140  mT1 = selectedRegion.t1();
141 }
142 
143 
144 // WDR: class implementations
145 
146 //----------------------------------------------------------------------------
147 // ContrastDialog
148 //----------------------------------------------------------------------------
149 
150 // WDR: event table for ContrastDialog
151 
152 enum {
155  //ID_BUTTON_GETURL,
158  //ID_BUTTON_CLOSE,
167 };
168 
169 BEGIN_EVENT_TABLE(ContrastDialog,wxDialogWrapper)
175  EVT_BUTTON(wxID_CANCEL, ContrastDialog::OnClose)
177 
178 void ContrastDialog::OnChar(wxKeyEvent &event)
179 {
180  // Is this still required?
181  if (event.GetKeyCode() == WXK_TAB) {
182  // pass to next handler
183  event.Skip();
184  return;
185  }
186 
187  // ignore any other key
188  event.Skip(false);
189  return;
190 }
191 
192 ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
193  const TranslatableString & title,
194  const wxPoint & pos):
195  wxDialogWrapper(parent, id, title, pos, wxDefaultSize,
196  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX )
197 {
198  SetName();
199 
200  mT0 = 0.0;
201  mT1 = 0.0;
202  foregrounddB = 0.0;
203  backgrounddB = 0.0;
204  mForegroundIsDefined = false;
205  mBackgroundIsDefined = false;
206 
207  // NULL out the control members until the controls are created.
208  mForegroundStartT = NULL;
209  mForegroundEndT = NULL;
210  mBackgroundStartT = NULL;
211  mBackgroundEndT = NULL;
212  wxString number;
213 
214  auto p = FindProjectFromWindow( this );
215  const auto &settings = ProjectSettings::Get( *p );
216  mProjectRate = settings.GetRate();
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  {
253  0.0,
254  mProjectRate,
255  options);
256  }
257  S.Name(XO("Foreground start time"))
259 
260  if (S.GetMode() == eIsCreating)
261  {
266  0.0,
267  mProjectRate,
268  options);
269  }
270  S.Name(XO("Foreground end time"))
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  {
287  0.0,
288  mProjectRate,
289  options);
290  }
291  S.Name(XO("Background start time"))
293 
294  if (S.GetMode() == eIsCreating)
295  {
300  0.0,
301  mProjectRate,
302  options);
303  }
304  S.Name(XO("Background end time"))
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);
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();
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 }
359 
360 void ContrastDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
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, wxT("Contrast"));
365 }
366 
367 void ContrastDialog::OnClose(wxCommandEvent & WXUNUSED(event))
368 {
369  wxCommandEvent dummyEvent;
370  OnReset(dummyEvent);
371 
372  Show(false);
373 }
374 
375 void ContrastDialog::OnGetForeground(wxCommandEvent & /*event*/)
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 }
390 
391 void ContrastDialog::OnGetBackground(wxCommandEvent & /*event*/)
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 }
406 
407 namespace {
408  // PRL: I gathered formatting into these functions, and eliminated some
409  // repetitions, and removed the redundant word "Average" as applied to RMS.
410  // Should these variations in formats be collapsed further?
411 
412  // Pass nullptr when value is not yet defined
414  {
415 
416  /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
417  auto format0 = XO("RMS = %s.");
418 
419  /* i18n-hint: dB abbreviates decibels */
420  auto format1 = XO("%s dB");
421 
422  TranslatableString value;
423 
424  if ( pValue ) {
425  if( fabs( *pValue ) != std::numeric_limits<float>::infinity() ) {
426  auto number = wxString::Format( wxT("%.2f"), *pValue );
427  value = format1.Format( number );
428  }
429  else
430  value = XO("zero");
431  }
432  else
433  value = format1.Format( "" );
434 
435  return format0.Format( value );
436  }
437 
439  {
440  if( diffdB != diffdB ) // test for NaN, reliant on IEEE implementation
441  return XO("indeterminate");
442  else {
443  if( diffdB != std::numeric_limits<float>::infinity() )
444  /* i18n-hint: dB abbreviates decibels
445  * RMS abbreviates root mean square, a certain averaging method */
446  return XO("%.2f dB RMS").Format( diffdB );
447  else
448  /* i18n-hint: dB abbreviates decibels */
449  return XO("Infinite dB difference");
450  }
451  }
452 
454  {
455  if( diffdB != diffdB ) //test for NaN, reliant on IEEE implementation
456  return XO("Difference is indeterminate.");
457  else
458  if( fabs(diffdB) != std::numeric_limits<float>::infinity() )
459  /* i18n-hint: dB abbreviates decibels
460  RMS abbreviates root mean square, a certain averaging method */
461  return XO("Difference = %.2f RMS dB.").Format( diffdB );
462  else
463  /* i18n-hint: dB abbreviates decibels
464  RMS abbreviates root mean square, a certain averaging method */
465  return XO("Difference = infinite RMS dB.");
466  }
467 }
468 
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 }
528 
529 void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
530 {
531  // TODO: Handle silence checks better (-infinity dB)
532  auto project = FindProjectFromWindow( this );
533  wxString fName = wxT("contrast.txt");
534 
535  fName = FileNames::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 }
634 
635 void ContrastDialog::OnReset(wxCommandEvent & /*event*/)
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 }
651 
652 // Remaining code hooks this add-on into the application
653 #include "commands/CommandContext.h"
654 #include "commands/CommandManager.h"
655 #include "../commands/ScreenshotCommand.h"
656 
657 namespace {
658 
659 // Contrast window attached to each project is built on demand by:
661  []( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
662  auto &window = ProjectWindow::Get( parent );
663  return safenew ContrastDialog(
664  &window, -1, XO("Contrast Analysis (WCAG 2 compliance)"),
665  wxPoint{ 150, 150 }
666  );
667  }
668 };
669 
670 // Define our extra menu item that invokes that factory
672  void OnContrast(const CommandContext &context)
673  {
674  auto &project = context.project;
675  CommandManager::Get(project).RegisterLastAnalyzer(context); //Register Contrast as Last Analyzer
676  auto contrastDialog =
677  &project.AttachedWindows::Get< ContrastDialog >( sContrastDialogKey );
678 
679  contrastDialog->CentreOnParent();
680  if( ScreenshotCommand::MayCapture( contrastDialog ) )
681  return;
682  contrastDialog->Show();
683  }
684 };
685 
687  // Handler is not stateful. Doesn't need a factory registered with
688  // AudacityProject.
689  static Handler instance;
690  return instance;
691 }
692 
693 // Register that menu item
694 
695 using namespace MenuTable;
696 AttachedItem sAttachment{ wxT("Analyze/Analyzers/Windows"),
698  Command( wxT("ContrastAnalyser"), XXO("Contrast..."),
699  &Handler::OnContrast,
701  wxT("Ctrl+Shift+T") ) )
702 };
703 
704 }
EVT_BUTTON
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
ID_FOREGROUNDSTART_T
@ ID_FOREGROUNDSTART_T
Definition: Contrast.cpp:159
ContrastDialog::mProjectRate
double mProjectRate
Definition: Contrast.h:48
ContrastDialog::OnGetBackground
void OnGetBackground(wxCommandEvent &event)
Definition: Contrast.cpp:391
TranslatableString
Definition: Types.h:290
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:162
ContrastDialog::mBackgroundEndT
NumericTextCtrl * mBackgroundEndT
Definition: Contrast.h:44
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
ContrastDialog::mDiffText
wxTextCtrl * mDiffText
Definition: Contrast.h:68
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
ContrastDialog::m_pButton_UseCurrentF
wxButton * m_pButton_UseCurrentF
Definition: Contrast.h:34
ProjectFileIO::GetFileName
const FilePath & GetFileName() const
Definition: ProjectFileIO.cpp:1444
ContrastDialog::mBackgroundIsDefined
bool mBackgroundIsDefined
Definition: Contrast.h:73
ID_BUTTON_EXPORT
@ ID_BUTTON_EXPORT
Definition: Contrast.cpp:156
NumericTextCtrl::Options::AutoPos
Options & AutoPos(bool enable)
Definition: NumericTextCtrl.h:189
MenuTable::FinderScope
Definition: CommandManager.h:465
ShuttleGuiBase::AddTitle
void AddTitle(const TranslatableString &Prompt, int wrapWidth=0)
Centred text string.
Definition: ShuttleGui.cpp:274
anonymous_namespace{Contrast.cpp}::findCommandHandler
CommandHandlerObject & findCommandHandler(AudacityProject &)
Definition: Contrast.cpp:686
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: AudacityMessageBox.h:20
ContrastDialog::m_pButton_Export
wxButton * m_pButton_Export
Definition: Contrast.h:37
ID_FOREGROUNDEND_T
@ ID_FOREGROUNDEND_T
Definition: Contrast.cpp:160
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:127
ID_RESULTS_TEXT
@ ID_RESULTS_TEXT
Definition: Contrast.cpp:165
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1467
Format
Abstract base class used in importing a file.
NumericConverter::HundredthsFormat
static NumericFormatSymbol HundredthsFormat()
Definition: NumericTextCtrl.cpp:696
ContrastDialog::OnGetURL
void OnGetURL(wxCommandEvent &event)
Definition: Contrast.cpp:360
CommandManager.h
ContrastDialog::mPassFailText
wxTextCtrl * mPassFailText
Definition: Contrast.h:67
XO
#define XO(s)
Definition: Internat.h:32
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:267
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:39
ContrastDialog::backgrounddB
float backgrounddB
Definition: Contrast.h:71
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:531
FindProjectFromWindow
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
Definition: ProjectWindowBase.cpp:39
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:617
MenuTable::AttachedItem
Definition: CommandManager.h:688
ContrastDialog::m_pButton_UseCurrentB
wxButton * m_pButton_UseCurrentB
Definition: Contrast.h:35
FileNames::AllFiles
AUDACITY_DLL_API const FileType AllFiles
Definition: FileNames.h:74
ID_BUTTON_RESET
@ ID_BUTTON_RESET
Definition: Contrast.cpp:157
NumericTextCtrl
Definition: NumericTextCtrl.h:171
WCAG2_PASS
#define WCAG2_PASS
Definition: Contrast.cpp:47
NumericTextCtrl::SetValue
void SetValue(double newValue)
Definition: NumericTextCtrl.cpp:1472
TrackList::SelectedLeaders
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1405
AudacityMessageDialog
Wrap wxMessageDialog so that caption IS translatable.
Definition: wxPanelWrapper.h:215
ClientData::Site::RegisteredFactory
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
WaveTracksSelectedFlag
const ReservedCommandFlag & WaveTracksSelectedFlag()
Definition: CommonCommandFlags.cpp:164
ContrastDialog::mT0
double mT0
Definition: Contrast.h:46
NumericTextCtrl::Options
Definition: NumericTextCtrl.h:177
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
anonymous_namespace{Contrast.cpp}::sContrastDialogKey
AudacityProject::AttachedWindows::RegisteredFactory sContrastDialogKey
Definition: Contrast.cpp:660
ContrastDialog::mForegroundRMSText
wxTextCtrl * mForegroundRMSText
Definition: Contrast.h:65
ContrastDialog::ContrastDialog
ContrastDialog(wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos)
Definition: Contrast.cpp:192
DB_MAX_LIMIT
#define DB_MAX_LIMIT
Definition: Contrast.cpp:46
ContrastDialog::OnClose
void OnClose(wxCommandEvent &event)
Definition: Contrast.cpp:367
ContrastDialog::OnGetForeground
void OnGetForeground(wxCommandEvent &event)
Definition: Contrast.cpp:375
anonymous_namespace{Contrast.cpp}::Handler::OnContrast
void OnContrast(const CommandContext &context)
Definition: Contrast.cpp:672
Contrast.h
CommandContext.h
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:199
XXO
#define XXO(s)
Definition: Internat.h:45
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:22
label
TranslatableString label
Definition: Tags.cpp:755
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
ContrastDialog
Definition: Contrast.h:28
FileNames::TextFiles
AUDACITY_DLL_API const FileType TextFiles
Definition: FileNames.h:77
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ID_BACKGROUNDEND_T
@ ID_BACKGROUNDEND_T
Definition: Contrast.cpp:162
ContrastDialog::GetDB
bool GetDB(float &dB)
Definition: Contrast.cpp:50
ID_BACKGROUNDSTART_T
@ ID_BACKGROUNDSTART_T
Definition: Contrast.cpp:161
anonymous_namespace{Contrast.cpp}::sAttachment
AttachedItem sAttachment
Definition: Contrast.cpp:696
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:611
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:433
ContrastDialog::SetStartAndEndTime
void SetStartAndEndTime()
Definition: Contrast.cpp:135
CommandManager::RegisterLastAnalyzer
void RegisterLastAnalyzer(const CommandContext &context)
Definition: CommandManager.cpp:1222
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:51
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
NumericTextCtrl::Options::MenuEnabled
Options & MenuEnabled(bool enable)
Definition: NumericTextCtrl.h:191
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
ID_BUTTON_USECURRENTF
@ ID_BUTTON_USECURRENTF
Definition: Contrast.cpp:153
ContrastDialog::mBackgroundRMSText
wxTextCtrl * mBackgroundRMSText
Definition: Contrast.h:66
ScreenshotCommand::MayCapture
static bool MayCapture(wxDialog *pDlg)
Definition: ScreenshotCommand.cpp:344
anonymous_namespace{Contrast.cpp}::FormatRMSMessage
TranslatableString FormatRMSMessage(float *pValue)
Definition: Contrast.cpp:413
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:353
ID_BUTTON_USECURRENTB
@ ID_BUTTON_USECURRENTB
Definition: Contrast.cpp:154
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
ContrastDialog::OnExport
void OnExport(wxCommandEvent &event)
Definition: Contrast.cpp:529
id
int id
Definition: WaveTrackControls.cpp:589
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
wxDialogWrapper
Definition: wxPanelWrapper.h:81
ContrastDialog::m_pButton_GetURL
wxButton * m_pButton_GetURL
Definition: Contrast.h:36
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow)
Definition: ShuttleGui.cpp:292
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:238
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
FileNames::SelectFile
AUDACITY_DLL_API FilePath SelectFile(Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
ContrastDialog::m_pButton_Close
wxButton * m_pButton_Close
Definition: Contrast.h:39
_
#define _(s)
Definition: Internat.h:76
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:655
ShuttleGui::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) -> typename std::enable_if< std::is_base_of< Argument, Tag >::value, ShuttleGui & >::type
Definition: ShuttleGui.h:706
ID_RESULTSDB_TEXT
@ ID_RESULTSDB_TEXT
Definition: Contrast.cpp:166
ContrastDialog::OnChar
void OnChar(wxKeyEvent &event)
Definition: Contrast.cpp:178
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
anonymous_namespace{Contrast.cpp}::Handler
Definition: Contrast.cpp:671
TimeSelectedFlag
const ReservedCommandFlag & TimeSelectedFlag()
Definition: CommonCommandFlags.cpp:159
NumericTextCtrl::Options::ReadOnly
Options & ReadOnly(bool enable)
Definition: NumericTextCtrl.h:190
ContrastDialog::mT1
double mT1
Definition: Contrast.h:47
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition: CommandFunctors.h:28
ContrastDialog::foregrounddB
float foregrounddB
Definition: Contrast.h:70
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:721
ID_FOREGROUNDDB_TEXT
@ ID_FOREGROUNDDB_TEXT
Definition: Contrast.cpp:163
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2406
ShuttleGui::GetMode
teShuttleMode GetMode()
Definition: ShuttleGui.h:759
ContrastDialog::mForegroundStartT
NumericTextCtrl * mForegroundStartT
Definition: Contrast.h:41
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
MenuTable
Definition: CommandManager.h:396
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
ContrastDialog::mBackgroundStartT
NumericTextCtrl * mBackgroundStartT
Definition: Contrast.h:43
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Definition: Types.h:363
CommandManager::Get
static CommandManager & Get(AudacityProject &project)
Definition: CommandManager.cpp:202
ID_BACKGROUNDDB_TEXT
@ ID_BACKGROUNDDB_TEXT
Definition: Contrast.cpp:164
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
safenew
#define safenew
Definition: MemoryX.h:8
settings
static Settings & settings()
Definition: TrackInfo.cpp:87
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
NumericConverter::GetValue
double GetValue()
Definition: NumericTextCtrl.cpp:1172
ContrastDialog::mForegroundEndT
NumericTextCtrl * mForegroundEndT
Definition: Contrast.h:42
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:52
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1371
END_EVENT_TABLE
END_EVENT_TABLE()
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
ContrastDialog::m_pButton_Reset
wxButton * m_pButton_Reset
Definition: Contrast.h:38
ContrastDialog::mForegroundIsDefined
bool mForegroundIsDefined
Definition: Contrast.h:72