diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 11:32:16 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 11:32:16 +0000 |
| commit | 8150882845f1eb089a0cba6fecd25c7bdc3c9540 (patch) | |
| tree | 6e73cf953a0b7272e9b2a9968edde8764e757db3 /src/plugins/Visual/analyzer/fft.c | |
| parent | b5dc393952c84dbd53c60afb8d367ad99bbd16ca (diff) | |
| download | qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.tar.gz qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.tar.bz2 qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.zip | |
ported analyzer plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5902 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Visual/analyzer/fft.c')
| -rw-r--r-- | src/plugins/Visual/analyzer/fft.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/Visual/analyzer/fft.c b/src/plugins/Visual/analyzer/fft.c index 0ea89eae6..2865e878e 100644 --- a/src/plugins/Visual/analyzer/fft.c +++ b/src/plugins/Visual/analyzer/fft.c @@ -25,6 +25,11 @@ * More optimisations. */ +/* + modifications compared to original code: + using float format for input data +*/ + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -56,7 +61,7 @@ struct _struct_fft_state { /* # Local function prototypes # */ /* ############################# */ -static void fft_prepare(const sound_sample * input, float *re, float *im); +static void fft_prepare(const float *input, float *re, float *im); static void fft_calculate(float *re, float *im); static void fft_output(const float *re, const float *im, float *output); static int reverseBits(unsigned int initial); @@ -126,7 +131,7 @@ fft_init(void) * state is a (non-NULL) pointer returned by fft_init. */ void -fft_perform(const sound_sample * input, float *output, fft_state * state) +fft_perform(const float *input, float *output, fft_state * state) { /* Convert data from sound format to be ready for FFT */ fft_prepare(input, state->real, state->imag); @@ -156,7 +161,7 @@ fft_close(fft_state * state) * Prepare data to perform an FFT on */ static void -fft_prepare(const sound_sample * input, float *re, float *im) +fft_prepare(const float *input, float *re, float *im) { unsigned int i; float *realptr = re; @@ -164,7 +169,7 @@ fft_prepare(const sound_sample * input, float *re, float *im) /* Get input, in reverse bit order */ for (i = 0; i < FFT_BUFFER_SIZE; i++) { - *realptr++ = input[bitReverse[i]]; + *realptr++ = input[bitReverse[i]] * 32767.0; *imagptr++ = 0; } } @@ -174,7 +179,7 @@ fft_prepare(const sound_sample * input, float *re, float *im) * Note: only produces half as many data points as the input had. * This is roughly a consequence of the Nyquist sampling theorm thingy. * (FIXME - make this comment better, and helpful.) - * + * * The two divisions by 4 are also a consequence of this: the contributions * returned for each frequency are split into two parts, one at i in the * table, and the other at FFT_BUFFER_SIZE - i, except for i = 0 and |
