Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv25159

Modified Files:
        FreqWindow.cpp FreqWindow.h 
Log Message:
Add control to turn grid on and off.
Increase possible audio length by factor of 10.
Correct scaling of Spectrum (13.4.5 of 
http://www.nrbook.com/a/bookcpdf/c13-4.pdf refers).

Index: FreqWindow.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FreqWindow.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- FreqWindow.h        24 Feb 2009 00:02:14 -0000      1.12
+++ FreqWindow.h        24 Feb 2009 23:12:18 -0000      1.13
@@ -75,6 +75,7 @@
    void OnAxisChoice(wxCommandEvent & event);
    void OnExport(wxCommandEvent & event);
    void OnReplot(wxCommandEvent & event);
+   void OnGridOnOff(wxCommandEvent & event);
 
    void Recalc();
    void DrawPlot();
@@ -109,6 +110,7 @@
    wxChoice *mSizeChoice;
    wxChoice *mFuncChoice;
    wxChoice *mAxisChoice;
+   wxCheckBox *mGridOnOff;
 
    wxRect mPlotRect;
    wxRect mInfoRect;

Index: FreqWindow.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FreqWindow.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- FreqWindow.cpp      24 Feb 2009 21:10:52 -0000      1.65
+++ FreqWindow.cpp      24 Feb 2009 23:12:18 -0000      1.66
@@ -84,7 +84,8 @@
    FreqSizeChoiceID,
    FreqFuncChoiceID,
    FreqAxisChoiceID,
-   ReplotButtonID
+   ReplotButtonID,
+   GridOnOffID
 };
 
 FreqWindow *gFreqWindow = NULL;
@@ -125,6 +126,7 @@
     EVT_CHOICE(FreqFuncChoiceID, FreqWindow::OnFuncChoice)
     EVT_CHOICE(FreqAxisChoiceID, FreqWindow::OnAxisChoice)
     EVT_BUTTON(ReplotButtonID, FreqWindow::OnReplot)
+    EVT_CHECKBOX(GridOnOffID, FreqWindow::OnGridOnOff)
 END_EVENT_TABLE()
 
 FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
@@ -237,6 +239,12 @@
                                _("Close"));
    mCloseButton->SetName(_("Close"));
 
+   mGridOnOff = new wxCheckBox(this, GridOnOffID, _("Grids"),
+                            wxDefaultPosition, wxDefaultSize,
+                            wxALIGN_RIGHT);
+   mGridOnOff->SetName(_("Grids"));
+   mGridOnOff->SetValue(mDrawGrid);
+
 #ifndef TARGET_CARBON
    mCloseButton->SetDefault();
    mCloseButton->SetFocus();
@@ -348,7 +356,7 @@
    hs->Add( 10, 1, 0 );
    hs->Add( mCloseButton, 0, wxALIGN_CENTER | wxALIGN_RIGHT | wxLEFT | 
wxRIGHT, 5 );
    gs->Add( hs, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxBOTTOM, 5 
);
-   // still some gs space for grid on-off control
+   gs->Add( mGridOnOff, 0, wxALIGN_CENTER | wxALIGN_RIGHT | wxLEFT | wxRIGHT, 
5 );
    vs->Add( gs, 0, wxEXPAND | wxBOTTOM, 0 );
 
    vs->Add( mInfo, 0, wxEXPAND | wxBOTTOM, 0 );
@@ -394,9 +402,9 @@
             start = track->TimeToLongSamples(p->mViewInfo.sel0);
             end = track->TimeToLongSamples(p->mViewInfo.sel1);
             len = (sampleCount)(end - start);
-            if (len > 1048576) {
+            if (len > 10485760) {
                warning = true;
-               len = 1048576;
+               len = 10485760;
             }
             buffer = new float[len];
             track->Get((samplePtr)buffer, floatSample, start, len);
@@ -1054,13 +1062,15 @@
    }
 
    switch (alg) {
+   double scale;
    case 0:                     // Spectrum
       // Convert to decibels
       mYMin = 1000000.;
       mYMax = -1000000.;
+      scale = (double)mWindowSize * (double)mWindowSize * (double)windows;
       for (i = 0; i < half; i++)
       {
-         mProcessed[i] = 10 * log10(mProcessed[i] / mWindowSize / windows);
+         mProcessed[i] = 10 * log10(mProcessed[i] / scale);
          if(mProcessed[i] > mYMax)
             mYMax = mProcessed[i];
          else if(mProcessed[i] < mYMin)
@@ -1214,6 +1224,15 @@
    gFreqWindow->Plot();
 }
 
+void FreqWindow::OnGridOnOff(wxCommandEvent & WXUNUSED(event))
+{
+   if( mGridOnOff->IsChecked() )
+      mDrawGrid = true;
+   else
+      mDrawGrid = false;
+   gFreqWindow->Plot();
+}
+
 BEGIN_EVENT_TABLE(FreqPlot, wxWindow)
    EVT_ERASE_BACKGROUND(FreqPlot::OnErase)
    EVT_PAINT(FreqPlot::OnPaint)


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to