Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv12989/src
Modified Files:
FFT.cpp FFT.h FreqWindow.cpp
Log Message:
Salvo's additional window functions.
Index: FreqWindow.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FreqWindow.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- FreqWindow.cpp 23 Sep 2006 02:28:04 -0000 1.38
+++ FreqWindow.cpp 17 Nov 2006 00:49:16 -0000 1.39
@@ -26,6 +26,11 @@
*//*******************************************************************/
+/*
+ Salvo Ventura - November 2006
+ Extended range check for additional FFT windows
+*/
+
#include "Audacity.h"
@@ -143,7 +148,7 @@
wxStaticText *algLabel = new wxStaticText(this, wxID_ANY, _("Algorithm:"));
mAlgChoice = new wxChoice(this, FreqAlgChoiceID,
wxDefaultPosition, wxDefaultSize,
- 4, algChoiceStrings);
+ 5, algChoiceStrings);
mAlgChoice->SetSelection(0);
@@ -818,7 +823,7 @@
(mSizeChoice->GetStringSelection()).ToLong(&windowSize);
if (!(windowSize >= 32 && windowSize <= 65536 &&
- alg >= 0 && alg <= 3 && windowFunc >= 0 && windowFunc <= 3)) {
+ alg >= 0 && alg <= 3 && windowFunc >= 0 && windowFunc <= 9)) {
mFreqPlot->Refresh(true);
return;
}
Index: FFT.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FFT.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- FFT.cpp 15 Jun 2006 14:26:13 -0000 1.8
+++ FFT.cpp 17 Nov 2006 00:49:16 -0000 1.9
@@ -6,8 +6,6 @@
September 2000
-
-
*******************************************************************//*!
\file FFT.cpp
@@ -30,7 +28,16 @@
calculate a real FFT and a real power spectrum.
*//*******************************************************************/
-
+/*
+ Salvo Ventura - November 2006
+ Added more window functions:
+ * 4: Blackman
+ * 5: Blackman-Harris
+ * 6: Welch
+ * 7: Gaussian(a=2.5)
+ * 8: Gaussian(a=3.5)
+ * 9: Gaussian(a=4.5)
+*/
#include <wx/intl.h>
#include <stdlib.h>
@@ -361,7 +368,7 @@
int NumWindowFuncs()
{
- return 4;
+ return 10;
}
const wxChar *WindowFuncName(int whichFunction)
@@ -376,12 +383,25 @@
return wxT("Hamming");
case 3:
return wxT("Hanning");
+ case 4:
+ return wxT("Blackman");
+ case 5:
+ return wxT("Blackman-Harris");
+ case 6:
+ return wxT("Welch");
+ case 7:
+ return wxT("Gaussian(a=2.5)");
+ case 8:
+ return wxT("Gaussian(a=3.5)");
+ case 9:
+ return wxT("Gaussian(a=4.5)");
}
}
void WindowFunc(int whichFunction, int NumSamples, float *in)
{
int i;
+ double A;
if (whichFunction == 1) {
// Bartlett (triangular) window
@@ -403,6 +423,62 @@
for (i = 0; i < NumSamples; i++)
in[i] *= 0.50 - 0.50 * cos(2 * M_PI * i / (NumSamples - 1));
}
+
+ if (whichFunction == 4) {
+ // Blackman
+ for (i = 0; i < NumSamples; i++) {
+ in[i] *= 0.42 - 0.5 * cos (2 * M_PI * i / (NumSamples - 1)) + 0.08 *
cos (4 * M_PI * i / (NumSamples - 1));
+ }
+ }
+
+ if (whichFunction == 5) {
+ // Blackman-Harris
+ for (i = 0; i < NumSamples; i++) {
+ in[i] *= 0.35875 - 0.48829 * cos(2 * M_PI * i /(NumSamples-1)) +
0.14128 * cos(4 * M_PI * i/(NumSamples-1)) - 0.01168 * cos(6 * M_PI *
i/(NumSamples-1));
+ }
+ }
+
+ if (whichFunction == 6) {
+ // Welch
+ for (i = 0; i < NumSamples; i++) {
+ in[i] *= 4*i/(float)NumSamples*(1-(i/(float)NumSamples));
+ }
+ }
+
+ if (whichFunction == 7) {
+ // Gaussian (a=2.5)
+ // Precalculate some values, and simplify the fmla to try and reduce
overhead
+ A=-2*2.5*2.5;
+
+ for (i = 0; i < NumSamples; i++) {
+ // full
+ // in[i] *=
exp(-0.5*(A*((i-NumSamples/2)/NumSamples/2))*(A*((i-NumSamples/2)/NumSamples/2)));
+ // reduced
+ in[i] *= exp(A*(0.25 + ((i/(float)NumSamples)*(i/(float)NumSamples))
- (i/(float)NumSamples)));
+ }
+ }
+
+ if (whichFunction == 8) {
+ // Gaussian (a=3.5)
+ A=-2*3.5*3.5;
+
+ for (i = 0; i < NumSamples; i++) {
+ // reduced
+ in[i] *= exp(A*(0.25 + ((i/(float)NumSamples)*(i/(float)NumSamples))
- (i/(float)NumSamples)));
+ }
+ }
+
+ if (whichFunction == 9) {
+ // Gaussian (a=4.5)
+ A=-2*4.5*4.5;
+
+ for (i = 0; i < NumSamples; i++) {
+ // reduced
+ in[i] *= exp(A*(0.25 + ((i/(float)NumSamples)*(i/(float)NumSamples))
- (i/(float)NumSamples)));
+ }
+ }
+
+
}
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
Index: FFT.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FFT.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- FFT.h 8 Feb 2005 04:49:30 -0000 1.4
+++ FFT.h 17 Nov 2006 00:49:16 -0000 1.5
@@ -29,6 +29,16 @@
you need to use doubles.
**********************************************************************/
+/*
+ Salvo Ventura - November 2006
+ Added more window functions:
+ * 4: Blackman
+ * 5: Blackman-Harris
+ * 6: Welch
+ * 7: Gaussian(a=2.5)
+ * 8: Gaussian(a=3.5)
+ * 9: Gaussian(a=4.5)
+*/
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
@@ -72,6 +82,12 @@
* 1: Bartlett (triangular)
* 2: Hamming
* 3: Hanning
+ * 4: Blackman
+ * 5: Blackman-Harris
+ * 6: Welch
+ * 7: Gaussian(a=2.5)
+ * 8: Gaussian(a=3.5)
+ * 9: Gaussian(a=4.5)
*/
void WindowFunc(int whichFunction, int NumSamples, float *data);
-------------------------------------------------------------------------
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