[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdemultimedia/noatun/library
From: Charles Samuels <charles () kde ! org>
Date: 2004-05-17 17:11:27
Message-ID: 20040517171127.ED7959192 () office ! kde ! org
[Download RAW message or body]
CVS commit by charles:
fix the FFT at last!
No more weird crashing due to it.
this may also resolve problems that may or may not exist in kjofol.
CCMAIL:Yogesh Marwaha <yogeshm02@rediffmail.com>
CCMAIL:Stefan Gehn <sgehn@gmx.net>
M +6 -2 plugin.cpp 1.46
M +5 -2 noatun/plugin.h 1.5
M +54 -55 noatunarts/FFTScopes.cpp 1.4
--- kdemultimedia/noatun/library/plugin.cpp #1.45:1.46
@@ -10,5 +10,6 @@
#include <kdebug.h>
#include <kstandarddirs.h>
-#include <stdlib.h>
+
+#include <cmath>
#include "plugin_deps.h"
@@ -213,5 +214,5 @@ FFTScope::FFTScope(int interval, int pid
float FFTScope::magic(int bands)
{
- QString path=locate("data", "noatun/magictable");
+/* QString path=locate("data", "noatun/magictable");
QFile magic(path);
if (!magic.open(IO_ReadOnly | IO_Raw))
@@ -223,4 +224,7 @@ float FFTScope::magic(int bands)
if (magic.readBlock((char*)&value, sizeof(float))==-1)
value=0;
+*/
+ float value = std::log(std::pow(2046.0, 1.0/bands));
+
return value;
}
--- kdemultimedia/noatun/library/noatun/plugin.h #1.4:1.5
@@ -169,6 +169,4 @@ public:
* bands()==50
* </pre>
- * This is a potentially slower function,
- * but never more than a few milliseconds
**/
static float magic(int bands);
@@ -184,4 +182,9 @@ public:
* This will only return valid responses
* for values between 10 and 1024
+ *
+ * This function is a terrible hack, and we apologize
+ * for it. The values of these magic numbers
+ * do occasionally change, so you must use
+ * @ref magic
**/
virtual void setBands(float n)=0;
--- kdemultimedia/noatun/library/noatunarts/FFTScopes.cpp #1.3:1.4
@@ -24,5 +24,7 @@ Boston, MA 02111-1307, USA.
#include "fft.h"
#include <stdsynthmodule.h>
-#include <math.h>
+#include <cmath>
+
+#include <iostream>
using namespace std;
@@ -41,25 +43,22 @@ static void doFft(float combine, float *
scope.clear();
- unsigned int start=0;
- unsigned int end=3;
-
- float *out_imgIt=out_real;
- float *out_realIt=out_img;
+ int previous=0;
+ int index=40;
- while (start < SAMPLES/2)
+ while (previous < 2048 && index < 2048)
{
- float xrange(0.0);
+ int end = int(std::exp(double(index)*combine));
+ float xrange = 0.0;
- do
+ while (previous < end)
{
- xrange += (fabs(*out_imgIt) + fabs(*out_realIt))/(float)SAMPLES;
- ++start;
- out_imgIt++;
- out_realIt++;
- } while(start < end);
+ xrange += (std::fabs(out_img[previous]) + std::fabs(out_real[previous]));
+ previous++;
+ }
+ xrange /= float(SAMPLES);
scope.push_back(xrange);
- end=(int)((float)(start+1)*combine);
- ++end;
+
+ index++;
}
}
@@ -137,5 +136,5 @@ public:
}
- FFTScopeStereo_impl()
+ FFTScopeStereo_impl() : mCombine(0.152492)
{
mWindow = new float[SAMPLES];
@@ -226,5 +225,5 @@ public:
}
- FFTScope_impl() : mCombine(1.1)
+ FFTScope_impl() : mCombine(0.152492)
{
mWindow = new float[SAMPLES];
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic