Update of /cvsroot/audacity/audacity-src/src/prefs
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv14652/src/prefs

Modified Files:
        SpectrumPrefs.cpp SpectrumPrefs.h 
Log Message:
Improvements to Spectrum view by Salvo Ventura (with a little input from me).  
From his comments:
Added support for autoMaxFrequency, so that spectrum plot automatically scales 
up to Fs/2
GetSpectrogram now saves and retrieves autoMaxFrequency and WindowType from 
config. This is configurable from prefs.
DrawVRuler now draws a vertical rules also in the case of Spectrum
Added optional parameter windowFunc to ComputeSpectrum
Consolidated some for loops in a single one (Spectrum.cpp)
Changed the todB_a for a "10*log10" with control (Spectrum.cpp)
Added selection box for windowType and checkBox for AutoMaxFrequency to scale 
the y axis in spectrum view
All params are saved in config file.
Disable the MaxFreq control when AutoMaxFrequency is TRUE (thx to James)

Index: SpectrumPrefs.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/SpectrumPrefs.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- SpectrumPrefs.h     6 Jun 2006 11:40:45 -0000       1.5
+++ SpectrumPrefs.h     30 Nov 2006 01:03:01 -0000      1.6
@@ -8,6 +8,17 @@
   James Crook
 
 **********************************************************************/
+/*
+  Salvo Ventura
+  November 2006
+
+  Added selection box for windowType and checkBox for AutoMaxFrequency
+  to scale the y axis in spectrum view
+
+  All params are saved in config file.
+  Disable the MaxFreq control when AutoMaxFrequency is TRUE (thx to James)
+*/
+
 
 #ifndef __AUDACITY_SPECTRUM_PREFS__
 #define __AUDACITY_SPECTRUM_PREFS__
@@ -20,7 +31,7 @@
 class wxWindow;
 class ShuttleGui;
 
-class SpectrumPrefs:public PrefsPanel 
+class SpectrumPrefs:public PrefsPanel
 {
 public:
    SpectrumPrefs(wxWindow * parent);
@@ -29,8 +40,14 @@
 
 private:
    void Populate();
+   void SpectrumPrefs::OnCheckAutoMaxFrequency(wxCommandEvent &event);
    void PopulateOrExchange( ShuttleGui & S );
    wxString maxFreqStr;
+   int windowType;
+   bool autoMaxFrequency;
+
+public:
+   DECLARE_EVENT_TABLE();
 };
 
 #endif

Index: SpectrumPrefs.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/SpectrumPrefs.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- SpectrumPrefs.cpp   19 Jun 2006 13:13:59 -0000      1.15
+++ SpectrumPrefs.cpp   30 Nov 2006 01:03:01 -0000      1.16
@@ -23,6 +23,16 @@
 #include "../Prefs.h"
 #include "../ShuttleGui.h"
 #include "SpectrumPrefs.h"
+#include "../FFT.h"
+
+enum {
+   ID_AUTOMAXFREQUENCY = 8000,
+   ID_MAXFREQUENCY
+};
+
+BEGIN_EVENT_TABLE(SpectrumPrefs, wxPanel)
+   EVT_CHECKBOX(ID_AUTOMAXFREQUENCY, SpectrumPrefs::OnCheckAutoMaxFrequency)
+END_EVENT_TABLE()
 
 SpectrumPrefs::SpectrumPrefs(wxWindow * parent):
    PrefsPanel(parent)
@@ -32,15 +42,24 @@
    Populate( );
 }
 
+void SpectrumPrefs::OnCheckAutoMaxFrequency(wxCommandEvent &event) {
+   FindWindow( ID_MAXFREQUENCY )->Enable( !event.IsChecked() );
+}
+
 void SpectrumPrefs::Populate( )
 {
+   int maxFreq;
+
    // First any pre-processing for constructing the GUI.
    // Unusual handling of maxFreqStr because it is a validated input.
-   int maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);
+   gPrefs->Read(wxT("/Spectrum/MaxFreq"), &maxFreq, 8000L);
+   gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, 3L);
+   gPrefs->Read(wxT("/Spectrum/AutoMaxFrequency"), &autoMaxFrequency, false);
+
    maxFreqStr.Printf(wxT("%d"), maxFreq);
    //------------------------- Main section --------------------
    // Now construct the GUI itself.
