Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
FrequencyPlotDialog Class Referencefinal

Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot. More...

#include <FreqWindow.h>

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

Public Member Functions

 FrequencyPlotDialog (wxWindow *parent, wxWindowID id, AudacityProject &project, const TranslatableString &title, const wxPoint &pos)
 
virtual ~ FrequencyPlotDialog ()
 
bool Show (bool show=true) override
 
- 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 Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 

Private Member Functions

void Populate ()
 
void GetAudio ()
 
void PlotMouseEvent (wxMouseEvent &event)
 
void PlotPaint (wxPaintEvent &event)
 
void OnCloseWindow (wxCloseEvent &event)
 
void OnCloseButton (wxCommandEvent &event)
 
void OnGetURL (wxCommandEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnPanScroller (wxScrollEvent &event)
 
void OnZoomSlider (wxCommandEvent &event)
 
void OnAlgChoice (wxCommandEvent &event)
 
void OnSizeChoice (wxCommandEvent &event)
 
void OnFuncChoice (wxCommandEvent &event)
 
void OnAxisChoice (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnReplot (wxCommandEvent &event)
 
void OnGridOnOff (wxCommandEvent &event)
 
void OnRecalc (wxCommandEvent &event)
 
void SendRecalcEvent ()
 
void Recalc ()
 
void DrawPlot ()
 
void DrawBackground (wxMemoryDC &dc)
 
void UpdatePrefs () override
 

Private Attributes

bool mDrawGrid
 
int mSize
 
SpectrumAnalyst::Algorithm mAlg
 
int mFunc
 
int mAxis
 
int dBRange
 
AudacityProjectmProject
 
RulerPanelvRuler
 
RulerPanelhRuler
 
FreqPlotmFreqPlot
 
FreqGaugemProgress
 
wxRect mPlotRect
 
wxFont mFreqFont
 
std::unique_ptr< wxCursor > mArrowCursor
 
std::unique_ptr< wxCursor > mCrossCursor
 
wxButton * mCloseButton
 
wxButton * mExportButton
 
wxButton * mReplotButton
 
wxCheckBox * mGridOnOff
 
wxChoice * mAlgChoice
 
wxChoice * mSizeChoice
 
wxChoice * mFuncChoice
 
wxChoice * mAxisChoice
 
wxScrollBar * mPanScroller
 
wxSlider * mZoomSlider
 
wxTextCtrl * mCursorText
 
wxTextCtrl * mPeakText
 
double mRate
 
size_t mDataLen
 
Floats mData
 
size_t mWindowSize
 
bool mLogAxis
 
float mYMin
 
float mYMax
 
float mYStep
 
std::unique_ptr< wxBitmap > mBitmap
 
int mMouseX
 
int mMouseY
 
std::unique_ptr< SpectrumAnalystmAnalyst
 

Static Private Attributes

static const int fontSize = 10
 

Friends

class FreqPlot
 

Additional Inherited Members

- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot.

Has a feature that finds peaks and reports their value as you move the mouse around.

Definition at line 56 of file FreqWindow.h.

Constructor & Destructor Documentation

◆ FrequencyPlotDialog()

FrequencyPlotDialog::FrequencyPlotDialog ( wxWindow *  parent,
wxWindowID  id,
AudacityProject project,
const TranslatableString title,
const wxPoint &  pos 
)

Definition at line 187 of file FreqWindow.cpp.

191 : wxDialogWrapper(parent, id, title, pos, wxDefaultSize,
192  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX),
193  mAnalyst(std::make_unique<SpectrumAnalyst>())
194 , mProject{ &project }
195 {
196  SetName();
197 
198  mMouseX = 0;
199  mMouseY = 0;
200  mRate = 0;
201  mDataLen = 0;
202 
203  gPrefs->Read(wxT("/FrequencyPlotDialog/DrawGrid"), &mDrawGrid, true);
204  gPrefs->Read(wxT("/FrequencyPlotDialog/SizeChoice"), &mSize, 3);
205 
206  int alg;
207  gPrefs->Read(wxT("/FrequencyPlotDialog/AlgChoice"), &alg, 0);
208  mAlg = static_cast<SpectrumAnalyst::Algorithm>(alg);
209 
210  gPrefs->Read(wxT("/FrequencyPlotDialog/FuncChoice"), &mFunc, 3);
211  gPrefs->Read(wxT("/FrequencyPlotDialog/AxisChoice"), &mAxis, 1);
212 
213  Populate();
214 }

◆ ~ FrequencyPlotDialog()

virtual FrequencyPlotDialog::~ FrequencyPlotDialog ( )
virtual

Member Function Documentation

◆ DrawBackground()

void FrequencyPlotDialog::DrawBackground ( wxMemoryDC &  dc)
private

Definition at line 649 of file FreqWindow.cpp.

650 {
651  Layout();
652 
653  mBitmap.reset();
654 
655  mPlotRect = mFreqPlot->GetClientRect();
656 
657  mBitmap = std::make_unique<wxBitmap>(mPlotRect.width, mPlotRect.height,24);
658 
659  dc.SelectObject(*mBitmap);
660 
661  dc.SetBackground(wxBrush(wxColour(254, 254, 254)));// DONT-THEME Mask colour.
662  dc.Clear();
663 
664  dc.SetPen(*wxBLACK_PEN);
665  dc.SetBrush(*wxWHITE_BRUSH);
666  dc.DrawRectangle(mPlotRect);
667 
668  dc.SetFont(mFreqFont);
669 }

References mBitmap, mFreqFont, mFreqPlot, and mPlotRect.

Referenced by DrawPlot().

Here is the caller graph for this function:

◆ DrawPlot()

void FrequencyPlotDialog::DrawPlot ( )
private

Definition at line 671 of file FreqWindow.cpp.

672 {
673  if (!mData || mDataLen < mWindowSize || mAnalyst->GetProcessedSize() == 0) {
674  wxMemoryDC memDC;
675 
676  vRuler->ruler.SetLog(false);
677  vRuler->ruler.SetRange(0.0, -dBRange);
678 
679  hRuler->ruler.SetLog(false);
680  hRuler->ruler.SetRange(0, 1);
681 
682  DrawBackground(memDC);
683 
684  if (mDataLen < mWindowSize) {
685  wxString msg = _("Not enough data selected.");
686  wxSize sz = memDC.GetTextExtent(msg);
687  memDC.DrawText(msg,
688  (mPlotRect.GetWidth() - sz.GetWidth()) / 2,
689  (mPlotRect.GetHeight() - sz.GetHeight()) / 2);
690  }
691 
692  memDC.SelectObject(wxNullBitmap);
693 
694  mFreqPlot->Refresh();
695 
696  Refresh();
697 
698  return;
699  }
700 
701  float yRange = mYMax - mYMin;
702  float yTotal = yRange * ((float) mZoomSlider->GetValue() / 100.0f);
703 
704  int sTotal = yTotal * 100;
705  int sRange = yRange * 100;
706  int sPos = mPanScroller->GetThumbPosition() + ((mPanScroller->GetThumbSize() - sTotal) / 2);
707  mPanScroller->SetScrollbar(sPos, sTotal, sRange, sTotal);
708 
709  float yMax = mYMax - ((float)sPos / 100);
710  float yMin = yMax - yTotal;
711 
712  // Set up y axis ruler
713 
715  vRuler->ruler.SetUnits(XO("dB"));
717  } else {
718  vRuler->ruler.SetUnits({});
720  }
721  int w1, w2, h;
722  vRuler->ruler.GetMaxSize(&w1, &h);
723  vRuler->ruler.SetRange(yMax, yMin); // Note inversion for vertical.
724  vRuler->ruler.GetMaxSize(&w2, &h);
725  if( w1 != w2 ) // Reduces flicker
726  {
727  vRuler->SetMinSize(wxSize(w2,h));
728  Layout();
729  }
730  vRuler->Refresh(false);
731 
732  wxMemoryDC memDC;
733  DrawBackground(memDC);
734 
735  // Get the plot dimensions
736  //
737  // Must be done after setting the vertical ruler above since the
738  // the width could change.
739  wxRect r = mPlotRect;
740 
741  // Set up x axis ruler
742 
743  int width = r.width - 2;
744 
745  float xMin, xMax, xRatio, xStep;
746 
748  xMin = mRate / mWindowSize;
749  xMax = mRate / 2;
750  xRatio = xMax / xMin;
751  if (mLogAxis)
752  {
753  xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
754  hRuler->ruler.SetLog(true);
755  }
756  else
757  {
758  xStep = (xMax - xMin) / width;
759  hRuler->ruler.SetLog(false);
760  }
761  hRuler->ruler.SetUnits(XO("Hz"));
762  } else {
763  xMin = 0;
764  xMax = mAnalyst->GetProcessedSize() / mRate;
765  xStep = (xMax - xMin) / width;
766  hRuler->ruler.SetLog(false);
767  /* i18n-hint: short form of 'seconds'.*/
768  hRuler->ruler.SetUnits(XO("s"));
769  }
770  hRuler->ruler.SetRange(xMin, xMax-xStep);
771  hRuler->Refresh(false);
772 
773  // Draw the plot
775  memDC.SetPen(wxPen(theTheme.Colour( clrHzPlot ), 1, wxPENSTYLE_SOLID));
776  else
777  memDC.SetPen(wxPen(theTheme.Colour( clrWavelengthPlot), 1, wxPENSTYLE_SOLID));
778 
779  float xPos = xMin;
780 
781  for (int i = 0; i < width; i++) {
782  float y;
783 
784  if (mLogAxis)
785  y = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
786  else
787  y = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
788 
789  float ynorm = (y - yMin) / yTotal;
790 
791  int lineheight = (int)(ynorm * (r.height - 1));
792 
793  if (lineheight > r.height - 2)
794  lineheight = r.height - 2;
795 
796  if (ynorm > 0.0)
797  AColor::Line(memDC, r.x + 1 + i, r.y + r.height - 1 - lineheight,
798  r.x + 1 + i, r.y + r.height - 1);
799 
800  if (mLogAxis)
801  xPos *= xStep;
802  else
803  xPos += xStep;
804  }
805 
806  // Outline the graph
807  memDC.SetPen(*wxBLACK_PEN);
808  memDC.SetBrush(*wxTRANSPARENT_BRUSH);
809  memDC.DrawRectangle(r);
810 
811  if(mDrawGrid)
812  {
813  hRuler->ruler.DrawGrid(memDC, r.height, true, true, 1, 1);
814  vRuler->ruler.DrawGrid(memDC, r.width, true, true, 1, 1);
815  }
816 
817  memDC.SelectObject( wxNullBitmap );
818 
819  mFreqPlot->Refresh();
820 }

