The source code of MPlayer is like this:<br><br>// Filter data through filter<br>static af_data_t* play(struct af_instance_s* af, af_data_t* data)<br>{<br> <b> af_data_t* c = data; // Current working data<br>
float* a = c->audio; // Audio data<br> int len = c->len/4; // Number of samples in current audio block<br> int nch = c->nch; // Number of channels<br> register int i;<br>
<br> /*<br> FIXME1 add a low band pass filter to avoid suppressing<br> centered bass/drums<br> FIXME2 better calculated* attenuation factor<br> */<br><br> for(i=0;i<len;i+=nch)<br> {<br>
a[i] = (a[i] - a[i+1]) * 0.7;<br> a[i+1]=a[i];<br> }</b><br><br> return c;<br>}<br><br>// Allocate memory and set function pointers<br>static int af_open(af_instance_t* af){<br> af->control = control;<br>
af->uninit = uninit;<br> af->play = play;<br> af->mul = 1;<br> af->data = calloc(1,sizeof(af_data_t));<br><br> if(af->data == NULL)<br> return AF_ERROR;<br><br> return AF_OK;<br>
}<br><br>// Description of this filter<br>af_info_t af_info_karaoke = {<br> "Simple karaoke/voice-removal audio filter",<br> "karaoke",<br> "Reynaldo H. Verdejo Pinochet",<br> "",<br>
AF_FLAGS_NOT_REENTRANT,<br> af_open<br>};<br><br><br>According to your suggestion, I think 0.5 is more reasonable thanks.<br><br><br><div class="gmail_quote">2011/4/15 Juha Jeronen <span dir="ltr"><<a href="mailto:juha.jeronen@jyu.fi">juha.jeronen@jyu.fi</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">Hi,<br>
<br>
>> From 6e85c56990a90f84049485f03942bd8c224d2852 Mon Sep 17 00:00:00 2001<br>
>> From: yuhong <<a href="mailto:yuhong.guo@gmail.com">yuhong.guo@gmail.com</a>><br>
>> Date: Thu, 14 Apr 2011 22:56:08 +0800<br>
>> Subject: [PATCH] karaoke and sweep audio filters<br>
>> + * DoWork : Do karaoke filter<br>
>> + *****************************************************************************/<br>
>> +static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )<br>
>> +{<br>
>> + int i, i_chan;<br>
>> + int i_samples = p_in_buf->i_nb_samples/4;<br>
>> + int i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );<br>
>> + float *p_in = (float*)p_in_buf->p_buffer;<br>
>> +<br>
>> + /* filter calculation */<br>
>> + for( i = 0; i < i_samples; i+=i_channels) {<br>
>> + p_in[i] = (p_in[i] - p_in[i+1]) * 0.7;<br>
>> + p_in[i+1] = p_in[i];<br>
>> + }<br>
<br>
</div>Maybe everyone else knows this already, but mind if I ask why the<br>
multiplier is 0.7? Is it correct or should it be something else?<br>
<br>
(My intuition says 0.5 is needed to ensure that all peaks fit. Assuming<br>
signed 16-bit audio samples, if p_in[i] == 32767 and p_in[i+1] ==<br>
-32768, the difference is 65535. From this 65535*0.7 = 45874 > 32767,<br>
and the result doesn't fit into a signed 16-bit buffer.)<br>
<font color="#888888"><br>
-J<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
</div></div></blockquote></div><br>