Audacity 3.2.0
FreqWindow.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FreqWindow.cpp
6
7 Dominic Mazzoni
8
9*******************************************************************//****************************************************************//*******************************************************************/
28
29/*
30 Salvo Ventura - November 2006
31 Extended range check for additional FFT windows
32*/
33
34#include "FreqWindow.h"
35
36#include <algorithm>
37
38#include <wx/setup.h> // for wxUSE_* macros
39
40#include <wx/brush.h>
41#include <wx/button.h>
42#include <wx/checkbox.h>
43#include <wx/choice.h>
44#include <wx/dcclient.h>
45#include <wx/dcmemory.h>
46#include <wx/font.h>
47#include <wx/image.h>
48#include <wx/file.h>
49#include <wx/intl.h>
50#include <wx/scrolbar.h>
51#include <wx/sizer.h>
52#include <wx/slider.h>
53#include <wx/statbmp.h>
54#include <wx/stattext.h>
55#include <wx/statusbr.h>
56
57#include <wx/textctrl.h>
58#include <wx/textfile.h>
59
60#include <wx/wfstream.h>
61#include <wx/txtstrm.h>
62
63#include <math.h>
64
65#include "SelectFile.h"
66#include "ShuttleGui.h"
67#include "AColor.h"
68#include "CommonCommandFlags.h"
69#include "FFT.h"
70#include "PitchName.h"
71#include "Decibels.h"
72#include "Prefs.h"
73#include "Project.h"
74#include "ProjectWindow.h"
75#include "Theme.h"
76#include "ViewInfo.h"
77#include "AllThemeResources.h"
78
79#include "FileNames.h"
80
81#include "WaveTrack.h"
82
85#include "widgets/Ruler.h"
87
88#if wxUSE_ACCESSIBILITY
90#endif
91
92#define FrequencyAnalysisTitle XO("Frequency Analysis")
93
94DEFINE_EVENT_TYPE(EVT_FREQWINDOW_RECALC);
95
96enum {
97 FirstID = 7000,
98
109
110// These specify the minimum plot window width
111
112#define FREQ_WINDOW_WIDTH 480
113#define FREQ_WINDOW_HEIGHT 330
114
115static const char * ZoomIn[] = {
116"16 16 6 1",
117" c None",
118"+ c #1C1C1C",
119"@ c #AEAEAE",
120"# c #F7F7F7",
121"$ c #CFCECC",
122"* c #1C1CA0",
123" ++++ ",
124" @+# @[email protected] ",
125" + @** [email protected] ",
126" +#@ ** #+ ",
128" + ****** [email protected]",
129" +# ** #[email protected]",
130" + ** [email protected]@",
131" +++# #[email protected]@ ",
133" [email protected]@ @@@@ ",
138" @@ "};
139
140static const char * ZoomOut[] = {
141"16 16 6 1",
142" c None",
143"+ c #1C1C1C",
144"@ c #AEAEAE",
145"# c #F7F7F7",
146"$ c #CFCECC",
147"* c #1C1CA0",
148" ++++ ",
149" @+# [email protected] ",
150" + @@ [email protected] ",
151" +# @ #+ ",
153" + ****** [email protected]",
154" +# #[email protected]",
156" +++# #[email protected]@ ",
158" [email protected]@ @@@@ ",
163" @@ "};
164
165// FrequencyPlotDialog
166
167BEGIN_EVENT_TABLE(FrequencyPlotDialog, wxDialogWrapper)
181 EVT_COMMAND(wxID_ANY, EVT_FREQWINDOW_RECALC, FrequencyPlotDialog::OnRecalc)
183
184FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
185 AudacityProject &project,
187 const wxPoint & pos)
188: wxDialogWrapper(parent, id, title, pos, wxDefaultSize,
189 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX),
190 mProject{ &project }
191, mAnalyst(std::make_unique<SpectrumAnalyst>())
192{
193 SetName();
194
195 mMouseX = 0;
196 mMouseY = 0;
197 mRate = 0;
198 mDataLen = 0;
199
200 gPrefs->Read(wxT("/FrequencyPlotDialog/DrawGrid"), &mDrawGrid, true);
201 gPrefs->Read(wxT("/FrequencyPlotDialog/SizeChoice"), &mSize, 3);
202
203 int alg;
204 gPrefs->Read(wxT("/FrequencyPlotDialog/AlgChoice"), &alg, 0);
205 mAlg = static_cast<SpectrumAnalyst::Algorithm>(alg);
206
207 gPrefs->Read(wxT("/FrequencyPlotDialog/FuncChoice"), &mFunc, 3);
208 gPrefs->Read(wxT("/FrequencyPlotDialog/AxisChoice"), &mAxis, 1);
209
210 Populate();
211}
212
214{
215}
216
218{
220
221 TranslatableStrings algChoices{
222 XO("Spectrum") ,
223 XO("Standard Autocorrelation") ,
224 XO("Cuberoot Autocorrelation") ,
225 XO("Enhanced Autocorrelation") ,
226 /* i18n-hint: This is a technical term, derived from the word
227 * "spectrum". Do not translate it unless you are sure you
228 * know the correct technical word in your language. */
229 XO("Cepstrum") ,
230 };
231
232 TranslatableStrings sizeChoices{
233 Verbatim( "128" ) ,
234 Verbatim( "256" ) ,
235 Verbatim( "512" ) ,
236 Verbatim( "1024" ) ,
237 Verbatim( "2048" ) ,
238 Verbatim( "4096" ) ,
239 Verbatim( "8192" ) ,
240 Verbatim( "16384" ) ,
241 Verbatim( "32768" ) ,
242 Verbatim( "65536" ) ,
243 Verbatim( "131072" ) ,
244 };
245
246 TranslatableStrings funcChoices;
247 for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
248 {
249 funcChoices.push_back(
250 /* i18n-hint: This refers to a "window function",
251 * such as Hann or Rectangular, used in the
252 * Frequency analyze dialog box. */
253 XO("%s window").Format( WindowFuncName(i) ) );
254 }
255
256 TranslatableStrings axisChoices{
257 XO("Linear frequency") ,
258 XO("Log frequency") ,
259 };
260
261 mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
262 mArrowCursor = std::make_unique<wxCursor>(wxCURSOR_ARROW);
263 mCrossCursor = std::make_unique<wxCursor>(wxCURSOR_CROSS);
264
265 long size;
266 // reinterpret one of the verbatim strings above as a number
267 sizeChoices[mSize].MSGID().GET().ToLong(&size);
269
271 if(dBRange < 90.)
272 dBRange = 90.;
273
274 ShuttleGui S(this, eIsCreating);
275
276 S.SetBorder(0);
277
278 S.AddSpace(5);
279
280 S.SetSizerProportion(1);
281 S.StartMultiColumn(3, wxEXPAND);
282 {
283 S.SetStretchyCol(1);
284 S.SetStretchyRow(0);
285
286 // -------------------------------------------------------------------
287 // ROW 1: Freq response panel and sliders for vertical scale
288 // -------------------------------------------------------------------
289
290 S.StartVerticalLay(2);
291 {
293 S.GetParent(), wxID_ANY, wxVERTICAL,
294 wxSize{ 100, 100 }, // Ruler can't handle small sizes
295 RulerPanel::Range{ 0.0, -dBRange },
297 XO("dB"),
299 .LabelEdges(true)
300 .TickColour( theTheme.Colour( clrGraphLabels ) )
301 );
302
303 S.AddSpace(wxDefaultCoord, 1);
304 S.Prop(1)
305 .Position(wxALIGN_RIGHT | wxALIGN_TOP)
306 .AddWindow(vRuler);
307 S.AddSpace(wxDefaultCoord, 1);
308 }
309 S.EndVerticalLay();
310
311 mFreqPlot = safenew FreqPlot(S.GetParent(), wxID_ANY);
312 S.Prop(1)
313 .Position(wxEXPAND)
314 .MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } )
315 .AddWindow(mFreqPlot);
316
317 S.StartHorizontalLay(wxEXPAND, 0);
318 {
319 S.StartVerticalLay();
320 {
321 mPanScroller = safenew wxScrollBar(S.GetParent(), FreqPanScrollerID,
322 wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
323#if wxUSE_ACCESSIBILITY
324 // so that name can be set on a standard control
326#endif
327 S.Prop(1);
328 S
329 .Name(XO("Scroll"))
330 .Position( wxALIGN_LEFT | wxTOP)
331 .AddWindow(mPanScroller);
332 }
333 S.EndVerticalLay();
334
335 S.StartVerticalLay();
336 {
337 wxStaticBitmap *zi = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomIn));
338 S.Position(wxALIGN_CENTER)
339 .AddWindow(zi);
340
341 S.AddSpace(5);
342
343 mZoomSlider = safenew wxSliderWrapper(S.GetParent(), FreqZoomSliderID, 100, 1, 100,
344 wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
345 S.Prop(1);
346 S
347 .Name(XO("Zoom"))
348 .Position(wxALIGN_CENTER_HORIZONTAL)
349 .AddWindow(mZoomSlider);
350#if wxUSE_ACCESSIBILITY
351 // so that name can be set on a standard control
353#endif
354
355 S.AddSpace(5);
356
357 wxStaticBitmap *zo = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomOut));
358 S.Position(wxALIGN_CENTER)
359 .AddWindow(zo);
360 }
361 S.EndVerticalLay();
362
363 S.AddSpace(5, wxDefaultCoord);
364 }
365 S.EndHorizontalLay();
366
367 // -------------------------------------------------------------------
368 // ROW 2: Frequency ruler
369 // -------------------------------------------------------------------
370
371 S.AddSpace(1);
372
373 S.StartHorizontalLay(wxEXPAND, 0);
374 {
376 S.GetParent(), wxID_ANY, wxHORIZONTAL,
377 wxSize{ 100, 100 }, // Ruler can't handle small sizes
378 RulerPanel::Range{ 10, 20000 },
380 XO("Hz"),
382 .Log(true)
383 .Flip(true)
384 .LabelEdges(true)
385 .TickColour( theTheme.Colour( clrGraphLabels ) )
386 );
387
388 S.AddSpace(1, wxDefaultCoord);
389 S.Prop(1)
390 .Position(wxALIGN_LEFT | wxALIGN_TOP)
391 .AddWindow(hRuler);
392 S.AddSpace(1, wxDefaultCoord);
393 }
394 S.EndHorizontalLay();
395
396 S.AddSpace(1);
397
398 // -------------------------------------------------------------------
399 // ROW 3: Spacer
400 // -------------------------------------------------------------------
401
402 S.AddSpace(5);
403 S.AddSpace(5);
404 S.AddSpace(5);
405
406 // -------------------------------------------------------------------
407 // ROW 4: Info
408 // -------------------------------------------------------------------
409
410 S.AddSpace(1);
411
412 S.StartHorizontalLay(wxEXPAND);
413 {
414 S.SetSizerProportion(1);
415 S.StartMultiColumn(6);
416 S.SetStretchyCol(1);
417 S.SetStretchyCol(3);
418 {
419 S.AddPrompt(XXO("Cursor:"));
420
421 mCursorText = S.Style(wxTE_READONLY)
422 .AddTextBox( {}, wxT(""), 10);
423
424 S.AddPrompt(XXO("Peak:"));
425
426 mPeakText = S.Style(wxTE_READONLY)
427 .AddTextBox( {}, wxT(""), 10);
428 S.AddSpace(5);
429
430 mGridOnOff = S.Id(GridOnOffID).AddCheckBox(XXO("&Grids"), mDrawGrid);
431 }
432 S.EndMultiColumn();
433 }
434 S.EndHorizontalLay();
435
436 S.AddSpace(1);
437 }
438 S.EndMultiColumn();
439
440 // -------------------------------------------------------------------
441 // ROW 5: Spacer
442 // -------------------------------------------------------------------
443
444 S.AddSpace(5);
445
446 S.SetBorder(2);
447 S.SetSizerProportion(0);
448 S.StartMultiColumn(9, wxALIGN_CENTER);
449 {
450 // ----------------------------------------------------------------
451 // ROW 6: Algorithm, Size, Export, Replot
452 // ----------------------------------------------------------------
453
454 S.AddSpace(5);
455
456 mAlgChoice = S.Id(FreqAlgChoiceID).Focus()
457 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
458 .AddChoice(XXO("&Algorithm:"), algChoices, mAlg);
459
460 S.AddSpace(5);
461
463 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
464 .AddChoice(XXO("&Size:"), sizeChoices, mSize);
465
466 S.AddSpace(5);
467
468 mExportButton = S.Id(FreqExportButtonID).AddButton(XXO("&Export..."));
469
470 S.AddSpace(5);
471
472 // ----------------------------------------------------------------
473 // ROW 7: Function, Axis, Grids, Close
474 // ----------------------------------------------------------------
475
476 S.AddSpace(5);
477
479 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
480 .AddChoice(XXO("&Function:"), funcChoices, mFunc);
481 mFuncChoice->MoveAfterInTabOrder(mSizeChoice);
482
483 S.AddSpace(5);
484
486 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
487 .AddChoice(XXO("&Axis:"), axisChoices, mAxis);
488 mAxisChoice->MoveAfterInTabOrder(mFuncChoice);
489
490 S.AddSpace(5);
491
492 mReplotButton = S.Id(ReplotButtonID).AddButton(XXO("&Replot..."));
493
494 S.AddSpace(5);
495
496 //mCloseButton = S.Id(wxID_CANCEL).AddButton(XO("&Close"));
497
498 //S.AddSpace(5);
499 }
500 S.EndMultiColumn();
501 S.AddStandardButtons( eHelpButton | eCloseButton );
502
503 // -------------------------------------------------------------------
504 // ROW 8: Spacer
505 // -------------------------------------------------------------------
506
507 S.AddSpace(5);
508
509 mProgress = safenew FreqGauge(S.GetParent(), wxID_ANY); //, wxST_SIZEGRIP);
510 S.Position(wxEXPAND)
511 .AddWindow(mProgress);
512
513 // Log-frequency axis works for spectrum plots only.
515 {
516 mAxis = 0;
517 mAxisChoice->Disable();
518 }
519 mLogAxis = mAxis != 0;
520
521 mCloseButton = static_cast<wxButton*>(FindWindowById( wxID_CANCEL ));
522 mCloseButton->SetDefault();
523
524 Layout();
525 Fit();
526 // Bug 1607:
527 Center();
528
529 SetMinSize(GetSize());
530
531#if defined(__WXGTK__)
532 // This should be rechecked with wx3.
533 //
534 // The scrollbar (focus some reason) doesn't allow tabbing past it
535 // because it can't receive focus. So, convince it otherwise.
536 //
537 // Unfortunately, this still doesn't let you adjust the scrollbar
538 // from the keyboard. Near as I can tell, wxWGTK is capturing the
539 // keyboard input, so the GTK widget doesn't see it, preventing
540 // the normal scroll events from being generated.
541 //
542 // I guess the only way round it would be to handle key actions
543 // ourselves, but we'll leave that for a future date.
544// gtk_widget_set_can_focus(mPanScroller->m_widget, true);
545#endif
546}
547
548void FrequencyPlotDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
549{
550 // Original help page is back on-line (March 2016), but the manual should be more reliable.
551 // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
552 HelpSystem::ShowHelp(this, L"Plot_Spectrum");
553}
554
556{
557 if (!show)
558 {
559 mFreqPlot->SetCursor(*mArrowCursor);
560 }
561
562 bool shown = IsShown();
563
564 if (show && !shown)
565 {
567 if(dBRange < 90.)
568 dBRange = 90.;
569 GetAudio();
570 // Don't send an event. We need the recalc right away.
571 // so that mAnalyst is valid when we paint.
572 //SendRecalcEvent();
573 Recalc();
574 }
575
576 bool res = wxDialogWrapper::Show(show);
577
578 return res;
579}
580
582{
583 mData.reset();
584 mDataLen = 0;
585
586 int selcount = 0;
587 bool warning = false;
588 for (auto track : TrackList::Get( *mProject ).Selected< const WaveTrack >()) {
589 auto &selectedRegion = ViewInfo::Get( *mProject ).selectedRegion;
590 if (selcount==0) {
591 mRate = track->GetRate();
592 auto start = track->TimeToLongSamples(selectedRegion.t0());
593 auto end = track->TimeToLongSamples(selectedRegion.t1());
594 auto dataLen = end - start;
595 // Permit approximately 46.60 minutes of selected samples at
596 // a sampling frequency of 48 kHz (11.65 minutes at 192 kHz).
597 auto maxDataLen = size_t(2) << 26;
598 if (dataLen > maxDataLen) {
599 warning = true;
600 mDataLen = maxDataLen;
601 }
602 else {
603 mDataLen = dataLen.as_size_t();
604 }
605 mData = Floats{ mDataLen };
606 // Don't allow throw for bad reads
607 track->GetFloats(mData.get(), start, mDataLen,
608 fillZero, false);
609 }
610 else {
611 if (track->GetRate() != mRate) {
613 XO(
614"To plot the spectrum, all selected tracks must be the same sample rate.") );
615 mData.reset();
616 mDataLen = 0;
617 return;
618 }
619 auto start = track->TimeToLongSamples(selectedRegion.t0());
620 Floats buffer2{ mDataLen };
621 // Again, stop exceptions
622 track->GetFloats(buffer2.get(), start, mDataLen,
623 fillZero, false);
624 for (size_t i = 0; i < mDataLen; i++)
625 mData[i] += buffer2[i];
626 }
627 selcount++;
628 }
629
630 if (selcount == 0)
631 return;
632
633 if (warning) {
634 auto msg = XO(
635"Too much audio was selected. Only the first %.1f seconds of audio will be analyzed.")
636 .Format(mDataLen / mRate);
637 AudacityMessageBox( msg );
638 }
639}
640
641void FrequencyPlotDialog::OnSize(wxSizeEvent & WXUNUSED(event))
642{
643 Layout();
644
645 DrawPlot();
646
647 Refresh(true);
648}
649
651{
652 Layout();
653
654 mBitmap.reset();
655
656 mPlotRect = mFreqPlot->GetClientRect();
657
658 mBitmap = std::make_unique<wxBitmap>(mPlotRect.width, mPlotRect.height,24);
659
660 dc.SelectObject(*mBitmap);
661
662 dc.SetBackground(wxBrush(wxColour(254, 254, 254)));// DONT-THEME Mask colour.
663 dc.Clear();
664
665 dc.SetPen(*wxBLACK_PEN);
666 dc.SetBrush(*wxWHITE_BRUSH);
667 dc.DrawRectangle(mPlotRect);
668
669 dc.SetFont(mFreqFont);
670}
671
673{
674 if (!mData || mDataLen < mWindowSize || mAnalyst->GetProcessedSize() == 0) {
675 wxMemoryDC memDC;
676
677 vRuler->ruler.SetLog(false);
679
680 hRuler->ruler.SetLog(false);
681 hRuler->ruler.SetRange(0, 1);
682
683 DrawBackground(memDC);
684
685 if (mDataLen < mWindowSize) {
686 wxString msg = _("Not enough data selected.");
687 wxSize sz = memDC.GetTextExtent(msg);
688 memDC.DrawText(msg,
689 (mPlotRect.GetWidth() - sz.GetWidth()) / 2,
690 (mPlotRect.GetHeight() - sz.GetHeight()) / 2);
691 }
692
693 memDC.SelectObject(wxNullBitmap);
694
695 mFreqPlot->Refresh();
696
697 Refresh();
698
699 return;
700 }
701
702 float yRange = mYMax - mYMin;
703 float yTotal = yRange * ((float) mZoomSlider->GetValue() / 100.0f);
704
705 int sTotal = yTotal * 100;
706 int sRange = yRange * 100;
707 int sPos = mPanScroller->GetThumbPosition() + ((mPanScroller->GetThumbSize() - sTotal) / 2);
708 mPanScroller->SetScrollbar(sPos, sTotal, sRange, sTotal);
709
710 float yMax = mYMax - ((float)sPos / 100);
711 float yMin = yMax - yTotal;
712
713 // Set up y axis ruler
714
716 vRuler->ruler.SetUnits(XO("dB"));
718 } else {
719 vRuler->ruler.SetUnits({});
721 }
722 int w1, w2, h;
723 vRuler->ruler.GetMaxSize(&w1, &h);
724 vRuler->ruler.SetRange(yMax, yMin); // Note inversion for vertical.
725 vRuler->ruler.GetMaxSize(&w2, &h);
726 if( w1 != w2 ) // Reduces flicker
727 {
728 vRuler->SetMinSize(wxSize(w2,h));
729 Layout();
730 }
731 vRuler->Refresh(false);
732
733 wxMemoryDC memDC;
734 DrawBackground(memDC);
735
736 // Get the plot dimensions
737 //
738 // Must be done after setting the vertical ruler above since the
739 // the width could change.
740 wxRect r = mPlotRect;
741
742 // Set up x axis ruler
743
744 int width = r.width - 2;
745
746 float xMin, xMax, xRatio, xStep;
747
749 xMin = mRate / mWindowSize;
750 xMax = mRate / 2;
751 xRatio = xMax / xMin;
752 if (mLogAxis)
753 {
754 xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
755 hRuler->ruler.SetLog(true);
756 }
757 else
758 {
759 xStep = (xMax - xMin) / width;
760 hRuler->ruler.SetLog(false);
761 }
762 hRuler->ruler.SetUnits(XO("Hz"));
763 } else {
764 xMin = 0;
765 xMax = mAnalyst->GetProcessedSize() / mRate;
766 xStep = (xMax - xMin) / width;
767 hRuler->ruler.SetLog(false);
768 /* i18n-hint: short form of 'seconds'.*/
769 hRuler->ruler.SetUnits(XO("s"));
770 }
771 hRuler->ruler.SetRange(xMin, xMax-xStep);
772 hRuler->Refresh(false);
773
774 // Draw the plot
776 memDC.SetPen(wxPen(theTheme.Colour( clrHzPlot ), 1, wxPENSTYLE_SOLID));
777 else
778 memDC.SetPen(wxPen(theTheme.Colour( clrWavelengthPlot), 1, wxPENSTYLE_SOLID));
779
780 float xPos = xMin;
781
782 for (int i = 0; i < width; i++) {
783 float y;
784
785 if (mLogAxis)
786 y = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
787 else
788 y = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
789
790 float ynorm = (y - yMin) / yTotal;
791
792 int lineheight = (int)(ynorm * (r.height - 1));
793
794 if (lineheight > r.height - 2)
795 lineheight = r.height - 2;
796
797 if (ynorm > 0.0)
798 AColor::Line(memDC, r.x + 1 + i, r.y + r.height - 1 - lineheight,
799 r.x + 1 + i, r.y + r.height - 1);
800
801 if (mLogAxis)
802 xPos *= xStep;
803 else
804 xPos += xStep;
805 }
806
807 // Outline the graph
808 memDC.SetPen(*wxBLACK_PEN);
809 memDC.SetBrush(*wxTRANSPARENT_BRUSH);
810 memDC.DrawRectangle(r);
811
812 if(mDrawGrid)
813 {
814 hRuler->ruler.DrawGrid(memDC, r.height, true, true, 1, 1);
815 vRuler->ruler.DrawGrid(memDC, r.width, true, true, 1, 1);
816 }
817
818 memDC.SelectObject( wxNullBitmap );
819
820 mFreqPlot->Refresh();
821}
822
823
824void FrequencyPlotDialog::PlotMouseEvent(wxMouseEvent & event)
825{
826 if (event.Moving() && (event.m_x != mMouseX || event.m_y != mMouseY)) {
827 mMouseX = event.m_x;
828 mMouseY = event.m_y;
829
830 if (mPlotRect.Contains(mMouseX, mMouseY))
831 mFreqPlot->SetCursor(*mCrossCursor);
832 else
833 mFreqPlot->SetCursor(*mArrowCursor);
834
835 mFreqPlot->Refresh(false);
836 }
837}
838
839void FrequencyPlotDialog::OnPanScroller(wxScrollEvent & WXUNUSED(event))
840{
841 DrawPlot();
842}
843
844void FrequencyPlotDialog::OnZoomSlider(wxCommandEvent & WXUNUSED(event))
845{
846 DrawPlot();
847}
848
849void FrequencyPlotDialog::OnAlgChoice(wxCommandEvent & WXUNUSED(event))
850{
851 mAlg = SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
852
853 // Log-frequency axis works for spectrum plots only.
855 mAxisChoice->Enable(true);
856 mLogAxis = mAxisChoice->GetSelection() ? true : false;
857 }
858 else {
859 mAxisChoice->Disable();
860 mLogAxis = false;
861 }
862
864}
865
866void FrequencyPlotDialog::OnSizeChoice(wxCommandEvent & WXUNUSED(event))
867{
868 long windowSize = 0;
869 mSizeChoice->GetStringSelection().ToLong(&windowSize);
870 mWindowSize = windowSize;
871
873}
874
875void FrequencyPlotDialog::OnFuncChoice(wxCommandEvent & WXUNUSED(event))
876{
878}
879
880void FrequencyPlotDialog::OnAxisChoice(wxCommandEvent & WXUNUSED(event))
881{
882 mLogAxis = mAxisChoice->GetSelection() ? true : false;
883 DrawPlot();
884}
885
886void FrequencyPlotDialog::PlotPaint(wxPaintEvent & event)
887{
888 wxPaintDC dc( (wxWindow *) event.GetEventObject() );
889
890 dc.DrawBitmap( *mBitmap, 0, 0, true );
891 // Fix for Bug 1226 "Plot Spectrum freezes... if insufficient samples selected"
892 if (!mData || mDataLen < mWindowSize)
893 return;
894
895 dc.SetFont(mFreqFont);
896
897 wxRect r = mPlotRect;
898
899 int width = r.width - 2;
900
901 float xMin, xMax, xRatio, xStep;
902
904 xMin = mRate / mWindowSize;
905 xMax = mRate / 2;
906 xRatio = xMax / xMin;
907 if (mLogAxis)
908 xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
909 else
910 xStep = (xMax - xMin) / width;
911 } else {
912 xMin = 0;
913 xMax = mAnalyst->GetProcessedSize() / mRate;
914 xStep = (xMax - xMin) / width;
915 }
916
917 float xPos = xMin;
918
919 // Find the peak nearest the cursor and plot it
920 if ( r.Contains(mMouseX, mMouseY) && (mMouseX!=0) && (mMouseX!=r.width-1) ) {
921 if (mLogAxis)
922 xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
923 else
924 xPos = xMin + xStep * (mMouseX - (r.x + 1));
925
926 float bestValue = 0;
927 float bestpeak = mAnalyst->FindPeak(xPos, &bestValue);
928
929 int px;
930 if (mLogAxis)
931 px = (int)(log(bestpeak / xMin) / log(xStep));
932 else
933 px = (int)((bestpeak - xMin) * width / (xMax - xMin));
934
935 dc.SetPen(wxPen(wxColour(255, 32, 32), 1, wxPENSTYLE_SOLID));
936 AColor::Line(dc, r.x + 1 + px, r.y, r.x + 1 + px, r.y + r.height);
937
938 // print out info about the cursor location
939
940 float value;
941
942 if (mLogAxis) {
943 xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
944 value = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
945 } else {
946 xPos = xMin + xStep * (mMouseX - (r.x + 1));
947 value = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
948 }
949
950 TranslatableString cursor;
952
954 auto xp = PitchName_Absolute(FreqToMIDInote(xPos));
955 auto pp = PitchName_Absolute(FreqToMIDInote(bestpeak));
956 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
957 cursor = XO("%d Hz (%s) = %d dB")
958 .Format( (int)(xPos + 0.5), xp, (int)(value + 0.5));
959 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
960 peak = XO("%d Hz (%s) = %.1f dB")
961 .Format( (int)(bestpeak + 0.5), pp, bestValue );
962 } else if (xPos > 0.0 && bestpeak > 0.0) {
963 auto xp = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
964 auto pp = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
965 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
966 * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
967 cursor = XO("%.4f sec (%d Hz) (%s) = %f")
968 .Format( xPos, (int)(1.0 / xPos + 0.5), xp, value );
969 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
970 * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
971 peak = XO("%.4f sec (%d Hz) (%s) = %.3f")
972 .Format( bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue );
973 }
974 mCursorText->SetValue( cursor.Translation() );
975 mPeakText->SetValue( peak.Translation() );
976 }
977 else {
978 mCursorText->SetValue(wxT(""));
979 mPeakText->SetValue(wxT(""));
980 }
981
982
983 // Outline the graph
984 dc.SetPen(*wxBLACK_PEN);
985 dc.SetBrush(*wxTRANSPARENT_BRUSH);
986 dc.DrawRectangle(r);
987}
988
989void FrequencyPlotDialog::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
990{
991 Show(false);
992}
993
994void FrequencyPlotDialog::OnCloseButton(wxCommandEvent & WXUNUSED(event))
995{
996 gPrefs->Write(wxT("/FrequencyPlotDialog/DrawGrid"), mDrawGrid);
997 gPrefs->Write(wxT("/FrequencyPlotDialog/SizeChoice"), mSizeChoice->GetSelection());
998 gPrefs->Write(wxT("/FrequencyPlotDialog/AlgChoice"), mAlgChoice->GetSelection());
999 gPrefs->Write(wxT("/FrequencyPlotDialog/FuncChoice"), mFuncChoice->GetSelection());
1000 gPrefs->Write(wxT("/FrequencyPlotDialog/AxisChoice"), mAxisChoice->GetSelection());
1001 gPrefs->Flush();
1002 mData.reset();
1003 Show(false);
1004}
1005
1007{
1008 wxCommandEvent e(EVT_FREQWINDOW_RECALC, wxID_ANY);
1009 GetEventHandler()->AddPendingEvent(e);
1010}
1011
1013{
1014 if (!mData || mDataLen < mWindowSize) {
1015 DrawPlot();
1016 return;
1017 }
1018
1020 SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
1021 int windowFunc = mFuncChoice->GetSelection();
1022
1023 wxWindow *hadFocus = FindFocus();
1024 // In wxMac, the skipped window MUST be a top level window. I'd originally made it
1025 // just the mProgress window with the idea of preventing user interaction with the
1026 // controls while the plot was being recalculated. This doesn't appear to be necessary
1027 // so just use the top level window instead.
1028 {
1029 std::optional<wxWindowDisabler> blocker;
1030 if (IsShown())
1031 blocker.emplace(this);
1032 wxYieldIfNeeded();
1033
1034 mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
1035 mData.get(), mDataLen,
1036 &mYMin, &mYMax, mProgress);
1037 }
1038 if (hadFocus) {
1039 hadFocus->SetFocus();
1040 }
1041
1042 if (alg == SpectrumAnalyst::Spectrum) {
1043 if(mYMin < -dBRange)
1044 mYMin = -dBRange;
1045 if(mYMax <= -dBRange)
1046 mYMax = -dBRange + 10.; // it's all out of range, but show a scale.
1047 else
1048 mYMax += .5;
1049 }
1050
1051 // Prime the scrollbar
1052 mPanScroller->SetScrollbar(0, (mYMax - mYMin) * 100, (mYMax - mYMin) * 100, 1);
1053
1054 DrawPlot();
1055}
1056
1057void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event))
1058{
1059 wxString fName = _("spectrum.txt");
1060
1061 fName = SelectFile(FileNames::Operation::Export,
1062 XO("Export Spectral Data As:"),
1063 wxEmptyString,
1064 fName,
1065 wxT("txt"),
1067 wxFD_SAVE | wxRESIZE_BORDER,
1068 this);
1069
1070 if (fName.empty())
1071 return;
1072
1073 wxFFileOutputStream ffStream{ fName };
1074 if (!ffStream.IsOk()) {
1075 AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
1076 return;
1077 }
1078
1079 wxTextOutputStream ss(ffStream);
1080
1081 const int processedSize = mAnalyst->GetProcessedSize();
1082 const float *const processed = mAnalyst->GetProcessed();
1083 if (mAlgChoice->GetSelection() == 0) {
1084 ss
1085 << XO("Frequency (Hz)\tLevel (dB)") << '\n';
1086 for (int i = 1; i < processedSize; i++)
1087 ss
1088 << wxString::Format(wxT("%f\t%f\n"),
1089 i * mRate / mWindowSize, processed[i] );
1090 }
1091 else {
1092 ss
1093 << XO("Lag (seconds)\tFrequency (Hz)\tLevel") << '\n';
1094 for (int i = 1; i < processedSize; i++)
1095 ss
1096 << wxString::Format(wxT("%f\t%f\t%f\n"),
1097 i / mRate, mRate / i, processed[i] );
1098 }
1099}
1100
1101void FrequencyPlotDialog::OnReplot(wxCommandEvent & WXUNUSED(event))
1102{
1104 if(dBRange < 90.)
1105 dBRange = 90.;
1106 GetAudio();
1108}
1109
1110void FrequencyPlotDialog::OnGridOnOff(wxCommandEvent & WXUNUSED(event))
1111{
1112 mDrawGrid = mGridOnOff->IsChecked();
1113
1114 DrawPlot();
1115}
1116
1117void FrequencyPlotDialog::OnRecalc(wxCommandEvent & WXUNUSED(event))
1118{
1119 Recalc();
1120}
1121
1123{
1124 bool shown = IsShown();
1125 if (shown) {
1126 Show(false);
1127 }
1128
1129 auto zoomSlider = mZoomSlider->GetValue();
1130 auto drawGrid = mGridOnOff->GetValue();
1131 auto sizeChoice = mSizeChoice->GetStringSelection();
1132 auto algChoice = mAlgChoice->GetSelection();
1133 auto funcChoice = mFuncChoice->GetSelection();
1134 auto axisChoice = mAxisChoice->GetSelection();
1135
1136 SetSizer(nullptr);
1137 DestroyChildren();
1138
1139 Populate();
1140
1141 mZoomSlider->SetValue(zoomSlider);
1142
1143 mDrawGrid = drawGrid;
1144 mGridOnOff->SetValue(drawGrid);
1145
1146 long windowSize = 0;
1147 sizeChoice.ToLong(&windowSize);
1148 mWindowSize = windowSize;
1149 mSizeChoice->SetStringSelection(sizeChoice);
1150
1151 mAlg = static_cast<SpectrumAnalyst::Algorithm>(algChoice);
1152 mAlgChoice->SetSelection(algChoice);
1153
1154 mFunc = funcChoice;
1155 mFuncChoice->SetSelection(funcChoice);
1156
1157 mAxis = axisChoice;
1158 mAxisChoice->SetSelection(axisChoice);
1159
1160 if (shown) {
1161 Show(true);
1162 }
1163}
1164
1165BEGIN_EVENT_TABLE(FreqPlot, wxWindow)
1166 EVT_ERASE_BACKGROUND(FreqPlot::OnErase)
1167 EVT_PAINT(FreqPlot::OnPaint)
1168 EVT_MOUSE_EVENTS(FreqPlot::OnMouseEvent)
1170
1171FreqPlot::FreqPlot(wxWindow *parent, wxWindowID winid)
1172: wxWindow(parent, winid)
1173{
1174 freqWindow = (FrequencyPlotDialog *) parent;
1175}
1176
1178{
1179 return false;
1180}
1181
1182void FreqPlot::OnErase(wxEraseEvent & WXUNUSED(event))
1183{
1184 // Ignore it to prevent flashing
1185}
1186
1187void FreqPlot::OnPaint(wxPaintEvent & evt)
1188{
1189 freqWindow->PlotPaint(evt);
1190}
1191
1192void FreqPlot::OnMouseEvent(wxMouseEvent & event)
1193{
1194 freqWindow->PlotMouseEvent(event);
1195}
1196
1197// Remaining code hooks this add-on into the application
1200#include "ProjectWindows.h"
1201
1202namespace {
1203
1204AttachedWindows::RegisteredFactory sFrequencyWindowKey{
1205 []( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
1206 auto &window = ProjectWindow::Get( parent );
1208 &window, -1, parent, FrequencyAnalysisTitle,
1209 wxPoint{ 150, 150 }
1210 );
1211 }
1212};
1213
1214// Define our extra menu item that invokes that factory
1216 void OnPlotSpectrum(const CommandContext &context)
1217 {
1218 auto &project = context.project;
1219 CommandManager::Get(project).RegisterLastAnalyzer(context); //Register Plot Spectrum as Last Analyzer
1220 auto freqWindow = &GetAttachedWindows(project)
1222
1223 if( VetoDialogHook::Call( freqWindow ) )
1224 return;
1225 freqWindow->Show(true);
1226 freqWindow->Raise();
1227 freqWindow->SetFocus();
1228 }
1229};
1230
1232 // Handler is not stateful. Doesn't need a factory registered with
1233 // AudacityProject.
1234 static Handler instance;
1235 return instance;
1236}
1237
1238// Register that menu item
1239
1240using namespace MenuTable;
1241AttachedItem sAttachment{ wxT("Analyze/Analyzers/Windows"),
1243 Command( wxT("PlotSpectrum"), XXO("Plot Spectrum..."),
1244 &Handler::OnPlotSpectrum,
1246};
1247
1248}
1249
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
END_EVENT_TABLE()
wxEvtHandler CommandHandlerObject
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
int NumWindowFuncs()
Definition: FFT.cpp:329
const TranslatableString WindowFuncName(int whichFunction)
Definition: FFT.cpp:334
#define FrequencyAnalysisTitle
Definition: FreqWindow.cpp:92
static const char * ZoomOut[]
Definition: FreqWindow.cpp:140
#define FREQ_WINDOW_HEIGHT
Definition: FreqWindow.cpp:113
DEFINE_EVENT_TYPE(EVT_FREQWINDOW_RECALC)
static const char * ZoomIn[]
Definition: FreqWindow.cpp:115
@ FreqAxisChoiceID
Definition: FreqWindow.cpp:105
@ FreqFuncChoiceID
Definition: FreqWindow.cpp:104
@ FreqPanScrollerID
Definition: FreqWindow.cpp:100
@ FreqExportButtonID
Definition: FreqWindow.cpp:101
@ ReplotButtonID
Definition: FreqWindow.cpp:106
@ FreqAlgChoiceID
Definition: FreqWindow.cpp:102
@ FreqSizeChoiceID
Definition: FreqWindow.cpp:103
@ FreqZoomSliderID
Definition: FreqWindow.cpp:99
@ GridOnOffID
Definition: FreqWindow.cpp:107
@ FirstID
Definition: FreqWindow.cpp:97
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
#define _(s)
Definition: Internat.h:75
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
Definition: LabelDialog.cpp:92
#define safenew
Definition: MemoryX.h:10
static const auto title
TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
Definition: PitchName.cpp:154
double FreqToMIDInote(const double freq)
Definition: PitchName.cpp:29
FileConfig * gPrefs
Definition: Prefs.cpp:71
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
accessors for certain important windows associated with each project
@ fillZero
Definition: SampleFormat.h:54
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
@ eIsCreating
Definition: ShuttleGui.h:39
@ eCloseButton
Definition: ShuttleGui.h:607
@ eHelpButton
Definition: ShuttleGui.h:601
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
void RegisterLastAnalyzer(const CommandContext &context)
static CommandManager & Get(AudacityProject &project)
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
FILES_API const FileType AllFiles
Definition: FileNames.h:71
FILES_API const FileType TextFiles
Definition: FileNames.h:74
Abstract base class used in importing a file.
Works with FrequencyPlotDialog to display a spectrum plot of the waveform. This class actually does t...
Definition: FreqWindow.h:38
void OnErase(wxEraseEvent &event)
bool AcceptsFocus() const
void OnMouseEvent(wxMouseEvent &event)
void OnPaint(wxPaintEvent &event)
FrequencyPlotDialog * freqWindow
Definition: FreqWindow.h:51
Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot.
Definition: FreqWindow.h:58
std::unique_ptr< wxCursor > mArrowCursor
Definition: FreqWindow.h:122
std::unique_ptr< wxBitmap > mBitmap
Definition: FreqWindow.h:149
void OnGetURL(wxCommandEvent &event)
Definition: FreqWindow.cpp:548
friend class FreqPlot
Definition: FreqWindow.h:158
void OnAlgChoice(wxCommandEvent &event)
Definition: FreqWindow.cpp:849
void OnPanScroller(wxScrollEvent &event)
Definition: FreqWindow.cpp:839
wxChoice * mAlgChoice
Definition: FreqWindow.h:129
void OnZoomSlider(wxCommandEvent &event)
Definition: FreqWindow.cpp:844
wxChoice * mSizeChoice
Definition: FreqWindow.h:130
wxButton * mExportButton
Definition: FreqWindow.h:126
void OnAxisChoice(wxCommandEvent &event)
Definition: FreqWindow.cpp:880
RulerPanel * hRuler
Definition: FreqWindow.h:114
std::unique_ptr< wxCursor > mCrossCursor
Definition: FreqWindow.h:123
wxButton * mReplotButton
Definition: FreqWindow.h:127
FreqPlot * mFreqPlot
Definition: FreqWindow.h:115
wxSlider * mZoomSlider
Definition: FreqWindow.h:134
void OnRecalc(wxCommandEvent &event)
SpectrumAnalyst::Algorithm mAlg
Definition: FreqWindow.h:101
virtual ~FrequencyPlotDialog()
Definition: FreqWindow.cpp:213
std::unique_ptr< SpectrumAnalyst > mAnalyst
Definition: FreqWindow.h:154
void OnFuncChoice(wxCommandEvent &event)
Definition: FreqWindow.cpp:875
void OnCloseButton(wxCommandEvent &event)
Definition: FreqWindow.cpp:994
void UpdatePrefs() override
wxChoice * mFuncChoice
Definition: FreqWindow.h:131
static const int fontSize
Definition: FreqWindow.h:108
void OnReplot(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &event)
Definition: FreqWindow.cpp:989
void OnExport(wxCommandEvent &event)
wxTextCtrl * mCursorText
Definition: FreqWindow.h:135
RulerPanel * vRuler
Definition: FreqWindow.h:113
void PlotPaint(wxPaintEvent &event)
Definition: FreqWindow.cpp:886
FreqGauge * mProgress
Definition: FreqWindow.h:116
wxTextCtrl * mPeakText
Definition: FreqWindow.h:136
void OnSize(wxSizeEvent &event)
Definition: FreqWindow.cpp:641
wxButton * mCloseButton
Definition: FreqWindow.h:125
void OnGridOnOff(wxCommandEvent &event)
bool Show(bool show=true) override
Definition: FreqWindow.cpp:555
void OnSizeChoice(wxCommandEvent &event)
Definition: FreqWindow.cpp:866
void DrawBackground(wxMemoryDC &dc)
Definition: FreqWindow.cpp:650
wxChoice * mAxisChoice
Definition: FreqWindow.h:132
wxScrollBar * mPanScroller
Definition: FreqWindow.h:133
void PlotMouseEvent(wxMouseEvent &event)
Definition: FreqWindow.cpp:824
wxCheckBox * mGridOnOff
Definition: FreqWindow.h:128
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:239
static ProjectWindow & Get(AudacityProject &project)
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:1521
void SetLog(bool log)
Definition: Ruler.cpp:142
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603
void SetUnits(const TranslatableString &units)
Definition: Ruler.cpp:153
void SetRange(double min, double max)
Definition: Ruler.cpp:188
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:131
@ LinearDBFormat
Definition: Ruler.h:34
@ RealFormat
Definition: Ruler.h:31
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
Ruler ruler
Definition: Ruler.h:288
std::pair< double, double > Range
Definition: Ruler.h:232
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
wxColour & Colour(int iIndex)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1454
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
void SetTitle(const TranslatableString &title)
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())
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
CommandHandlerObject & findCommandHandler(AudacityProject &)
AttachedWindows::RegisteredFactory sFrequencyWindowKey
Options & LabelEdges(bool l)
Definition: Ruler.h:250
Options & Log(bool l)
Definition: Ruler.h:244
void OnPlotSpectrum(const CommandContext &context)