Commit 524254f8 authored by Scott Caudle's avatar Scott Caudle

updates spectrometer visualization. some optimization tweaks and additional features.

parent 46d8d47a
...@@ -396,11 +396,6 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -396,11 +396,6 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
} }
p_buffs = p_s16_buff; p_buffs = p_s16_buff;
//i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
//i_separ = config_GetInt( p_aout, "visual-separ" );
//i_amp = config_GetInt ( p_aout, "visual-amp" );
//i_peak = config_GetInt ( p_aout, "visual-peaks" );
/* previous 4 vars changed.. using them as `spect' variables */
i_original = config_GetInt ( p_aout, "spect-show-original" ); i_original = config_GetInt ( p_aout, "spect-show-original" );
i_nb_bands = config_GetInt ( p_aout, "spect-nbbands" ); i_nb_bands = config_GetInt ( p_aout, "spect-nbbands" );
i_separ = config_GetInt ( p_aout, "spect-separ" ); i_separ = config_GetInt ( p_aout, "spect-separ" );
...@@ -420,12 +415,10 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -420,12 +415,10 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
} }
else else
{ {
i_nb_bands = 80; if( i_nb_bands > 80 )
i_nb_bands = 80;
xscale = xscale2; xscale = xscale2;
} }
i_nb_bands *= i_sections;
/* whoops, dont malloc the following memory for all the duplicated bands..
-only the original 20 or 80 will be fine */
if( !p_effect->p_data ) if( !p_effect->p_data )
{ {
...@@ -446,13 +439,13 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -446,13 +439,13 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
peaks =(int *)p_effect->p_data; peaks =(int *)p_effect->p_data;
} }
height = (int *)malloc( i_nb_bands * sizeof(int) ); height = (int *)malloc( i_nb_bands * sizeof(int) );
if( !height) if( !height)
{ {
msg_Err(p_aout,"Out of memory"); msg_Err(p_aout,"Out of memory");
return -1; return -1;
} }
/* Convert the buffer to int16_t */ /* Convert the buffer to int16_t */
/* Pasted from float32tos16.c */ /* Pasted from float32tos16.c */
for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; ) for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
...@@ -482,6 +475,8 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -482,6 +475,8 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
for(i= 0; i< FFT_BUFFER_SIZE ; i++ ) for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8; p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
i_nb_bands *= i_sections;
for ( i = 0 ; i< i_nb_bands/i_sections ;i++) for ( i = 0 ; i< i_nb_bands/i_sections ;i++)
{ {
/* We search the maximum on one scale */ /* We search the maximum on one scale */
...@@ -660,24 +655,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -660,24 +655,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
y /= 2; y /= 2;
*(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
- p_picture->p[1].i_pitch
) = 0;/* U(R,G,B); */ ) = 0;/* U(R,G,B); */
if( 0x04 * (i_line + k ) - 0x0f > 0 ) if( 0x04 * (i_line + k ) - 0x0f > 0 )
{ {
if ( 0x04 * (i_line + k ) -0x0f < 0xff) if ( 0x04 * (i_line + k ) -0x0f < 0xff)
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = ( 0x04 * ( i_line + k ) ) -(color1-1);/* -V(R,G,B); */ ) = ( 0x04 * ( i_line + k ) ) -(color1-1);/* -V(R,G,B); */
else else
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = 255;/* V(R,G,B); */ ) = 255;/* V(R,G,B); */
} }
else else
{ {
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = color1;/* V(R,G,B); */ ) = color1;/* V(R,G,B); */
} }
} }
...@@ -705,24 +696,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -705,24 +696,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
y /= 2; y /= 2;
*(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
- p_picture->p[1].i_pitch
) = 0;/* U(R,G,B); */ ) = 0;/* U(R,G,B); */
if( 0x04 * i_line - 0x0f > 0 ) if( 0x04 * i_line - 0x0f > 0 )
{ {
if( 0x04 * i_line -0x0f < 0xff) if( 0x04 * i_line -0x0f < 0xff)
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = ( 0x04 * i_line) -(color1-1);/* -V(R,G,B); */ ) = ( 0x04 * i_line) -(color1-1);/* -V(R,G,B); */
else else
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = 255;/* V(R,G,B); */ ) = 255;/* V(R,G,B); */
} }
else else
{ {
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = color1;/* V(R,G,B); */ ) = color1;/* V(R,G,B); */
} }
} }
...@@ -755,24 +742,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, ...@@ -755,24 +742,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
y /= 2; y /= 2;
*(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
- p_picture->p[1].i_pitch
) = 0; ) = 0;
if( 0x04 * i_line - 0x0f > 0 ) if( 0x04 * i_line - 0x0f > 0 )
{ {
if ( 0x04 * i_line -0x0f < 0xff) if ( 0x04 * i_line -0x0f < 0xff)
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = ( 0x04 * i_line) -(color1-1); ) = ( 0x04 * i_line) -(color1-1);
else else
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = 255; ) = 255;
} }
else else
{ {
*(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
- p_picture->p[2].i_pitch
) = color1; ) = color1;
} }
} }
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
#define NBBANDS_TEXT N_( "Number of bands" ) #define NBBANDS_TEXT N_( "Number of bands" )
#define NBBANDS_LONGTEXT N_( \ #define NBBANDS_LONGTEXT N_( \
"Number of bands used by spectrum analyzer, should be 20 or 80." ) "Number of bands used by spectrum analyzer, should be 20 or 80." )
#define SPNBBANDS_LONGTEXT N_( \
"Number of bands used by the spectrOmeter, from 20 to 80." )
#define SEPAR_TEXT N_( "Band separator" ) #define SEPAR_TEXT N_( "Band separator" )
#define SEPAR_LONGTEXT N_( \ #define SEPAR_LONGTEXT N_( \
...@@ -125,27 +127,27 @@ vlc_module_begin(); ...@@ -125,27 +127,27 @@ vlc_module_begin();
add_bool("visual-peaks", VLC_TRUE, NULL, add_bool("visual-peaks", VLC_TRUE, NULL,
PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE ); PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE );
set_section( N_("Spectrometer") , NULL ); set_section( N_("Spectrometer") , NULL );
add_bool("spect-show-original", VLC_TRUE, NULL, add_bool("spect-show-original", VLC_FALSE, NULL,
ORIG_TEXT, ORIG_LONGTEXT, VLC_TRUE ); ORIG_TEXT, ORIG_LONGTEXT, VLC_TRUE );
add_bool("spect-show-base", VLC_TRUE, NULL, add_bool("spect-show-base", VLC_TRUE, NULL,
BASE_TEXT, BASE_LONGTEXT, VLC_TRUE ); BASE_TEXT, BASE_LONGTEXT, VLC_TRUE );
add_integer("spect-radius", 22, NULL, add_integer("spect-radius", 42, NULL,
RADIUS_TEXT, RADIUS_LONGTEXT, VLC_TRUE ); RADIUS_TEXT, RADIUS_LONGTEXT, VLC_TRUE );
add_integer("spect-sections", 2, NULL, add_integer("spect-sections", 3, NULL,
SECT_TEXT, SECT_LONGTEXT, VLC_TRUE ); SECT_TEXT, SECT_LONGTEXT, VLC_TRUE );
add_integer("spect-color", 16, NULL, add_integer("spect-color", 80, NULL,
COLOR1_TEXT, COLOR1_LONGTEXT, VLC_TRUE ); COLOR1_TEXT, COLOR1_LONGTEXT, VLC_TRUE );
add_bool("spect-show-bands", VLC_TRUE, NULL, add_bool("spect-show-bands", VLC_TRUE, NULL,
BANDS_TEXT, BANDS_LONGTEXT, VLC_TRUE ); BANDS_TEXT, BANDS_LONGTEXT, VLC_TRUE );
add_integer("spect-nbbands", 80, NULL, add_integer("spect-nbbands", 32, NULL,
NBBANDS_TEXT, NBBANDS_LONGTEXT, VLC_TRUE ); NBBANDS_TEXT, SPNBBANDS_LONGTEXT, VLC_TRUE );
add_integer("spect-separ", 1, NULL, add_integer("spect-separ", 1, NULL,
SEPAR_TEXT, SEPAR_LONGTEXT, VLC_TRUE ); SEPAR_TEXT, SEPAR_LONGTEXT, VLC_TRUE );
add_integer("spect-amp", 3, NULL, add_integer("spect-amp", 8, NULL,
AMP_TEXT, AMP_LONGTEXT, VLC_TRUE ); AMP_TEXT, AMP_LONGTEXT, VLC_TRUE );
add_bool("spect-show-peaks", VLC_TRUE, NULL, add_bool("spect-show-peaks", VLC_TRUE, NULL,
PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE ); PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE );
add_integer("spect-peak-width", 1, NULL, add_integer("spect-peak-width", 61, NULL,
PEAK_WIDTH_TEXT, PEAK_WIDTH_LONGTEXT, VLC_TRUE ); PEAK_WIDTH_TEXT, PEAK_WIDTH_LONGTEXT, VLC_TRUE );
add_integer("spect-peak-height", 1, NULL, add_integer("spect-peak-height", 1, NULL,
PEAK_HEIGHT_TEXT, PEAK_HEIGHT_LONGTEXT, VLC_TRUE ); PEAK_HEIGHT_TEXT, PEAK_HEIGHT_LONGTEXT, VLC_TRUE );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment