I have fixed some issues(sustained noise of drum beats) and some TODOs and added callback.<br>I have attached the patch<br><b>>>> Inline explanations</b><br><br><br>diff --git a/modules/audio_filter/chorus_flanger.c b/modules/audio_filter/chorus_flanger.c<br>
index efeade6..5f82f23 100644<br>--- a/modules/audio_filter/chorus_flanger.c<br>+++ b/modules/audio_filter/chorus_flanger.c<br>@@ -5,6 +5,7 @@<br>  * $Id$<br>  *<br>  * Author: Srikanth Raju < srikiraju at gmail dot com ><br>
+ * Modified : Sukrit Sangwan < sukritsangwan at gmail dot com ><br>  *<br>  * This program is free software; you can redistribute it and/or modify<br>  * it under the terms of the GNU General Public License as published by<br>
@@ -43,10 +44,11 @@<br> /*****************************************************************************<br>  * Local prototypes<br>  *****************************************************************************/<br>-<br> static int  Open     ( vlc_object_t * );<br>
 static void Close    ( vlc_object_t * );<br> static block_t *DoWork( filter_t *, block_t * );<br>+static int paramCallback( vlc_object_t *, char const *, vlc_value_t ,<br>+                          vlc_value_t , void * );<br>
 <br> struct filter_sys_t<br> {<br>@@ -57,8 +59,8 @@ struct filter_sys_t<br>     float f_wetLevel, f_dryLevel;<br>     float f_sweepDepth, f_sweepRate;<br> <br>-    float f_step,f_offset;<br>-    int i_step,i_offset;<br>+    float f_offset;<br>
+    int i_step;<br>     float f_temp;<br>     float f_sinMultiplier;<br> <br>@@ -66,13 +68,15 @@ struct filter_sys_t<br>     int i_bufferLength;<br>     float * pf_delayLineStart, * pf_delayLineEnd;<br>     float * pf_write;<br>
+<br>+    /* Used if callback fails to allocate buffer, *<br>+     * in that case dont free the buffer twice    */<br>+    bool b_free_buf;<br> };<br> <br> /*****************************************************************************<br>
  * Module descriptor<br>  *****************************************************************************/<br>-<br>-<br> vlc_module_begin ()<br>     set_description( N_("Sound Delay") )<br>     set_shortname( N_("Delay") )<br>