References _, ThemeBase::Colour(), dBRange, DrawBackground(), Ruler::DrawGrid(), Ruler::GetMaxSize(), hRuler, AColor::Line(), Ruler::LinearDBFormat, mAlg, mAnalyst, mData, mDataLen, mDrawGrid, mFreqPlot, mLogAxis, mPanScroller, mPlotRect, mRate, mWindowSize, mYMax, mYMin, mZoomSlider, Ruler::RealFormat, RulerPanel::ruler, Ruler::SetFormat(), Ruler::SetLog(), Ruler::SetRange(), Ruler::SetUnits(), SpectrumAnalyst::Spectrum, theTheme, vRuler, and XO.

Referenced by OnAxisChoice(), OnGridOnOff(), OnPanScroller(), OnSize(), OnZoomSlider(), and Recalc().

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

◆ GetAudio()

void FrequencyPlotDialog::GetAudio ( )
private

Definition at line 583 of file FreqWindow.cpp.

584 {
585  mData.reset();
586  mDataLen = 0;
587 
588  int selcount = 0;
589  bool warning = false;
590  for (auto track : TrackList::Get( *mProject ).Selected< const WaveTrack >()) {
591  auto &selectedRegion = ViewInfo::Get( *mProject ).selectedRegion;
592  if (selcount==0) {
593  mRate = track->GetRate();
594  auto start = track->TimeToLongSamples(selectedRegion.t0());
595  auto end = track->TimeToLongSamples(selectedRegion.t1());
596  auto dataLen = end - start;
597  if (dataLen > 10485760) {
598  warning = true;
599  mDataLen = 10485760;
600  }
601  else
602  // dataLen is not more than 10 * 2 ^ 20
603  mDataLen = dataLen.as_size_t();
604  mData = Floats{ mDataLen };
605  // Don't allow throw for bad reads
606  track->GetFloats(mData.get(), start, mDataLen,
607  fillZero, false);
608  }
609  else {
610  if (track->GetRate() != mRate) {
612  XO(
613 "To plot the spectrum, all selected tracks must be the same sample rate.") );
614  mData.reset();
615  mDataLen = 0;
616  return;
617  }
618  auto start = track->TimeToLongSamples(selectedRegion.t0());
619  Floats buffer2{ mDataLen };
620  // Again, stop exceptions
621  track->GetFloats(buffer2.get(), start, mDataLen,
622  fillZero, false);
623  for (size_t i = 0; i < mDataLen; i++)
624  mData[i] += buffer2[i];
625  }
626  selcount++;
627  }
628 
629  if (selcount == 0)
630  return;
631 
632  if (warning) {
633  auto msg = XO(
634 "Too much audio was selected. Only the first %.1f seconds of audio will be analyzed.")
635  .Format(mDataLen / mRate);
636  AudacityMessageBox( msg );
637  }
638 }

References AudacityMessageBox(), fillZero, ViewInfo::Get(), TrackList::Get(), mData, mDataLen, mRate, TrackList::Selected(), ViewInfo::selectedRegion, and XO.

Referenced by OnReplot(), and Show().

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

◆ OnAlgChoice()

void FrequencyPlotDialog::OnAlgChoice ( wxCommandEvent &  event)
private

Definition at line 848 of file FreqWindow.cpp.

849 {
850  mAlg = SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
851 
852  // Log-frequency axis works for spectrum plots only.
854  mAxisChoice->Enable(true);
855  mLogAxis = mAxisChoice->GetSelection() ? true : false;
856  }
857  else {
858  mAxisChoice->Disable();
859  mLogAxis = false;
860  }
861 
862  SendRecalcEvent();
863 }

References mAlg, mAlgChoice, mAxisChoice, mLogAxis, SendRecalcEvent(), and SpectrumAnalyst::Spectrum.

Here is the call graph for this function:

◆ OnAxisChoice()

void FrequencyPlotDialog::OnAxisChoice ( wxCommandEvent &  event)
private

Definition at line 879 of file FreqWindow.cpp.

880 {
881  mLogAxis = mAxisChoice->GetSelection() ? true : false;
882  DrawPlot();
883 }

References DrawPlot(), mAxisChoice, and mLogAxis.

Here is the call graph for this function:

◆ OnCloseButton()

void FrequencyPlotDialog::OnCloseButton ( wxCommandEvent &  event)
private

Definition at line 993 of file FreqWindow.cpp.

994 {
995  gPrefs->Write(wxT("/FrequencyPlotDialog/DrawGrid"), mDrawGrid);
996  gPrefs->Write(wxT("/FrequencyPlotDialog/SizeChoice"), mSizeChoice->GetSelection());
997  gPrefs->Write(wxT("/FrequencyPlotDialog/AlgChoice"), mAlgChoice->GetSelection());
998  gPrefs->Write(wxT("/FrequencyPlotDialog/FuncChoice"), mFuncChoice->GetSelection());
999  gPrefs->Write(wxT("/FrequencyPlotDialog/AxisChoice"), mAxisChoice->GetSelection());
1000  gPrefs->Flush();
1001  Show(false);
1002 }

