[vlc-devel] [PATCH] karaoke : setting the output to mono

Sukrit Sangwan sukritsangwan at gmail.com
Wed Mar 7 00:51:10 CET 2012


diff --git a/modules/audio_filter/karaoke.c b/modules/audio_filter/karaoke.c
index 81bc276..609f365 100644
--- a/modules/audio_filter/karaoke.c
+++ b/modules/audio_filter/karaoke.c
@@ -58,6 +58,8 @@ static int Open (vlc_object_t *obj)
     }

     filter->pf_audio_filter = Process;
+    filter->fmt_out.audio.i_physical_channels = AOUT_CHAN_CENTER;
+    filter->fmt_out.audio.i_channels = 1;
     return VLC_SUCCESS;
 }

@@ -65,15 +67,15 @@ static block_t *Process (filter_t *filter, block_t
*block)
 {
     const float factor = .70710678 /* 1. / sqrtf (2) */;
     float *spl = (float *)block->p_buffer;
+    float *out = (float *)block->p_buffer;

     for (unsigned i = block->i_nb_samples; i > 0; i--)
     {
         float s = (spl[0] - spl[1]) * factor;
-
-        *(spl++) = s;
-        *(spl++) = s;
-        /* TODO: set output format to mono */
+        spl += 2 ;
+        *(out++) = s;
     }
+    block->i_buffer /= 2;
     (void) filter;
     return block;
 }


-- 
Regards
Sukrit Sangwan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120306/9be71b12/attachment.html>


More information about the vlc-devel mailing list