[vlc-commits] glspectrum: use FFT Windowing
Ron Wright
git at videolan.org
Sat Feb 8 15:39:41 CET 2014
vlc | branch: master | Ron Wright <logiconcepts819 at gmail.com> | Sat Feb 8 15:34:45 2014 +0100| [23cd7b25da73d295093b8d218e8719ec4492b23d] | committer: Jean-Baptiste Kempf
glspectrum: use FFT Windowing
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23cd7b25da73d295093b8d218e8719ec4492b23d
---
modules/visualization/Modules.am | 3 ++-
modules/visualization/glspectrum.c | 15 +++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/modules/visualization/Modules.am b/modules/visualization/Modules.am
index 60d376d..ecea82f 100644
--- a/modules/visualization/Modules.am
+++ b/modules/visualization/Modules.am
@@ -17,4 +17,5 @@ visualization_LTLIBRARIES += libvisual_plugin.la
SOURCES_vsxu = vsxu.cpp cyclic_buffer.h
-SOURCES_glspectrum = glspectrum.c visual/fft.c visual/fft.h
+SOURCES_glspectrum = glspectrum.c visual/fft.c visual/fft.h \
+ visual/window.c visual/window.h visual/window_presets.h
diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index a361ef0..3b0ad9d 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -40,6 +40,7 @@
#include <math.h>
#include "visual/fft.h"
+#include "visual/window.h"
/*****************************************************************************
@@ -94,6 +95,9 @@ struct filter_sys_t
/* Window size */
int i_width;
int i_height;
+
+ /* FFT window parameters */
+ window_param wind_param;
};
@@ -135,6 +139,9 @@ static int Open(vlc_object_t * p_this)
p_sys->f_rotationAngle = 0;
p_sys->f_rotationIncrement = ROTATION_INCREMENT;
+ /* Fetch the FFT window parameters */
+ window_get_param( VLC_OBJECT( p_filter ), &p_sys->wind_param );
+
/* Create the FIFO for the audio data. */
p_sys->fifo = block_FifoNew();
if (p_sys->fifo == NULL)
@@ -425,6 +432,7 @@ static void *Thread( void *p_data )
36,47,62,82,107,141,184,255};
fft_state *p_state = NULL; /* internal FFT data */
+ DEFINE_WIND_CONTEXT(wind_ctx); /* internal window data */
unsigned i, j;
float p_output[FFT_BUFFER_SIZE]; /* Raw FFT Result */
@@ -471,6 +479,11 @@ static void *Thread( void *p_data )
msg_Err(p_filter,"unable to initialize FFT transform");
goto release;
}
+ if (!window_init(FFT_BUFFER_SIZE, &p_sys->wind_param, &wind_ctx))
+ {
+ msg_Err(p_filter,"unable to initialize FFT window");
+ goto release;
+ }
p_buffs = p_s16_buff;
for (i = 0 ; i < FFT_BUFFER_SIZE; i++)
{
@@ -481,6 +494,7 @@ static void *Thread( void *p_data )
if (p_buffs >= &p_s16_buff[block->i_nb_samples * p_sys->i_channels])
p_buffs = p_s16_buff;
}
+ window_scale_in_place (p_buffer1, &wind_ctx);
fft_perform (p_buffer1, p_output, p_state);
for (i = 0; i< FFT_BUFFER_SIZE; ++i)
@@ -532,6 +546,7 @@ static void *Thread( void *p_data )
}
release:
+ window_close(&wind_ctx);
fft_close(p_state);
block_Release(block);
vlc_restorecancel(canc);
More information about the vlc-commits
mailing list