References FileConfig::Flush(), gPrefs, mAlgChoice, mAxisChoice, mDrawGrid, mFuncChoice, mSizeChoice, and Show().

Here is the call graph for this function:

◆ OnCloseWindow()

void FrequencyPlotDialog::OnCloseWindow ( wxCloseEvent &  event)
private

Definition at line 988 of file FreqWindow.cpp.

989 {
990  Show(false);
991 }

References Show().

Here is the call graph for this function:

◆ OnExport()

void FrequencyPlotDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 1055 of file FreqWindow.cpp.

1056 {
1057  wxString fName = _("spectrum.txt");
1058 
1059  fName = SelectFile(FileNames::Operation::Export,
1060  XO("Export Spectral Data As:"),
1061  wxEmptyString,
1062  fName,
1063  wxT("txt"),
1065  wxFD_SAVE | wxRESIZE_BORDER,
1066  this);
1067 
1068  if (fName.empty())
1069  return;
1070 
1071  wxFFileOutputStream ffStream{ fName };
1072  if (!ffStream.IsOk()) {
1073  AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
1074  return;
1075  }
1076 
1077  wxTextOutputStream ss(ffStream);
1078 
1079  const int processedSize = mAnalyst->GetProcessedSize();
1080  const float *const processed = mAnalyst->GetProcessed();
1081  if (mAlgChoice->GetSelection() == 0) {
1082  ss
1083  << XO("Frequency (Hz)\tLevel (dB)") << '\n';
1084  for (int i = 1; i < processedSize; i++)
1085  ss
1086  << wxString::Format(wxT("%f\t%f\n"),
1087  i * mRate / mWindowSize, processed[i] );
1088  }
1089  else {
1090  ss
1091  << XO("Lag (seconds)\tFrequency (Hz)\tLevel") << '\n';
1092  for (int i = 1; i < processedSize; i++)
1093  ss
1094  << wxString::Format(wxT("%f\t%f\t%f\n"),
1095  i / mRate, mRate / i, processed[i] );
1096  }
1097 }

References _, FileNames::AllFiles, AudacityMessageBox(), mAlgChoice, mAnalyst, mRate, mWindowSize, SelectFile(), FileNames::TextFiles, and XO.

Here is the call graph for this function:

◆ OnFuncChoice()

void FrequencyPlotDialog::OnFuncChoice ( wxCommandEvent &  event)
private

Definition at line 874 of file FreqWindow.cpp.

875 {
876  SendRecalcEvent();
877 }

References SendRecalcEvent().

Here is the call graph for this function:

◆ OnGetURL()

void FrequencyPlotDialog::OnGetURL ( wxCommandEvent &  event)
private

Definition at line 550 of file FreqWindow.cpp.

551 {
552  // Original help page is back on-line (March 2016), but the manual should be more reliable.
553  // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
554  HelpSystem::ShowHelp(this, L"Plot Spectrum");
555 }

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnGridOnOff()

void FrequencyPlotDialog::OnGridOnOff ( wxCommandEvent &  event)
private

Definition at line 1108 of file FreqWindow.cpp.

1109 {
1110  mDrawGrid = mGridOnOff->IsChecked();
1111 
1112  DrawPlot();
1113 }

References DrawPlot(), mDrawGrid, and mGridOnOff.

Here is the call graph for this function:

◆ OnPanScroller()

void FrequencyPlotDialog::OnPanScroller ( wxScrollEvent &  event)
private

Definition at line 838 of file FreqWindow.cpp.

839 {
840  DrawPlot();
841 }

References DrawPlot().

Here is the call graph for this function:

◆ OnRecalc()

void FrequencyPlotDialog::OnRecalc ( wxCommandEvent &  event)
private

Definition at line 1115 of file FreqWindow.cpp.

1116 {
1117  Recalc();
1118 }

References Recalc().

Here is the call graph for this function:

◆ OnReplot()

void FrequencyPlotDialog::OnReplot ( wxCommandEvent &  event)
private

Definition at line 1099 of file FreqWindow.cpp.

1100 {
1102  if(dBRange < 90.)
1103  dBRange = 90.;
1104  GetAudio();
1105  SendRecalcEvent();
1106 }

References dBRange, DecibelScaleCutoff, GetAudio(), Setting< T >::Read(), and SendRecalcEvent().

Here is the call graph for this function:

◆ OnSize()

void FrequencyPlotDialog::OnSize ( wxSizeEvent &  event)
private

Definition at line 640 of file FreqWindow.cpp.

641 {
642  Layout();
643 
644  DrawPlot();
645 
646  Refresh(true);
647 }

References DrawPlot().

Here is the call graph for this function:

◆ OnSizeChoice()

void FrequencyPlotDialog::OnSizeChoice ( wxCommandEvent &  event)
private

Definition at line 865 of file FreqWindow.cpp.

866 {
867  long windowSize = 0;
868  mSizeChoice->GetStringSelection().ToLong(&windowSize);
869  mWindowSize = windowSize;
870 
871  SendRecalcEvent();
872 }

References mSizeChoice, mWindowSize, and SendRecalcEvent().

Here is the call graph for this function:

◆ OnZoomSlider()

void FrequencyPlotDialog::OnZoomSlider ( wxCommandEvent &  event)
private

Definition at line 843 of file FreqWindow.cpp.

844 {
845  DrawPlot();
846 }

References DrawPlot().

Here is the call graph for this function:

◆ PlotMouseEvent()

void FrequencyPlotDialog::PlotMouseEvent ( wxMouseEvent &  event)
private

Definition at line 823 of file FreqWindow.cpp.

824 {
825  if (event.Moving() && (event.m_x != mMouseX || event.m_y != mMouseY)) {
826  mMouseX = event.m_x;
827  mMouseY = event.m_y;
828 
829  if (mPlotRect.Contains(mMouseX, mMouseY))
830  mFreqPlot->SetCursor(*mCrossCursor);
831  else
832  mFreqPlot->SetCursor(*mArrowCursor);
833 
834  mFreqPlot->Refresh(false);
835  }
836 }

References mArrowCursor, mCrossCursor, mFreqPlot, mMouseX, mMouseY, and mPlotRect.

Referenced by FreqPlot::OnMouseEvent().

Here is the caller graph for this function:

◆ PlotPaint()

void FrequencyPlotDialog::PlotPaint ( wxPaintEvent &  event)
private

Definition at line 885 of file FreqWindow.cpp.