-   // Use 'eIsCreatingFromPrefs' so that the GUI is 
+   // Use 'eIsCreatingFromPrefs' so that the GUI is
    // initialised with values from gPrefs.
    ShuttleGui S(this, eIsCreatingFromPrefs);
    PopulateOrExchange(S);
@@ -49,6 +68,11 @@
 
 void SpectrumPrefs::PopulateOrExchange( ShuttleGui & S )
 {
+   wxArrayString windowTypeList;
+
+   for(int i=0; i<NumWindowFuncs(); i++)
+      windowTypeList.Add(WindowFuncName(i));
+
    S.SetBorder( 2 );
    S.StartHorizontalLay(wxEXPAND, 0 );
    S.StartStatic( _("FFT Size"), 0 );
@@ -65,24 +89,37 @@
       S.TieRadioButton( wxT("2048"),                2048);
       S.TieRadioButton( _("4096 - most narrowband"),4096);
       S.EndRadioButtonGroup();
-   }                              
+
+      // add choice for windowtype
+      S.StartMultiColumn(2, wxCENTER);
+      {
+         S.TieChoice( _("Window type:"), windowType,  &windowTypeList);
+         S.SetSizeHints(-1,-1);
+      }
+      S.EndMultiColumn();
+   }
    S.EndStatic();
    S.StartStatic( _("Display"),1 );
    {
       // JC: For layout of mixtures of controls I prefer checkboxes on the 
right,
       // with everything in two columns over what we have here.
-      S.TieCheckBox( _("&Grayscale"),
-         wxT("/Spectrum/Grayscale"), false);
+      S.TieCheckBox( _("&Grayscale"), wxT("/Spectrum/Grayscale"), false);
       S.StartTwoColumn(); // 2 cols because we have a control with a separate 
label.
-      S.TieTextBox( 
+      S.Id(ID_MAXFREQUENCY).TieTextBox(
          _("Maximum Frequency (Hz):"), // prompt
          maxFreqStr, // String to exchange with
          12 // max number of characters (used to size the control).
          );
       S.EndTwoColumn();
+      // auto max frequency: will always set to Fs/2: if automax is true,
+      // then the other control should be grayed out
+      S.Id(ID_AUTOMAXFREQUENCY).TieCheckBox( _("&Auto max frequency (Fs/2)"), 
wxT("/Spectrum/AutoMaxFrequency"), false);
    }
    S.EndStatic();
    S.EndHorizontalLay();
+
+   gPrefs->Read(wxT("/Spectrum/AutoMaxFrequency"), &autoMaxFrequency, false);
+   FindWindow( ID_MAXFREQUENCY )->Enable(!autoMaxFrequency);
 }
 
 
@@ -94,8 +131,8 @@
    // maxFreqStr is an input field that has validation.
    // We've handled it slightly differently to all the
    // other fields, which just go straight through to gPrefs.
-   // Instead ShuttleGui has been told to only do a one step 
-   // exchange with it, not including gPrefs..  so we now 
+   // Instead ShuttleGui has been told to only do a one step
+   // exchange with it, not including gPrefs..  so we now
    // need to validate it and possibly write it back to gPrefs.
 
    //---- Validation of maxFreqStr
@@ -111,12 +148,13 @@
    //---- End of validation of maxFreqStr.
 
    gPrefs->Write(wxT("/Spectrum/MaxFreq"), maxFreq);
+   gPrefs->Write(wxT("/Spectrum/WindowType"), windowType);
+   gPrefs->Write(wxT("/Spectrum/AutoMaxFrequency"), autoMaxFrequency);
 
    // TODO: Force all projects to repaint themselves
    return true;
 }
 
-
 SpectrumPrefs::~SpectrumPrefs()
 {
 }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to