#include <vlc_plugin.h>
#include <vlc_aout.h>
+#include <vlc_filter.h>
/*****************************************************************************
* Local prototypes
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;
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 )
*/
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 ) )
{
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;
/**
* 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 ) *
}
}
- return;
+ return p_in_buf;
}
/**
*/
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 );