886 {
887  wxPaintDC dc( (wxWindow *) event.GetEventObject() );
888 
889  dc.DrawBitmap( *mBitmap, 0, 0, true );
890  // Fix for Bug 1226 "Plot Spectrum freezes... if insufficient samples selected"
891  if (!mData || mDataLen < mWindowSize)
892  return;
893 
894  dc.SetFont(mFreqFont);
895 
896  wxRect r = mPlotRect;
897 
898  int width = r.width - 2;
899 
900  float xMin, xMax, xRatio, xStep;
901 
903  xMin = mRate / mWindowSize;
904  xMax = mRate / 2;
905  xRatio = xMax / xMin;
906  if (mLogAxis)
907  xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
908  else
909  xStep = (xMax - xMin) / width;
910  } else {
911  xMin = 0;
912  xMax = mAnalyst->GetProcessedSize() / mRate;
913  xStep = (xMax - xMin) / width;
914  }
915 
916  float xPos = xMin;
917 
918  // Find the peak nearest the cursor and plot it
919  if ( r.Contains(mMouseX, mMouseY) & (mMouseX!=0) & (mMouseX!=r.width-1) ) {
920  if (mLogAxis)
921  xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
922  else
923  xPos = xMin + xStep * (mMouseX - (r.x + 1));
924 
925  float bestValue = 0;
926  float bestpeak = mAnalyst->FindPeak(xPos, &bestValue);
927 
928  int px;
929  if (mLogAxis)
930  px = (int)(log(bestpeak / xMin) / log(xStep));
931  else
932  px = (int)((bestpeak - xMin) * width / (xMax - xMin));
933 
934  dc.SetPen(wxPen(wxColour(255, 32, 32), 1, wxPENSTYLE_SOLID));
935  AColor::Line(dc, r.x + 1 + px, r.y, r.x + 1 + px, r.y + r.height);
936 
937  // print out info about the cursor location
938 
939  float value;
940 
941  if (mLogAxis) {
942  xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
943  value = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
944  } else {
945  xPos = xMin + xStep * (mMouseX - (r.x + 1));
946  value = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
947  }
948 
949  TranslatableString cursor;
950  TranslatableString peak;
951 
953  auto xp = PitchName_Absolute(FreqToMIDInote(xPos));
954  auto pp = PitchName_Absolute(FreqToMIDInote(bestpeak));
955  /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
956  cursor = XO("%d Hz (%s) = %d dB")
957  .Format( (int)(xPos + 0.5), xp, (int)(value + 0.5));
958  /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
959  peak = XO("%d Hz (%s) = %.1f dB")
960  .Format( (int)(bestpeak + 0.5), pp, bestValue );
961  } else if (xPos > 0.0 && bestpeak > 0.0) {
962  auto xp = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
963  auto pp = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
964  /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
965  * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
966  cursor = XO("%.4f sec (%d Hz) (%s) = %f")
967  .Format( xPos, (int)(1.0 / xPos + 0.5), xp, value );
968  /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
969  * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
970  peak = XO("%.4f sec (%d Hz) (%s) = %.3f")
971  .Format( bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue );
972  }
973  mCursorText->SetValue( cursor.Translation() );
974  mPeakText->SetValue( peak.Translation() );
975  }
976  else {
977  mCursorText->SetValue(wxT(""));
978  mPeakText->SetValue(wxT(""));
979  }
980 
981 
982  // Outline the graph
983  dc.SetPen(*wxBLACK_PEN);
984  dc.SetBrush(*wxTRANSPARENT_BRUSH);
985  dc.DrawRectangle(r);
986 }

References FreqToMIDInote(), AColor::Line(), mAlg, mAnalyst, mBitmap, mCursorText, mData, mDataLen, mFreqFont, mLogAxis, mMouseX, mMouseY, mPeakText, mPlotRect, mRate, mWindowSize, PitchName_Absolute(), SpectrumAnalyst::Spectrum, TranslatableString::Translation(), and XO.

Referenced by FreqPlot::OnPaint().

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

◆ Populate()

void FrequencyPlotDialog::Populate ( )
private

Definition at line 220 of file FreqWindow.cpp.

