[vlc-devel] karaoke filter

Juha Jeronen juha.jeronen at jyu.fi
Fri Apr 15 09:35:19 CEST 2011


Hi,

>> From 6e85c56990a90f84049485f03942bd8c224d2852 Mon Sep 17 00:00:00 2001
>> From: yuhong <yuhong.guo at gmail.com>
>> Date: Thu, 14 Apr 2011 22:56:08 +0800
>> Subject: [PATCH] karaoke and sweep audio filters
>> + * DoWork : Do karaoke filter
>> + *****************************************************************************/
>> +static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
>> +{
>> +   int i, i_chan;
>> +   int i_samples = p_in_buf->i_nb_samples/4;
>> +   int i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
>> +   float *p_in =  (float*)p_in_buf->p_buffer;
>> +
>> +   /* filter calculation */
>> +   for( i = 0; i < i_samples; i+=i_channels) {
>> +          p_in[i] = (p_in[i] - p_in[i+1]) * 0.7;
>> +          p_in[i+1] = p_in[i];
>> +   }

Maybe everyone else knows this already, but mind if I ask why the
multiplier is 0.7? Is it correct or should it be something else?

(My intuition says 0.5 is needed to ensure that all peaks fit. Assuming
signed 16-bit audio samples, if p_in[i] == 32767 and p_in[i+1] ==
-32768, the difference is 65535. From this 65535*0.7 = 45874 > 32767,
and the result doesn't fit into a signed 16-bit buffer.)

 -J




More information about the vlc-devel mailing list