X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_filter%2Fchorus_flanger.c;h=efeade622393588cea595eb05e35dd21a5499953;hb=3799b698da614d7d56a4aa9d48f1494cfa33043f;hp=841131b988461ce218cc6bdfb5d5da71f8e81a6b;hpb=d2549af08b564d352ec09044b9fb3a3cb57ebc5a;p=vlc diff --git a/modules/audio_filter/chorus_flanger.c b/modules/audio_filter/chorus_flanger.c index 841131b988..efeade6223 100644 --- a/modules/audio_filter/chorus_flanger.c +++ b/modules/audio_filter/chorus_flanger.c @@ -38,6 +38,7 @@ #include #include +#include /***************************************************************************** * Local prototypes @@ -45,10 +46,9 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -static void DoWork ( aout_instance_t * , aout_filter_t *, - aout_buffer_t * , aout_buffer_t * ); +static block_t *DoWork( filter_t *, block_t * ); -struct aout_filter_sys_t +struct filter_sys_t { /* TODO: Cleanup and optimise */ int i_cumulative; @@ -75,23 +75,24 @@ struct aout_filter_sys_t vlc_module_begin () set_description( N_("Sound Delay") ) - set_shortname( N_("delay") ) + set_shortname( N_("Delay") ) + set_help( N_("Add a delay effect to the sound") ) set_category( CAT_AUDIO ) set_subcategory( SUBCAT_AUDIO_AFILTER ) add_shortcut( "delay" ) - add_float( "delay-time", 40, NULL, N_("Delay time"), + add_float( "delay-time", 40, N_("Delay time"), N_("Time in milliseconds of the average delay. Note average"), true ) - add_float( "sweep-depth", 6, NULL, N_("Sweep Depth"), + add_float( "sweep-depth", 6, N_("Sweep Depth"), N_("Time in milliseconds of the maximum sweep depth. Thus, the sweep " "range will be delay-time +/- sweep-depth."), true ) - add_float( "sweep-rate", 6, NULL, N_("Sweep Rate"), + add_float( "sweep-rate", 6, N_("Sweep Rate"), N_("Rate of change of sweep depth in milliseconds shift per second " "of play"), true ) - add_float_with_range( "feedback-gain", 0.5, -0.9, 0.9, NULL, + add_float_with_range( "feedback-gain", 0.5, -0.9, 0.9, N_("Feedback Gain"), N_("Gain on Feedback loop"), true ) - add_float_with_range( "wet-mix", 0.4, -0.999, 0.999, NULL, + add_float_with_range( "wet-mix", 0.4, -0.999, 0.999, N_("Wet mix"), N_("Level of delayed signal"), true ) - add_float_with_range( "dry-mix", 0.4, -0.999, 0.999, NULL, + add_float_with_range( "dry-mix", 0.4, -0.999, 0.999, N_("Dry Mix"), N_("Level of input signal"), true ) set_capability( "audio filter", 0 ) set_callbacks( Open, Close ) @@ -113,8 +114,8 @@ static inline float small_value() */ static int Open( vlc_object_t *p_this ) { - aout_filter_t *p_filter = (aout_filter_t*)p_this; - aout_filter_sys_t *p_sys; + filter_t *p_filter = (filter_t*)p_this; + filter_sys_t *p_sys; if ( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) ) { @@ -130,10 +131,9 @@ static int Open( vlc_object_t *p_this ) msg_Warn( p_filter, "bad input or output format" ); } - p_filter->pf_do_work = DoWork; - p_filter->b_in_place = true; + p_filter->pf_audio_filter = DoWork; - p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) ); + p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; @@ -225,31 +225,24 @@ static inline void sanitize( float * f_value ) /** * DoWork : delays and finds the value of the current frame - * @param p_aout Audio output object * @param p_filter This filter object * @param p_in_buf Input buffer - * @param p_out_buf Output buffer + * @return Output buffer */ -static void DoWork( aout_instance_t *p_aout, aout_filter_t *p_filter, - aout_buffer_t *p_in_buf, aout_buffer_t *p_out_buf ) +static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf ) { - VLC_UNUSED( p_aout ); - - struct aout_filter_sys_t *p_sys = p_filter->p_sys; + struct filter_sys_t *p_sys = p_filter->p_sys; int i_chan; - int i_samples = p_in_buf->i_nb_samples; /* Gives the number of samples */ + unsigned i_samples = p_in_buf->i_nb_samples; /* number of samples */ /* maximum number of samples to offset in buffer */ int i_maxOffset = floor( p_sys->f_sweepDepth * p_sys->i_sampleRate / 1000 ); - float *p_out = (float*)p_out_buf->p_buffer; + float *p_out = (float*)p_in_buf->p_buffer; float *p_in = (float*)p_in_buf->p_buffer; float *pf_ptr, f_diff = 0, f_frac = 0, f_temp = 0 ; - p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; - p_out_buf->i_buffer = p_in_buf->i_buffer; - /* Process each sample */ - for( int i = 0; i < i_samples ; i++ ) + for( unsigned i = 0; i < i_samples ; i++ ) { /* Use a sine function as a oscillator wave. TODO */ /* f_offset = sinf( ( p_sys->i_cumulative ) * p_sys->f_sinMultiplier ) * @@ -316,7 +309,7 @@ static void DoWork( aout_instance_t *p_aout, aout_filter_t *p_filter, } } - return; + return p_in_buf; } /** @@ -325,8 +318,8 @@ static void DoWork( aout_instance_t *p_aout, aout_filter_t *p_filter, */ static void Close( vlc_object_t *p_this ) { - aout_filter_t *p_filter = ( aout_filter_t* )p_this; - aout_filter_sys_t *p_sys = p_filter->p_sys; + filter_t *p_filter = ( filter_t* )p_this; + filter_sys_t *p_sys = p_filter->p_sys; free( p_sys->pf_delayLineStart ); free( p_sys );