@@ -80,7 +84,7 @@ vlc_module_begin ()<br>     set_category( CAT_AUDIO )<br>     set_subcategory( SUBCAT_AUDIO_AFILTER )<br>     add_shortcut( "delay" )<br>-    add_float( "delay-time", 40, N_("Delay time"),<br>
+    add_float( "delay-time", 20, N_("Delay time"),<br><b>>>> 20 ms avg delay is better for the effect, so default value changed</b><br>         N_("Time in milliseconds of the average delay. Note average"), true )<br>
     add_float( "sweep-depth", 6, N_("Sweep Depth"),<br>         N_("Time in milliseconds of the maximum sweep depth. Thus, the sweep "<br>@@ -138,12 +142,16 @@ static int Open( vlc_object_t *p_this )<br>
         return VLC_ENOMEM;<br> <br>     p_sys->i_channels       = aout_FormatNbChannels( &p_filter->fmt_in.audio );<br>-    p_sys->f_delayTime      = var_CreateGetFloat( p_this, "delay-time" );<br>
-    p_sys->f_sweepDepth     = var_CreateGetFloat( p_this, "sweep-depth" );<br>-    p_sys->f_sweepRate      = var_CreateGetFloat( p_this, "sweep-rate" );<br>-    p_sys->f_feedbackGain   = var_CreateGetFloat( p_this, "feedback-gain" );<br>
-    p_sys->f_dryLevel       = var_CreateGetFloat( p_this, "dry-mix" );<br>-    p_sys->f_wetLevel       = var_CreateGetFloat( p_this, "wet-mix" );<br>+<br>+#define CREATE_VAR( stor, var ) \<br>+        p_sys->stor = var_CreateGetFloat( p_filter, var ); \<br>
+        var_AddCallback( p_filter, var, paramCallback, p_sys );<br>+    CREATE_VAR( f_delayTime,    "delay-time" );<br>+    CREATE_VAR( f_sweepDepth,   "sweep-depth" );<br>+    CREATE_VAR( f_sweepRate,    "sweep-rate" );<br>
+    CREATE_VAR( f_feedbackGain, "feedback-gain" );<br>+    CREATE_VAR( f_dryLevel,     "dry-mix" );<br>+    CREATE_VAR( f_wetLevel,     "wet-mix" );<br> <br>     if( p_sys->f_delayTime < 0.0)<br>
     {<br>@@ -176,7 +184,7 @@ static int Open( vlc_object_t *p_this )<br>             p_sys->f_sweepRate, p_filter->fmt_in.audio.i_rate );<br>     if( p_sys->i_bufferLength <= 0 )<br>     {<br>-        msg_Err( p_filter, "Delay-time, Sampl rate or Channels was incorrect" );<br>
+        msg_Err( p_filter, "Delay-time, Sample rate or Channels was incorrect" );<br>         free(p_sys);<br>         return VLC_EGENERIC;<br>     }<br>@@ -187,12 +195,11 @@ static int Open( vlc_object_t *p_this )<br>
         free( p_sys );<br>         return VLC_ENOMEM;<br>     }<br>+    p_sys->b_free_buf = true;<br> <br>     p_sys->i_cumulative = 0;<br>-    p_sys->f_step = p_sys->f_sweepRate / 1000.0;<br>     p_sys->i_step = p_sys->f_sweepRate > 0 ? 1 : 0;<br>
     p_sys->f_offset = 0;<br>-    p_sys->i_offset = 0;<br><b>>>> Drop unused variables</b><br>     p_sys->f_temp = 0;<br> <br>     p_sys->pf_delayLineEnd = p_sys->pf_delayLineStart + p_sys->i_bufferLength;<br>
@@ -211,7 +218,6 @@ static int Open( vlc_object_t *p_this )<br>     return VLC_SUCCESS;<br> }<br> <br>-<br> /**<br>  * sanitize: Helper function to eliminate small amplitudes<br>  * @param f_value pointer to value to clean<br>
@@ -244,23 +250,19 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )<br>     /* Process each sample */<br>     for( unsigned i = 0; i < i_samples ; i++ )<br>     {<br>-        /* Use a sine function as a oscillator wave. TODO */<br>
-        /* f_offset = sinf( ( p_sys->i_cumulative ) * p_sys->f_sinMultiplier ) *<br>-         * (int)floor(p_sys->f_sweepDepth * p_sys->i_sampleRate / 1000);<br>-         */<br>-<br>-        /* Triangle oscillator. Step using ints, because floats give rounding */<br>
-        p_sys->i_offset+=p_sys->i_step;<br>-        p_sys->f_offset = p_sys->i_offset * p_sys->f_step;<br>+        /* Sine function as a oscillator wave to calculate sweep */<br>+        p_sys->i_cumulative += p_sys->i_step;<br>
+        p_sys->f_offset = sinf( (p_sys->i_cumulative) * p_sys->f_sinMultiplier )<br>+                * (int)floor(p_sys->f_sweepDepth * p_sys->i_sampleRate / 1000);<br>         if( abs( p_sys->i_step ) > 0 )<br>
         {<br>-            if( p_sys->i_offset >=  floor( p_sys->f_sweepDepth *<br>+            if( p_sys->i_cumulative >=  floor( p_sys->f_sweepDepth *<br>                         p_sys->i_sampleRate / p_sys->f_sweepRate ))<br>
             {<br>                 p_sys->f_offset = i_maxOffset;<br>                 p_sys->i_step = -1 * ( p_sys->i_step );<br>             }<br>-            if( p_sys->i_offset <= floor( -1 * p_sys->f_sweepDepth *<br>
+            if( p_sys->i_cumulative <= floor( -1 * p_sys->f_sweepDepth *<br>                         p_sys->i_sampleRate / p_sys->f_sweepRate ) )<br>             {<br>                 p_sys->f_offset = -i_maxOffset;<br>
@@ -269,8 +271,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )<br>         }<br>         /* Calculate position in delay */<br>         int offset = floor( p_sys->f_offset );<br>-        pf_ptr = p_sys->pf_write + i_maxOffset * p_sys->i_channels +<br>
-            offset * p_sys->i_channels;<br>+        pf_ptr = p_sys->pf_write + ( i_maxOffset - offset ) * p_sys->i_channels;<br><b>>>> although i_maxOffset +/- offset produce same effect, i changed to "-" so that it seems what it really is <br>
>>> (for more delay the pf_ptr should point more backwards in the buffer)<br>>>> +/- produce same effect because its value oscillates between +max and -max</b><br> <br>         /* Handle Overflow */<br>         if( pf_ptr < p_sys->pf_delayLineStart )<br>
@@ -285,15 +286,18 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )<br>         f_frac = ( p_sys->f_offset - (int)p_sys->f_offset );<br>         for( i_chan = 0; i_chan < p_sys->i_channels; i_chan++ )<br>
         {<br>-            f_diff =  *( pf_ptr + p_sys->i_channels + i_chan )<br>-                        - *( pf_ptr + i_chan );<br>-            f_temp = ( *( pf_ptr + i_chan ) );//+ f_diff * f_frac);<br>-            /*Linear Interpolation. FIXME. This creates LOTS of noise */<br>
<b>>>> i changed pf_ptr + i_channels to pf_ptr - i_channels because to access previous sample you must point backwards</b><br>+            if( pf_ptr <= p_sys->pf_delayLineStart + p_sys->i_channels )<br>
+                f_diff = *(p_sys->pf_delayLineEnd + i_chan) - *(pf_ptr + i_chan);<br>+            else<br>+                f_diff = *( pf_ptr - p_sys->i_channels + i_chan )<br>+                            - *( pf_ptr + i_chan );<br>
<b>>>> although it was written to fix linear interpolation, i have still used it because it wasn't the cause of noise.</b><br>+            /* Linear Interpolation. */<br>+            f_temp = *( pf_ptr + i_chan ) + f_diff * f_frac;<br>
             sanitize(&f_temp);<br>+            *( p_sys->pf_write + i_chan ) = p_in[i_chan] +<br>+                p_sys->f_feedbackGain * *(pf_ptr + i_chan);<br>             p_out[i_chan] = p_sys->f_dryLevel * p_in[i_chan] +<br>
                 p_sys->f_wetLevel * f_temp;<br><b>>>> The real cause of noise. copying the current sample after modifying it. i have copied it first and then modified</b><br>-            *( p_sys->pf_write + i_chan ) = p_in[i_chan] +<br>
-                p_sys->f_feedbackGain * f_temp;<br>         }<br>         if( p_sys->pf_write == p_sys->pf_delayLineStart )<br>             for( i_chan = 0; i_chan < p_sys->i_channels; i_chan++ )<br>@@ -320,7 +324,83 @@ static void Close( vlc_object_t *p_this )<br>
 {<br>     filter_t *p_filter = ( filter_t* )p_this;<br>     filter_sys_t *p_sys = p_filter->p_sys;<br>+#define DEL_VAR( var ) \<br>+        var_DelCallback( p_filter, var, paramCallback, p_sys ); \<br>+        var_Destroy( p_filter, var );<br>
+    DEL_VAR( "delay-time" );<br>+    DEL_VAR( "sweep-depth" );<br>+    DEL_VAR( "sweep-rate" );<br>+    DEL_VAR( "feedback-gain" );<br>+    DEL_VAR( "wet-mix" );<br>+    DEL_VAR( "dry-mix" );<br>
+<br>+    if( p_sys->b_free_buf == true )<br>+        free( p_sys->pf_delayLineStart );<br>+    free( p_sys );<br>+}<br>+<br>+/******************************************************************************<br>+ * Callback to update parameters on the fly<br>
+ ******************************************************************************/<br>+static int paramCallback( vlc_object_t *p_this, char const *psz_var,<br>+                          vlc_value_t oldval, vlc_value_t newval, void *p_data )<br>
+{<br>+    VLC_UNUSED(oldval);<br>+    filter_t *p_filter = (filter_t *)p_this;<br>+    filter_sys_t *p_sys = (filter_sys_t *) p_data;<br>+<br>+    if( !strcmp( psz_var, "delay-time" ) )<br>+    {<br>+        /* if invalid value pretend everything is OK without updating value */<br>
+        if( newval.f_float < 0 )<br>+            return VLC_SUCCESS;<br>+        p_sys->f_delayTime = newval.f_float;<br>+        goto allocate_new_buffer;<br>+    }<br>+    else if( !strcmp( psz_var, "sweep-depth" ) )<br>
+    {<br>+        if( newval.f_float < 0 || newval.f_float > p_sys->f_delayTime)<br>+            return VLC_SUCCESS;<br>+        p_sys->f_sweepDepth = newval.f_float;<br>+        goto allocate_new_buffer;<br>
+    }<br>+    else if( !strcmp( psz_var, "sweep-rate" ) )<br>+    {<br>+        if( newval.f_float > p_sys->f_sweepDepth )<br>+            return VLC_SUCCESS;<br>+        p_sys->f_sweepRate = newval.f_float;<br>
+        /* Calculate new f_sinMultiplier */<br>+        if( p_sys->f_sweepDepth < small_value() ||<br>+                p_filter->fmt_in.audio.i_rate < small_value() ) {<br>+            p_sys->f_sinMultiplier = 0.0;<br>
+        }<br>+        else {<br>+            p_sys->f_sinMultiplier = 11 * p_sys->f_sweepRate /<br>+                ( 7 * p_sys->f_sweepDepth * p_filter->fmt_in.audio.i_rate ) ;<br>+        }<br>+    }<br>+    else if( !strcmp( psz_var, "feedback-gain" ) )<br>
+        p_sys->f_feedbackGain = newval.f_float;<br>+    else if( !strcmp( psz_var, "wet-mix" ) )<br>+        p_sys->f_wetLevel = newval.f_float;<br>+    else if( !strcmp( psz_var, "dry-mix" ) )<br>
+        p_sys->f_dryLevel = newval.f_float;<br>+<br>+    return VLC_SUCCESS;<br>+<br>+allocate_new_buffer:<br>+    p_sys->i_bufferLength = p_sys->i_channels * ( (int)( ( p_sys->f_delayTime<br>+                + p_sys->f_sweepDepth ) * p_filter->fmt_in.audio.i_rate/1000 ) + 1 );<br>
 <br>     free( p_sys->pf_delayLineStart );<br>-    free( p_sys );<br>+    p_sys->pf_delayLineStart = calloc( p_sys->i_bufferLength, sizeof( float ) );<br>+    if( !p_sys->pf_delayLineStart )<br>+    {<br>+        p_sys->b_free_buf = false;<br>
+        msg_Dbg( p_filter, "Couldnt allocate buffer for delay" );<br>+        Close( p_this );<br>+    }<br>+    p_sys->pf_delayLineEnd = p_sys->pf_delayLineStart + p_sys->i_bufferLength;<br>+<br>+    return VLC_SUCCESS;<br>
 }<br><br><b>>>> I have also added a small patch for stereo_widen.c<br>>>> i had earlier provided a long description which doesnt fit in the preferences box<br>>>> (box becomes very large to accomodate full description in a single line)<br>
>>> i changed a description into help and a added a small description</b><br>diff --git a/modules/audio_filter/stereo_widen.c b/modules/audio_filter/stereo_widen.c<br>index 5aa97f2..974bd45 100644<br>--- a/modules/audio_filter/stereo_widen.c<br>
+++ b/modules/audio_filter/stereo_widen.c<br>@@ -52,7 +52,7 @@ struct filter_sys_t<br>                          * allocate buffer, then dont free it twice */<br> };<br> <br>-#define DESCRIPTION N_("This filter enhances stereo effect by \<br>
+#define HELP_TEXT N_("This filter enhances stereo effect by \<br>             suppressing mono,i.e. signal common to both channels, \<br>             and by delaying the signal of left into right and vice versa \<br>
             thereby widening stereo effect")<br>@@ -75,7 +75,8 @@ struct filter_sys_t<br>  *****************************************************************************/<br> vlc_module_begin ()<br>     set_shortname( N_("stereo_widen") )<br>
-    set_description( DESCRIPTION )<br>+    set_description( N_("Stereo Enhancer") )<br>+    set_help( HELP_TEXT )<br>     set_category( CAT_AUDIO )<br>     set_subcategory( SUBCAT_AUDIO_AFILTER )<br>     set_capability( "audio filter", 0 )<br>
<br clear="all"><br>-- <br><div>Regards<br>Sukrit Sangwan</div>
<br>