spectrogram: allows better visualization of low frequencies
authorMaxime Even <maximeeven@proton.me>
Mon, 8 Jul 2024 15:51:14 +0000 (17:51 +0200)
committerSebastian Ramacher <sramacher@debian.org>
Tue, 14 Jan 2025 22:09:47 +0000 (23:09 +0100)
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

(cherry picked from commit c347fed91e76bd31387171e1ff67224c21194362)

Gbp-Pq: Name 0017-spectrogram-allows-better-visualization-of-low-frequ.patch

modules/visualization/glspectrum.c
modules/visualization/visual/effects.c

index 96ee3fe8d4f4b706de11e27982e0ac3a768bd485..832a52d0fe342979d148369f2bd8e5f68b7fde16 100644 (file)
@@ -58,6 +58,8 @@ static void Close(vlc_object_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"))
@@ -466,8 +468,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];
         }
index d5a720982b65ba964fbd99213c29e17aef2d622f..6961c546e58f5c389d8c6a07bb5e752024a9374d 100644 (file)
@@ -46,6 +46,8 @@
 #define GRAD_ANGLE_MAX 0.5
 #define GRAD_INCR 0.01
 
+#define LOG_OFFSET 0.1
+
 /*****************************************************************************
  * dummy_Run
  *****************************************************************************/
@@ -231,10 +233,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;
         }