Skip to content

Commit

Permalink
spectrogram: allows better visualization of low frequencies
Browse files Browse the repository at this point in the history
In some cases, Y which represents the height of a column was equal to 1
and therefore when passed through the log, the output displayed was
zero, by adding this 0.1, this allows you to see a column when y = 1
without really changing the height of each column
  • Loading branch information
M4x1M8 authored and robUx4 committed Jul 13, 2024
1 parent 94a8d15 commit c347fed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions modules/visualization/glspectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ static void Close(filter_t *);
#define HEIGHT_TEXT N_("Video height")
#define HEIGHT_LONGTEXT N_("The height of the visualization window, in pixels.")

#define LOG_OFFSET 0.1

vlc_module_begin()
set_shortname(N_("glSpectrum"))
set_description(N_("3D OpenGL spectrum visualization"))
Expand Down Expand Up @@ -545,8 +547,9 @@ static void *Thread( void *p_data )
if (p_dest[j] > y)
y = p_dest[j];
}
/* Calculate the height of the bar */
float new_height = y != 0 ? logf(y) * 0.4f : 0;
/* Calculate the height of the bar
This log_offset makes it possible to display low values */
float new_height = y != 0 ? logf( y + LOG_OFFSET ) * 0.4f : 0;
height[i] = new_height > height[i]
? new_height : height[i];
}
Expand Down
7 changes: 5 additions & 2 deletions modules/visualization/visual/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#define GRAD_ANGLE_MAX 0.5
#define GRAD_INCR 0.01

#define LOG_OFFSET 0.1

/*****************************************************************************
* dummy_Run
*****************************************************************************/
Expand Down Expand Up @@ -230,10 +232,11 @@ static int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
if ( p_dest[j] > y )
y = p_dest[j];
}
/* Calculate the height of the bar */
/* Calculate the height of the bar
This log_offset makes it possible to display low values */
if( y != 0 )
{
height[i] = log( y ) * 30;
height[i] = log( y + LOG_OFFSET ) * 30;
if( height[i] > 380 )
height[i] = 380;
}
Expand Down

0 comments on commit c347fed

Please sign in to comment.