221 {
223 
224  TranslatableStrings algChoices{
225  XO("Spectrum") ,
226  XO("Standard Autocorrelation") ,
227  XO("Cuberoot Autocorrelation") ,
228  XO("Enhanced Autocorrelation") ,
229  /* i18n-hint: This is a technical term, derived from the word
230  * "spectrum". Do not translate it unless you are sure you
231  * know the correct technical word in your language. */
232  XO("Cepstrum") ,
233  };
234 
235  TranslatableStrings sizeChoices{
236  Verbatim( "128" ) ,
237  Verbatim( "256" ) ,
238  Verbatim( "512" ) ,
239  Verbatim( "1024" ) ,
240  Verbatim( "2048" ) ,
241  Verbatim( "4096" ) ,
242  Verbatim( "8192" ) ,
243  Verbatim( "16384" ) ,
244  Verbatim( "32768" ) ,
245  Verbatim( "65536" ) ,
246  };
247 
248  TranslatableStrings funcChoices;
249  for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
250  {
251  funcChoices.push_back(
252  /* i18n-hint: This refers to a "window function",
253  * such as Hann or Rectangular, used in the
254  * Frequency analyze dialog box. */
255  XO("%s window").Format( WindowFuncName(i) ) );
256  }
257 
258  TranslatableStrings axisChoices{
259  XO("Linear frequency") ,
260  XO("Log frequency") ,
261  };
262 
263  mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
264  mArrowCursor = std::make_unique<wxCursor>(wxCURSOR_ARROW);
265  mCrossCursor = std::make_unique<wxCursor>(wxCURSOR_CROSS);
266 
267  long size;
268  // reinterpret one of the verbatim strings above as a number
269  sizeChoices[mSize].MSGID().GET().ToLong(&size);
270  mWindowSize = size;
271 
273  if(dBRange < 90.)
274  dBRange = 90.;
275 
276  ShuttleGui S(this, eIsCreating);
277 
278  S.SetBorder(0);
279 
280  S.AddSpace(5);
281 
282  S.SetSizerProportion(1);
283  S.StartMultiColumn(3, wxEXPAND);
284  {
285  S.SetStretchyCol(1);
286  S.SetStretchyRow(0);
287 
288  // -------------------------------------------------------------------
289  // ROW 1: Freq response panel and sliders for vertical scale
290  // -------------------------------------------------------------------
291 
292  S.StartVerticalLay(2);
293  {
295  S.GetParent(), wxID_ANY, wxVERTICAL,
296  wxSize{ 100, 100 }, // Ruler can't handle small sizes
297  RulerPanel::Range{ 0.0, -dBRange },
299  XO("dB"),
301  .LabelEdges(true)
302  .TickColour( theTheme.Colour( clrGraphLabels ) )
303  );
304 
305  S.AddSpace(wxDefaultCoord, 1);
306  S.Prop(1)
307  .Position(wxALIGN_RIGHT | wxALIGN_TOP)
308  .AddWindow(vRuler);
309  S.AddSpace(wxDefaultCoord, 1);
310  }
311  S.EndVerticalLay();
312 
313  mFreqPlot = safenew FreqPlot(S.GetParent(), wxID_ANY);
314  S.Prop(1)
315  .Position(wxEXPAND)
316  .MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } )
317  .AddWindow(mFreqPlot);
318 
319  S.StartHorizontalLay(wxEXPAND, 0);
320  {
321  S.StartVerticalLay();
322  {
323  mPanScroller = safenew wxScrollBar(S.GetParent(), FreqPanScrollerID,
324  wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
325 #if wxUSE_ACCESSIBILITY
326  // so that name can be set on a standard control
328 #endif
329  S.Prop(1);
330  S
331  .Name(XO("Scroll"))
332  .Position( wxALIGN_LEFT | wxTOP)
333  .AddWindow(mPanScroller);
334  }
335  S.EndVerticalLay();
336 
337  S.StartVerticalLay();
338  {
339  wxStaticBitmap *zi = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomIn));
340  S.Position(wxALIGN_CENTER)
341  .AddWindow(zi);
342 
343  S.AddSpace(5);
344 
345  mZoomSlider = safenew wxSliderWrapper(S.GetParent(), FreqZoomSliderID, 100, 1, 100,
346  wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
347  S.Prop(1);
348  S
349  .Name(XO("Zoom"))
350  .Position(wxALIGN_CENTER_HORIZONTAL)
351  .AddWindow(mZoomSlider);
352 #if wxUSE_ACCESSIBILITY
353  // so that name can be set on a standard control
355 #endif
356 
357  S.AddSpace(5);
358 
359  wxStaticBitmap *zo = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomOut));
360  S.Position(wxALIGN_CENTER)
361  .AddWindow(zo);
362  }
363  S.EndVerticalLay();
364 
365  S.AddSpace(5, wxDefaultCoord);
366  }
367  S.EndHorizontalLay();
368 
369  // -------------------------------------------------------------------
370  // ROW 2: Frequency ruler
371  // -------------------------------------------------------------------
372 
373  S.AddSpace(1);
374 
375  S.StartHorizontalLay(wxEXPAND, 0);
376  {
378  S.GetParent(), wxID_ANY, wxHORIZONTAL,
379  wxSize{ 100, 100 }, // Ruler can't handle small sizes
380  RulerPanel::Range{ 10, 20000 },
382  XO("Hz"),
384  .Log(true)
385  .Flip(true)
386  .LabelEdges(true)
387  .TickColour( theTheme.Colour( clrGraphLabels ) )
388  );
389 
390  S.AddSpace(1, wxDefaultCoord);
391  S.Prop(1)
392  .Position(wxALIGN_LEFT | wxALIGN_TOP)
393  .AddWindow(hRuler);
394  S.AddSpace(1, wxDefaultCoord);
395  }
396  S.EndHorizontalLay();
397 
398  S.AddSpace(1);
399 
400  // -------------------------------------------------------------------
401  // ROW 3: Spacer
402  // -------------------------------------------------------------------
403  S.AddSpace(5);
404  S.AddSpace(5);
405  S.AddSpace(5);
406 
407  // -------------------------------------------------------------------
408  // ROW 4: Info
409  // -------------------------------------------------------------------
410 
411  S.AddSpace(1);
412 
413  S.StartHorizontalLay(wxEXPAND);
414  {
415  S.SetSizerProportion(1);
416  S.StartMultiColumn(6);
417  S.SetStretchyCol(1);
418  S.SetStretchyCol(3);
419  {
420  S.AddPrompt(XXO("Cursor:"));
421 
422  mCursorText = S.Style(wxTE_READONLY)
423  .AddTextBox( {}, wxT(""), 10);
424 
425  S.AddPrompt(XXO("Peak:"));
426 
427  mPeakText = S.Style(wxTE_READONLY)
428  .AddTextBox( {}, wxT(""), 10);
429  S.AddSpace(5);
430 
431  mGridOnOff = S.Id(GridOnOffID).AddCheckBox(XXO("&Grids"), mDrawGrid);
432  }
433  S.EndMultiColumn();
434  }
435  S.EndHorizontalLay();
436 
437  S.AddSpace(1);
438  }
439  S.EndMultiColumn();
440 
441  // -------------------------------------------------------------------
442  // ROW 5: Spacer
443  // -------------------------------------------------------------------
444 
445  S.AddSpace(5);
446 
447  S.SetBorder(2);
448  S.SetSizerProportion(0);
449  S.StartMultiColumn(9, wxALIGN_CENTER);
450  {
451  // ----------------------------------------------------------------
452  // ROW 6: Algorithm, Size, Export, Replot
453  // ----------------------------------------------------------------
454 
455  S.AddSpace(5);
456 
457  mAlgChoice = S.Id(FreqAlgChoiceID).Focus()
458  .MinSize( { wxDefaultCoord, wxDefaultCoord } )
459  .AddChoice(XXO("&Algorithm:"), algChoices, mAlg);
460 
461  S.AddSpace(5);
462 
464  .MinSize( { wxDefaultCoord, wxDefaultCoord } )
465  .AddChoice(XXO("&Size:"), sizeChoices, mSize);
466 
467  S.AddSpace(5);
468 
469  mExportButton = S.Id(FreqExportButtonID).AddButton(XXO("&Export..."));
470 
471  S.AddSpace(5);
472 
473 
474  // ----------------------------------------------------------------
475  // ROW 7: Function, Axix, Grids, Close
476  // ----------------------------------------------------------------
477 
478  S.AddSpace(5);
479 
481  .MinSize( { wxDefaultCoord, wxDefaultCoord } )
482  .AddChoice(XXO("&Function:"), funcChoices, mFunc);
483  mFuncChoice->MoveAfterInTabOrder(mSizeChoice);
484 
485  S.AddSpace(5);
486 
488  .MinSize( { wxDefaultCoord, wxDefaultCoord } )
489  .AddChoice(XXO("&Axis:"), axisChoices, mAxis);
490  mAxisChoice->MoveAfterInTabOrder(mFuncChoice);
491 
492  S.AddSpace(5);
493 
494  mReplotButton = S.Id(ReplotButtonID).AddButton(XXO("&Replot..."));
495 
496  S.AddSpace(5);
497 
498  //mCloseButton = S.Id(wxID_CANCEL).AddButton(XO("&Close"));
499 
500  //S.AddSpace(5);
501  }
502  S.EndMultiColumn();
503  S.AddStandardButtons( eHelpButton | eCloseButton );
504 
505  // -------------------------------------------------------------------
506  // ROW 8: Spacer
507  // -------------------------------------------------------------------
508 
509  S.AddSpace(5);
510 
511  mProgress = safenew FreqGauge(S.GetParent(), wxID_ANY); //, wxST_SIZEGRIP);
512  S.Position(wxEXPAND)
513  .AddWindow(mProgress);
514 
515  // Log-frequency axis works for spectrum plots only.
517  {
518  mAxis = 0;
519  mAxisChoice->Disable();
520  }
521  mLogAxis = mAxis != 0;
522 
523  mCloseButton = static_cast<wxButton*>(FindWindowById( wxID_CANCEL ));
524  mCloseButton->SetDefault();
525 
526  Layout();
527  Fit();
528  // Bug 1607:
529  Center();
530 
531  SetMinSize(GetSize());
532 
533 #if defined(__WXGTK__)
534  // This should be rechecked with wx3.
535  //
536  // The scrollbar (focus some reason) doesn't allow tabbing past it
537  // because it can't receive focus. So, convince it otherwise.
538  //
539  // Unfortunately, this still doesn't let you adjust the scrollbar
540  // from the keyboard. Near as I can tell, wxWGTK is capturing the
541  // keyboard input, so the GTK widget doesn't see it, preventing
542  // the normal scroll events from being generated.
543  //
544  // I guess the only way round it would be to handle key actions
545  // ourselves, but we'll leave that for a future date.
546 // gtk_widget_set_can_focus(mPanScroller->m_widget, true);
547 #endif
548 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddSpace(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddWindow(), ThemeBase::Colour(), dBRange, DecibelScaleCutoff, eCloseButton, eHelpButton, eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Focus(), fontSize, FREQ_WINDOW_HEIGHT, FreqAlgChoiceID, FreqAxisChoiceID, FreqExportButtonID, FreqFuncChoiceID, FreqPanScrollerID, FreqPlot, FreqSizeChoiceID, FrequencyAnalysisTitle, FreqZoomSliderID, ShuttleGuiBase::GetParent(), GridOnOffID, hRuler, ShuttleGui::Id(), RulerPanel::Options::LabelEdges(), Ruler::LinearDBFormat, RulerPanel::Options::Log(), mAlg, mAlgChoice, mArrowCursor, mAxis, mAxisChoice, mCloseButton, mCrossCursor, mCursorText, mDrawGrid, mExportButton, mFreqFont, mFreqPlot, mFunc, mFuncChoice, mGridOnOff, ShuttleGui::MinSize(), mLogAxis, mPanScroller, mPeakText, mProgress, mReplotButton, mSize, mSizeChoice, mWindowSize, mZoomSlider, ShuttleGui::Name(), NumWindowFuncs(), ShuttleGui::Position(), ShuttleGui::Prop(), Setting< T >::Read(), Ruler::RealFormat, ReplotButtonID, safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetSizerProportion(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::SetStretchyRow(), wxDialogWrapper::SetTitle(), size, SpectrumAnalyst::Spectrum, ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Style(), theTheme, Verbatim(), vRuler, WindowFuncName(), XO, XXO, ZoomIn, and ZoomOut.

Referenced by UpdatePrefs().

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

◆ Recalc()

void FrequencyPlotDialog::Recalc ( )
private

Definition at line 1010 of file FreqWindow.cpp.

1011 {
1012  if (!mData || mDataLen < mWindowSize) {
1013  DrawPlot();
1014  return;
1015  }
1016 
1018  SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
1019  int windowFunc = mFuncChoice->GetSelection();
1020 
1021  wxWindow *hadFocus = FindFocus();
1022  // In wxMac, the skipped window MUST be a top level window. I'd originally made it
1023  // just the mProgress window with the idea of preventing user interaction with the
1024  // controls while the plot was being recalculated. This doesn't appear to be necessary
1025  // so just use the top level window instead.
1026  {
1028  if (IsShown())
1029  blocker.emplace(this);
1030  wxYieldIfNeeded();
1031 
1032  mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
1033  mData.get(), mDataLen,
1034  &mYMin, &mYMax, mProgress);
1035  }
1036  if (hadFocus) {
1037  hadFocus->SetFocus();
1038  }
1039 
1040  if (alg == SpectrumAnalyst::Spectrum) {
1041  if(mYMin < -dBRange)
1042  mYMin = -dBRange;
1043  if(mYMax <= -dBRange)
1044  mYMax = -dBRange + 10.; // it's all out of range, but show a scale.
1045  else
1046  mYMax += .5;
1047  }
1048 
1049  // Prime the scrollbar
1050  mPanScroller->SetScrollbar(0, (mYMax - mYMin) * 100, (mYMax - mYMin) * 100, 1);
1051 
1052  DrawPlot();
1053 }

References dBRange, DrawPlot(), Optional< X >::emplace(), mAlgChoice, mAnalyst, mData, mDataLen, mFuncChoice, mPanScroller, mProgress, mRate, mWindowSize, mYMax, mYMin, and SpectrumAnalyst::Spectrum.

Referenced by OnRecalc(), and Show().

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

◆ SendRecalcEvent()

void FrequencyPlotDialog::SendRecalcEvent ( )
private

Definition at line 1004 of file FreqWindow.cpp.

1005 {
1006  wxCommandEvent e(EVT_FREQWINDOW_RECALC, wxID_ANY);
1007  GetEventHandler()->AddPendingEvent(e);
1008 }

Referenced by OnAlgChoice(), OnFuncChoice(), OnReplot(), and OnSizeChoice().

Here is the caller graph for this function:

◆ Show()

bool FrequencyPlotDialog::Show ( bool  show = true)
override

Definition at line 557 of file FreqWindow.cpp.

558 {
559  if (!show)
560  {
561  mFreqPlot->SetCursor(*mArrowCursor);
562  }
563 
564  bool shown = IsShown();
565 
566  if (show && !shown)
567  {
569  if(dBRange < 90.)
570  dBRange = 90.;
571  GetAudio();
572  // Don't send an event. We need the recalc right away.
573  // so that mAnalyst is valid when we paint.
574  //SendRecalcEvent();
575  Recalc();
576  }
577 
578  bool res = wxDialogWrapper::Show(show);
579 
580  return res;
581 }

References dBRange, DecibelScaleCutoff, GetAudio(), mArrowCursor, mFreqPlot, Setting< T >::Read(), and Recalc().

Referenced by OnCloseButton(), OnCloseWindow(), anonymous_namespace{FreqWindow.cpp}::Handler::OnPlotSpectrum(), and UpdatePrefs().

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

◆ UpdatePrefs()

void FrequencyPlotDialog::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 1120 of file FreqWindow.cpp.

1121 {
1122  bool shown = IsShown();
1123  if (shown) {
1124  Show(false);
1125  }
1126 
1127  auto zoomSlider = mZoomSlider->GetValue();
1128  auto drawGrid = mGridOnOff->GetValue();
1129  auto sizeChoice = mSizeChoice->GetStringSelection();
1130  auto algChoice = mAlgChoice->GetSelection();
1131  auto funcChoice = mFuncChoice->GetSelection();
1132  auto axisChoice = mAxisChoice->GetSelection();
1133 
1134  SetSizer(nullptr);
1135  DestroyChildren();
1136 
1137  Populate();
1138 
1139  mZoomSlider->SetValue(zoomSlider);
1140 
1141  mDrawGrid = drawGrid;
1142  mGridOnOff->SetValue(drawGrid);
1143 
1144  long windowSize = 0;
1145  sizeChoice.ToLong(&windowSize);
1146  mWindowSize = windowSize;
1147  mSizeChoice->SetStringSelection(sizeChoice);
1148 
1149  mAlg = static_cast<SpectrumAnalyst::Algorithm>(algChoice);
1150  mAlgChoice->SetSelection(algChoice);
1151 
1152  mFunc = funcChoice;
1153  mFuncChoice->SetSelection(funcChoice);
1154 
1155  mAxis = axisChoice;
1156  mAxisChoice->SetSelection(axisChoice);
1157 
1158  if (shown) {
1159  Show(true);
1160  }
1161 }

References mAlg, mAlgChoice, mAxis, mAxisChoice, mDrawGrid, mFunc, mFuncChoice, mGridOnOff, mSizeChoice, mWindowSize, mZoomSlider, Populate(), and Show().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ FreqPlot

friend class FreqPlot
friend

Definition at line 158 of file FreqWindow.h.

Referenced by Populate().

Member Data Documentation

◆ dBRange

int FrequencyPlotDialog::dBRange
private

Definition at line 104 of file FreqWindow.h.

Referenced by DrawPlot(), OnReplot(), Populate(), Recalc(), and Show().

◆ fontSize

const int FrequencyPlotDialog::fontSize = 10
staticprivate

Definition at line 110 of file FreqWindow.h.

Referenced by Populate().

◆ hRuler

RulerPanel* FrequencyPlotDialog::hRuler
private

Definition at line 114 of file FreqWindow.h.

Referenced by DrawPlot(), and Populate().

◆ mAlg

SpectrumAnalyst::Algorithm FrequencyPlotDialog::mAlg
private

Definition at line 101 of file FreqWindow.h.

Referenced by DrawPlot(), OnAlgChoice(), PlotPaint(), Populate(), and UpdatePrefs().

◆ mAlgChoice

wxChoice* FrequencyPlotDialog::mAlgChoice
private

Definition at line 129 of file FreqWindow.h.

Referenced by OnAlgChoice(), OnCloseButton(), OnExport(), Populate(), Recalc(), and UpdatePrefs().

◆ mAnalyst

std::unique_ptr<SpectrumAnalyst> FrequencyPlotDialog::mAnalyst
private

Definition at line 154 of file FreqWindow.h.

Referenced by DrawPlot(), OnExport(), PlotPaint(), and Recalc().

◆ mArrowCursor

std::unique_ptr<wxCursor> FrequencyPlotDialog::mArrowCursor
private

Definition at line 122 of file FreqWindow.h.

Referenced by PlotMouseEvent(), Populate(), and Show().

◆ mAxis

int FrequencyPlotDialog::mAxis
private

Definition at line 103 of file FreqWindow.h.

Referenced by Populate(), and UpdatePrefs().

◆ mAxisChoice

wxChoice* FrequencyPlotDialog::mAxisChoice
private

Definition at line 132 of file FreqWindow.h.

Referenced by OnAlgChoice(), OnAxisChoice(), OnCloseButton(), Populate(), and UpdatePrefs().

◆ mBitmap

std::unique_ptr<wxBitmap> FrequencyPlotDialog::mBitmap
private

Definition at line 149 of file FreqWindow.h.

Referenced by DrawBackground(), and PlotPaint().

◆ mCloseButton

wxButton* FrequencyPlotDialog::mCloseButton
private

Definition at line 125 of file FreqWindow.h.

Referenced by Populate().

◆ mCrossCursor

std::unique_ptr<wxCursor> FrequencyPlotDialog::mCrossCursor
private

Definition at line 123 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and Populate().

◆ mCursorText

wxTextCtrl* FrequencyPlotDialog::mCursorText
private

Definition at line 135 of file FreqWindow.h.

Referenced by PlotPaint(), and Populate().

◆ mData

Floats FrequencyPlotDialog::mData
private

Definition at line 141 of file FreqWindow.h.

Referenced by DrawPlot(), GetAudio(), PlotPaint(), and Recalc().

◆ mDataLen

size_t FrequencyPlotDialog::mDataLen
private

Definition at line 140 of file FreqWindow.h.

Referenced by DrawPlot(), GetAudio(), PlotPaint(), and Recalc().

◆ mDrawGrid

bool FrequencyPlotDialog::mDrawGrid
private

Definition at line 99 of file FreqWindow.h.

Referenced by DrawPlot(), OnCloseButton(), OnGridOnOff(), Populate(), and UpdatePrefs().

◆ mExportButton

wxButton* FrequencyPlotDialog::mExportButton
private

Definition at line 126 of file FreqWindow.h.

Referenced by Populate().

◆ mFreqFont

wxFont FrequencyPlotDialog::mFreqFont
private

Definition at line 120 of file FreqWindow.h.

Referenced by DrawBackground(), PlotPaint(), and Populate().

◆ mFreqPlot

FreqPlot* FrequencyPlotDialog::mFreqPlot
private

Definition at line 115 of file FreqWindow.h.

Referenced by DrawBackground(), DrawPlot(), PlotMouseEvent(), Populate(), and Show().

◆ mFunc

int FrequencyPlotDialog::mFunc
private

Definition at line 102 of file FreqWindow.h.

Referenced by Populate(), and UpdatePrefs().

◆ mFuncChoice

wxChoice* FrequencyPlotDialog::mFuncChoice
private

Definition at line 131 of file FreqWindow.h.

Referenced by OnCloseButton(), Populate(), Recalc(), and UpdatePrefs().

◆ mGridOnOff

wxCheckBox* FrequencyPlotDialog::mGridOnOff
private

Definition at line 128 of file FreqWindow.h.

Referenced by OnGridOnOff(), Populate(), and UpdatePrefs().

◆ mLogAxis

bool FrequencyPlotDialog::mLogAxis
private

Definition at line 144 of file FreqWindow.h.

Referenced by DrawPlot(), OnAlgChoice(), OnAxisChoice(), PlotPaint(), and Populate().

◆ mMouseX

int FrequencyPlotDialog::mMouseX
private

Definition at line 151 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and PlotPaint().

◆ mMouseY

int FrequencyPlotDialog::mMouseY
private

Definition at line 152 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and PlotPaint().

◆ mPanScroller

wxScrollBar* FrequencyPlotDialog::mPanScroller
private

Definition at line 133 of file FreqWindow.h.

Referenced by DrawPlot(), Populate(), and Recalc().

◆ mPeakText

wxTextCtrl* FrequencyPlotDialog::mPeakText
private

Definition at line 136 of file FreqWindow.h.

Referenced by PlotPaint(), and Populate().

◆ mPlotRect

wxRect FrequencyPlotDialog::mPlotRect
private

Definition at line 118 of file FreqWindow.h.

Referenced by DrawBackground(), DrawPlot(), PlotMouseEvent(), and PlotPaint().

◆ mProgress

FreqGauge* FrequencyPlotDialog::mProgress
private

Definition at line 116 of file FreqWindow.h.

Referenced by Populate(), and Recalc().

◆ mProject

AudacityProject* FrequencyPlotDialog::mProject
private

Definition at line 105 of file FreqWindow.h.

◆ mRate

double FrequencyPlotDialog::mRate
private

Definition at line 139 of file FreqWindow.h.

Referenced by DrawPlot(), GetAudio(), OnExport(), PlotPaint(), and Recalc().

◆ mReplotButton

wxButton* FrequencyPlotDialog::mReplotButton
private

Definition at line 127 of file FreqWindow.h.

Referenced by Populate().

◆ mSize

int FrequencyPlotDialog::mSize
private

Definition at line 100 of file FreqWindow.h.

Referenced by Populate().

◆ mSizeChoice

wxChoice* FrequencyPlotDialog::mSizeChoice
private

Definition at line 130 of file FreqWindow.h.

Referenced by OnCloseButton(), OnSizeChoice(), Populate(), and UpdatePrefs().

◆ mWindowSize

size_t FrequencyPlotDialog::mWindowSize
private

Definition at line 142 of file FreqWindow.h.

Referenced by DrawPlot(), OnExport(), OnSizeChoice(), PlotPaint(), Populate(), Recalc(), and UpdatePrefs().

◆ mYMax

float FrequencyPlotDialog::mYMax
private

Definition at line 146 of file FreqWindow.h.

Referenced by DrawPlot(), and Recalc().

◆ mYMin

float FrequencyPlotDialog::mYMin
private

Definition at line 145 of file FreqWindow.h.

Referenced by DrawPlot(), and Recalc().

◆ mYStep

float FrequencyPlotDialog::mYStep
private

Definition at line 147 of file FreqWindow.h.

◆ mZoomSlider

wxSlider* FrequencyPlotDialog::mZoomSlider
private

Definition at line 134 of file FreqWindow.h.

Referenced by DrawPlot(), Populate(), and UpdatePrefs().

◆ vRuler

RulerPanel* FrequencyPlotDialog::vRuler
private

Definition at line 113 of file FreqWindow.h.

Referenced by DrawPlot(), and Populate().


The documentation for this class was generated from the following files:
FrequencyPlotDialog::dBRange
int dBRange
Definition: FreqWindow.h:104
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
Optional::emplace
X & emplace(Args &&... args)
Definition: MemoryX.h:193
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
FrequencyPlotDialog::mSize
int mSize
Definition: FreqWindow.h:100
SpectrumAnalyst::Spectrum
@ Spectrum
Definition: SpectrumAnalyst.h:25
FrequencyPlotDialog::mYMax
float mYMax
Definition: FreqWindow.h:146
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
wxSliderWrapper
wxSlider wxSliderWrapper
Definition: ShuttleGui.h:105
RulerPanel
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
Optional
Like a smart pointer, allows for object to not exist (nullptr)
Definition: MemoryX.h:144
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
Ruler::LinearDBFormat
@ LinearDBFormat
Definition: Ruler.h:34
FreqPanScrollerID
@ FreqPanScrollerID
Definition: FreqWindow.cpp:101
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
FrequencyAnalysisTitle
#define FrequencyAnalysisTitle
Definition: FreqWindow.cpp:93
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: TranslatableString.h:295
ZoomIn
static const char * ZoomIn[]
Definition: FreqWindow.cpp:117
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:604
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
FreqZoomSliderID
@ FreqZoomSliderID
Definition: FreqWindow.cpp:100
Format
Abstract base class used in importing a file.
FrequencyPlotDialog::mDrawGrid
bool mDrawGrid
Definition: FreqWindow.h:99
FrequencyPlotDialog::mRate
double mRate
Definition: FreqWindow.h:139
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
Ruler::SetLog
void SetLog(bool log)
Definition: Ruler.cpp:142
FrequencyPlotDialog::Recalc
void Recalc()
Definition: FreqWindow.cpp:1010
NumWindowFuncs
int NumWindowFuncs()
Definition: FFT.cpp:329
FrequencyPlotDialog::mFreqFont
wxFont mFreqFont
Definition: FreqWindow.h:120
FrequencyPlotDialog::mProgress
FreqGauge * mProgress
Definition: FreqWindow.h:116
FrequencyPlotDialog::DrawBackground
void DrawBackground(wxMemoryDC &dc)
Definition: FreqWindow.cpp:649
FrequencyPlotDialog::mAxis
int mAxis
Definition: FreqWindow.h:103
FreqExportButtonID
@ FreqExportButtonID
Definition: FreqWindow.cpp:102
XO
#define XO(s)
Definition: Internat.h:31
FrequencyPlotDialog::mSizeChoice
wxChoice * mSizeChoice
Definition: FreqWindow.h:130
Ruler::SetFormat
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:131
Ruler::RealFormat
@ RealFormat
Definition: Ruler.h:31
FrequencyPlotDialog::mAlg
SpectrumAnalyst::Algorithm mAlg
Definition: FreqWindow.h:101
FrequencyPlotDialog::mZoomSlider
wxSlider * mZoomSlider
Definition: FreqWindow.h:134
ReplotButtonID
@ ReplotButtonID
Definition: FreqWindow.cpp:107
FileNames::AllFiles
FILES_API const FileType AllFiles
Definition: FileNames.h:71
fillZero
@ fillZero
Definition: SampleFormat.h:54
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
FreqToMIDInote
double FreqToMIDInote(const double freq)
Definition: PitchName.cpp:29
PitchName_Absolute
TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
Definition: PitchName.cpp:154
Ruler::SetUnits
void SetUnits(const TranslatableString &units)
Definition: Ruler.cpp:153
FrequencyPlotDialog::mFuncChoice
wxChoice * mFuncChoice
Definition: FreqWindow.h:131
FrequencyPlotDialog::Show
bool Show(bool show=true) override
Definition: FreqWindow.cpp:557
FREQ_WINDOW_HEIGHT
#define FREQ_WINDOW_HEIGHT
Definition: FreqWindow.cpp:114
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:128
FrequencyPlotDialog::mCursorText
wxTextCtrl * mCursorText
Definition: FreqWindow.h:135
Ruler::GetMaxSize
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603
FrequencyPlotDialog::GetAudio
void GetAudio()
Definition: FreqWindow.cpp:583
ZoomOut
static const char * ZoomOut[]
Definition: FreqWindow.cpp:143
RulerPanel::Range
std::pair< double, double > Range
Definition: Ruler.h:232
FrequencyPlotDialog::mAlgChoice
wxChoice * mAlgChoice
Definition: FreqWindow.h:129
FrequencyPlotDialog::vRuler
RulerPanel * vRuler
Definition: FreqWindow.h:113
FrequencyPlotDialog::mExportButton
wxButton * mExportButton
Definition: FreqWindow.h:126
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
XXO
#define XXO(s)
Definition: Internat.h:44
FrequencyPlotDialog::mBitmap
std::unique_ptr< wxBitmap > mBitmap
Definition: FreqWindow.h:149
FrequencyPlotDialog::Populate
void Populate()
Definition: FreqWindow.cpp:220
FrequencyPlotDialog::mMouseX
int mMouseX
Definition: FreqWindow.h:151
FrequencyPlotDialog::mLogAxis
bool mLogAxis
Definition: FreqWindow.h:144
FileNames::TextFiles
FILES_API const FileType TextFiles
Definition: FileNames.h:74
FrequencyPlotDialog::mYMin
float mYMin
Definition: FreqWindow.h:145
FrequencyPlotDialog::mDataLen
size_t mDataLen
Definition: FreqWindow.h:140
FrequencyPlotDialog::mCloseButton
wxButton * mCloseButton
Definition: FreqWindow.h:125
FreqFuncChoiceID
@ FreqFuncChoiceID
Definition: FreqWindow.cpp:105
FrequencyPlotDialog::mProject
AudacityProject * mProject
Definition: FreqWindow.h:105
FrequencyPlotDialog::mPlotRect
wxRect mPlotRect
Definition: FreqWindow.h:118
FrequencyPlotDialog::mCrossCursor
std::unique_ptr< wxCursor > mCrossCursor
Definition: FreqWindow.h:123
FreqAlgChoiceID
@ FreqAlgChoiceID
Definition: FreqWindow.cpp:103
Ruler::SetRange
void SetRange(double min, double max)
Definition: Ruler.cpp:188
WindowAccessible
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
FrequencyPlotDialog::mAnalyst
std::unique_ptr< SpectrumAnalyst > mAnalyst
Definition: FreqWindow.h:154
FreqGauge
Definition: SpectrumAnalyst.h:63
WindowFuncName
const TranslatableString WindowFuncName(int whichFunction)
Definition: FFT.cpp:334
DecibelScaleCutoff
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
RulerPanel::Options::LabelEdges
Options & LabelEdges(bool l)
Definition: Ruler.h:250
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
FrequencyPlotDialog::DrawPlot
void DrawPlot()
Definition: FreqWindow.cpp:671
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
FrequencyPlotDialog::hRuler
RulerPanel * hRuler
Definition: FreqWindow.h:114
FrequencyPlotDialog::mArrowCursor
std::unique_ptr< wxCursor > mArrowCursor
Definition: FreqWindow.h:122
_
#define _(s)
Definition: Internat.h:75
FrequencyPlotDialog::mFreqPlot
FreqPlot * mFreqPlot
Definition: FreqWindow.h:115
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:610
RulerPanel::Options
Definition: Ruler.h:234
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
RulerPanel::ruler
Ruler ruler
Definition: Ruler.h:288
FreqSizeChoiceID
@ FreqSizeChoiceID
Definition: FreqWindow.cpp:104
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
FrequencyPlotDialog::SendRecalcEvent
void SendRecalcEvent()
Definition: FreqWindow.cpp:1004
wxDialogWrapper::SetTitle
void SetTitle(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:66
SpectrumAnalyst::Algorithm
Algorithm
Definition: SpectrumAnalyst.h:24
FrequencyPlotDialog::mPanScroller
wxScrollBar * mPanScroller
Definition: FreqWindow.h:133
FrequencyPlotDialog::mFunc
int mFunc
Definition: FreqWindow.h:102
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
FrequencyPlotDialog::mGridOnOff
wxCheckBox * mGridOnOff
Definition: FreqWindow.h:128
FrequencyPlotDialog::mMouseY
int mMouseY
Definition: FreqWindow.h:152
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
FrequencyPlotDialog::fontSize
static const int fontSize
Definition: FreqWindow.h:110
GridOnOffID
@ GridOnOffID
Definition: FreqWindow.cpp:108
FrequencyPlotDialog::mPeakText
wxTextCtrl * mPeakText
Definition: FreqWindow.h:136
safenew
#define safenew
Definition: MemoryX.h:10
FreqAxisChoiceID
@ FreqAxisChoiceID
Definition: FreqWindow.cpp:106
Ruler::DrawGrid
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:1521
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
ArrayOf< float >
FrequencyPlotDialog::mAxisChoice
wxChoice * mAxisChoice
Definition: FreqWindow.h:132
FrequencyPlotDialog::mWindowSize
size_t mWindowSize
Definition: FreqWindow.h:142
RulerPanel::Options::Log
Options & Log(bool l)
Definition: Ruler.h:244
FrequencyPlotDialog::mReplotButton
wxButton * mReplotButton
Definition: FreqWindow.h:127
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
FrequencyPlotDialog::FreqPlot
friend class FreqPlot
Definition: FreqWindow.h:158
FrequencyPlotDialog::mData
Floats mData
Definition: FreqWindow.h:141