Merge branch 'master-group-audio-filters' into 'master'

add support for avaudio filters

See merge request videolan/vlc!2414
This commit is contained in:
Raj S 2024-04-28 07:10:58 +00:00
commit c12a70e5b2
35 changed files with 6976 additions and 2 deletions

View File

@ -2769,6 +2769,31 @@ AS_IF([test "${enable_avformat}" != "no"], [
])
AM_CONDITIONAL([HAVE_AVFORMAT], [test "${enable_avformat}" != "no"])
dnl
dnl avfilter audio_filter plugin
dnl
AC_ARG_ENABLE([avfilter],
AS_HELP_STRING([--enable-avfilter], [libavfilter containers (default auto)]),, [
enable_avfilter="${have_avcodec}"
])
have_avfilter="no"
AS_IF([test "${enable_avfilter}" != "no"], [
PKG_CHECK_MODULES(AVFILTER,[libavfilter >= 7.57.100 libavcodec libavutil], [
have_avfilter="yes"
VLC_SAVE_FLAGS
CPPFLAGS="${CPPFLAGS} ${AVFILTER_CFLAGS}"
CFLAGS="${CFLAGS} ${AVFILTER_CFLAGS}"
AC_CHECK_HEADERS([libavfilter/avfilter.h])
AS_IF([test "$enable_merge_ffmpeg" = "no"], [
have_avfilter="no"
])
VLC_RESTORE_FLAGS
],[
])
])
AM_CONDITIONAL([HAVE_AVFILTER], [test "${have_avfilter}" != "no"])
dnl
dnl swscale image scaling and conversion plugin
dnl

View File

@ -23,7 +23,6 @@ FFMPEGCONF = \
--disable-debug \
--disable-avdevice \
--disable-devices \
--disable-avfilter \
--disable-filters \
--disable-protocol=concat \
--disable-bsfs \
@ -200,7 +199,7 @@ endif
# Build
PKGS += ffmpeg
ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale $(MAYBE_POSTPROC)"),)
ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libavfilter libswscale $(MAYBE_POSTPROC)"),)
PKGS_FOUND += ffmpeg
endif

View File

@ -1,5 +1,6 @@
audio_filterdir = $(pluginsdir)/audio_filter
libaudiobargraph_a_plugin_la_SOURCES = audio_filter/audiobargraph_a.c
libaudiobargraph_a_plugin_la_LIBADD = $(LIBM)
libchorus_flanger_plugin_la_SOURCES = audio_filter/chorus_flanger.c
@ -54,6 +55,163 @@ audio_filter_LTLIBRARIES = \
libcenter_plugin.la \
libstereopan_plugin.la
libavaudio_common_la_SOURCES = audio_filter/avaudio/avaudio.c audio_filter/avaudio/avaudio.h
libavaudio_common_la_CFLAGS = $(LIBM) $(AVFILTER_CFLAGS)
libavaudio_common_la_LIBADD = $(LIBM) $(AVFILTER_LIBS)
libavaudio_common_la_LDFLAGS = -static
noinst_LTLIBRARIES += libavaudio_common.la
libacrusher_plugin_la_SOURCES = audio_filter/avaudio/acrusher.c
libacrusher_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libacrusher_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libacrusher_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libadelay_plugin_la_SOURCES = audio_filter/avaudio/adelay.c
libadelay_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libadelay_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libadelay_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libaecho_plugin_la_SOURCES = audio_filter/avaudio/aecho.c
libaecho_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libaecho_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libaecho_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libaemphasis_plugin_la_SOURCES = audio_filter/avaudio/aemphasis.c
libaemphasis_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libaemphasis_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libaemphasis_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libagate_plugin_la_SOURCES = audio_filter/avaudio/agate.c
libagate_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libagate_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libagate_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libaiir_plugin_la_SOURCES = audio_filter/avaudio/aiir.c
libaiir_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libaiir_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libaiir_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libalimiter_plugin_la_SOURCES = audio_filter/avaudio/alimiter.c
libalimiter_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libalimiter_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libalimiter_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libanull_plugin_la_SOURCES = audio_filter/avaudio/anull.c
libanull_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libanull_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libanull_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libaphaser_plugin_la_SOURCES = audio_filter/avaudio/aphaser.c
libaphaser_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libaphaser_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libaphaser_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libapulsator_plugin_la_SOURCES = audio_filter/avaudio/apulsator.c
libapulsator_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libapulsator_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libapulsator_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libasoftclip_plugin_la_SOURCES = audio_filter/avaudio/asoftclip.c
libasoftclip_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libasoftclip_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libasoftclip_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libastereowiden_plugin_la_SOURCES = audio_filter/avaudio/astereowiden.c
libastereowiden_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libastereowiden_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libastereowiden_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libbandpass_plugin_la_SOURCES = audio_filter/avaudio/bandpass.c
libbandpass_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libbandpass_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libbandpass_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libbandreject_plugin_la_SOURCES = audio_filter/avaudio/bandreject.c
libbandreject_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libbandreject_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libbandreject_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libbiquad_plugin_la_SOURCES = audio_filter/avaudio/biquad.c
libbiquad_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libbiquad_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libbiquad_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libchorus_plugin_la_SOURCES = audio_filter/avaudio/chorus.c
libchorus_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libchorus_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libchorus_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libcompensationdelay_plugin_la_SOURCES = audio_filter/avaudio/compensationdelay.c
libcompensationdelay_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libcompensationdelay_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libcompensationdelay_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libcrossfeed_plugin_la_SOURCES = audio_filter/avaudio/crossfeed.c
libcrossfeed_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libcrossfeed_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libcrossfeed_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libcrystalizer_plugin_la_SOURCES = audio_filter/avaudio/crystalizer.c
libcrystalizer_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libcrystalizer_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libcrystalizer_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libdeesser_plugin_la_SOURCES = audio_filter/avaudio/deesser.c
libdeesser_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libdeesser_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libdeesser_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libextrastereo_plugin_la_SOURCES = audio_filter/avaudio/extrastereo.c
libextrastereo_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libextrastereo_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libextrastereo_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libflanger_plugin_la_SOURCES = audio_filter/avaudio/flanger.c
libflanger_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libflanger_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libflanger_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libhaas_plugin_la_SOURCES = audio_filter/avaudio/haas.c
libhaas_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libhaas_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libhaas_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libhighpass_plugin_la_SOURCES = audio_filter/avaudio/highpass.c
libhighpass_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libhighpass_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libhighpass_plugin_la_LDFLAGS = $(AM_LDFLAGS)
liblowpass_plugin_la_SOURCES = audio_filter/avaudio/lowpass.c
liblowpass_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
liblowpass_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
liblowpass_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libmcompand_plugin_la_SOURCES = audio_filter/avaudio/mcompand.c
libmcompand_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libmcompand_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libmcompand_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libtreble_plugin_la_SOURCES = audio_filter/avaudio/treble.c
libtreble_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libtreble_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libtreble_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libtremolo_plugin_la_SOURCES = audio_filter/avaudio/tremolo.c
libtremolo_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libtremolo_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libtremolo_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libvibrato_plugin_la_SOURCES = audio_filter/avaudio/vibrato.c
libvibrato_plugin_la_CFLAGS = $(AVFILTER_CFLAGS) $(AM_CFLAGS)
libvibrato_plugin_la_LIBADD = $(AVFILTER_LIBS) $(LIBM) libavaudio_common.la
libvibrato_plugin_la_LDFLAGS = $(AM_LDFLAGS)
audio_filter_LTLIBRARIES += \
libacrusher_plugin.la \
libadelay_plugin.la \
libaecho_plugin.la \
libaemphasis_plugin.la \
libagate_plugin.la \
libaiir_plugin.la \
libalimiter_plugin.la \
libanull_plugin.la \
libaphaser_plugin.la \
libapulsator_plugin.la \
libasoftclip_plugin.la \
libastereowiden_plugin.la \
libbandpass_plugin.la \
libbandreject_plugin.la \
libbiquad_plugin.la \
libchorus_plugin.la \
libcompensationdelay_plugin.la \
libcrossfeed_plugin.la \
libcrystalizer_plugin.la \
libdeesser_plugin.la \
libextrastereo_plugin.la \
libflanger_plugin.la \
libhaas_plugin.la \
libhighpass_plugin.la \
liblowpass_plugin.la \
libmcompand_plugin.la \
libtreble_plugin.la \
libtremolo_plugin.la \
libvibrato_plugin.la
# Channel mixers
libdolby_surround_decoder_plugin_la_SOURCES = \
audio_filter/channel_mixer/dolby.c

View File

@ -0,0 +1,245 @@
/*****************************************************************************
* acrusher.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float level_in;
float level_out;
float bits;
float mix;
float dc;
float aa;
float samples;
av_filter avf;
}avfilter_sys_t;
static int Open_acrusher( vlc_object_t *p_this );
static void Close_acrusher( filter_t *p_filter );
static char* string_generate_acrusher(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "acrusher=%f:%f:"
"bits=%f:mix=%f:dc=%f:aa=%f:samples=%f",
p_sys->level_in, p_sys->level_out, p_sys->bits,
p_sys->mix, p_sys->dc, p_sys->aa, p_sys->samples);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define ACRUSHER_LEVEL_IN_TEXT N_( "level_in" )
#define ACRUSHER_LEVEL_IN_LONGTEXT N_( "Set input level. Default is 1." \
" Range is [0.015625 - 64]" )
#define ACRUSHER_LEVEL_OUT_TEXT N_( "level_out" )
#define ACRUSHER_LEVEL_OUT_LONGTEXT N_( "Set output level. Default is 1." \
" Range is [0.015625 - 64]" )
#define ACRUSHER_BITS_TEXT N_( "bits" )
#define ACRUSHER_BITS_LONGTEXT N_( "Set bit reduction. Default is 8." \
" Range is [1 - 64]" )
#define ACRUSHER_MIX_TEXT N_( "mix" )
#define ACRUSHER_MIX_LONGTEXT N_( "Set mixing amount. Default is 0.5." \
" Range is [0 - 1]")
#define ACRUSHER_DC_TEXT N_( "dc" )
#define ACRUSHER_DC_LONGTEXT N_( "Set DC offeset. Default is 1." \
" Range is [0.25 - 4]")
#define ACRUSHER_AA_TEXT N_( "anti-aliasing " )
#define ACRUSHER_AA_LONGTEXT N_( "Set anti-aliasing. Default is 0.5." \
" Range is [0 - 1]" )
#define ACRUSHER_SAMPLES_TEXT N_( "sample reduction" )
#define ACRUSHER_SAMPLES_LONGTEXT N_( "Set sample reduction. Default is 1." \
" Range is [1 - 250]" )
vlc_module_begin()
set_shortname( N_("Acrusher") )
set_description( N_("Reduce audio bit resolution.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "acrusher-level_in", 1, 0.015625, 32,
ACRUSHER_LEVEL_IN_TEXT, ACRUSHER_LEVEL_IN_LONGTEXT )
add_float_with_range( "acrusher-level_out", 1, 0.015625, 64,
ACRUSHER_LEVEL_OUT_TEXT, ACRUSHER_LEVEL_OUT_LONGTEXT )
add_float_with_range( "acrusher-bits", 8, 1, 64,
ACRUSHER_BITS_TEXT, ACRUSHER_BITS_LONGTEXT )
add_float_with_range( "acrusher-mix", 0.5, 0, 1,
ACRUSHER_MIX_TEXT, ACRUSHER_MIX_LONGTEXT )
add_float_with_range( "acrusher-dc", 1, 0.25, 4,
ACRUSHER_DC_TEXT, ACRUSHER_DC_LONGTEXT )
add_float_with_range( "acrusher-aa", 0.5, 0, 1,
ACRUSHER_AA_TEXT, ACRUSHER_AA_LONGTEXT )
add_float_with_range( "acrusher-samples", 1, 1, 250,
ACRUSHER_SAMPLES_TEXT, ACRUSHER_SAMPLES_LONGTEXT )
add_shortcut("acrusher")
set_callback( Open_acrusher )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_acrusher( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_acrusher( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "acrusher-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-level_out" ) )
p_sys->level_out = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-bits" ) )
p_sys->bits = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-mix" ) )
p_sys->mix = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-dc" ) )
p_sys->dc = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-aa" ) )
p_sys->aa = newval.f_float;
if( !strcmp( psz_cmd, "acrusher-samples" ) )
p_sys->samples = newval.f_float;
if(string_generate_acrusher(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_acrusher( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->level_in = var_CreateGetFloat(p_aout,"acrusher-level_in");
p_sys->level_out = var_CreateGetFloat(p_aout,"acrusher-level_out");
p_sys->bits = var_CreateGetFloat(p_aout,"acrusher-bits");
p_sys->mix = var_CreateGetFloat(p_aout,"acrusher-mix");
p_sys->dc = var_CreateGetFloat(p_aout,"acrusher-dc");
p_sys->aa = var_CreateGetFloat(p_aout,"acrusher-aa");
p_sys->samples = var_CreateGetFloat(p_aout,"acrusher-samples");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "acrusher-level_in", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-level_out", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-bits", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-mix", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-dc", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-aa", paramCallback_acrusher, p_sys );
var_AddCallback( p_aout, "acrusher-samples", paramCallback_acrusher, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_acrusher(p_sys), p_filter, &p_sys->avf.avfilter) <0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"acrusher initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_acrusher =
{ .filter_audio = Process_acrusher, .close = Close_acrusher };
p_filter->ops = &filter_ops_acrusher;
return VLC_SUCCESS;
}
static void Close_acrusher( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,135 @@
/*****************************************************************************
* adelay.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_adelay( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define ADELAY_DELAYS_TEXT N_( "delays" )
#define ADELAY_DELAYS_LONGTEXT N_( "Set list of delays in milliseconds for each channel" \
" separated by '|'. Unused delays will be silently ignored." \
" If number of given delays is smaller than number of channels all" \
" remaining channels will not be delayed." )
vlc_module_begin()
set_shortname( N_("Adelay") )
set_description( N_("Delay one or more audio channels.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_string( "adelay-delays", "1000", ADELAY_DELAYS_TEXT,
ADELAY_DELAYS_LONGTEXT )
add_shortcut( "adelay" )
set_callback( Open_adelay )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_adelay( vlc_object_t *p_this )
{
struct vlc_memstream ms;
char *delay;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
delay = var_CreateGetString(p_filter,"adelay-delays");
/** Configure filter parameters (filters_descr) **/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "adelay=");
/* Checking delay Bounds */
if (delay != NULL)
{
char *delay_all = check_Bounds(p_filter,delay,0.000001 ,50000, 0);
if(!delay_all)
vlc_memstream_printf(&ms, "0");
else
vlc_memstream_printf(&ms, "%s", delay_all);
free(delay_all);
}
else
{
vlc_memstream_printf(&ms, "0");
msg_Warn(p_filter, "delay parameter not set. Set to default(0).");
}
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter, p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"adelay initialised: %s",ms.ptr);
free(ms.ptr);
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,179 @@
/*****************************************************************************
* aecho.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_aecho( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define AECHO_IN_GAIN_TEXT N_( "in_gain" )
#define AECHO_IN_GAIN_LONGTEXT N_( "Set the in_gain." )
#define AECHO_OUT_GAIN_TEXT N_( "out_gain" )
#define AECHO_OUT_GAIN_LONGTEXT N_( "Set the out_gain (reflected)." )
#define AECHO_DELAY_TEXT N_( "delays" )
#define AECHO_DELAY_LONGTEXT N_( "Set list of time intervals in " \
"milliseconds between original signal and " \
"reflections separated by '|'. Allowed " \
"range for each delay is (0 - 90000.0]" )
#define AECHO_DECAY_TEXT N_( "decays" )
#define AECHO_DECAY_LONGTEXT N_( "Set list of loudness of reflected " \
"signals separated by '|'. Allowed range for " \
"each decay is (0 - 1.0]. Default is 0.5." )
vlc_module_begin()
set_shortname( N_("Aecho") )
set_description( N_("Echo effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "aecho-in_gain", 0.6, 0.0, 1.0,
AECHO_IN_GAIN_TEXT, AECHO_IN_GAIN_LONGTEXT )
add_float_with_range( "aecho-out_gain", 0.3, 0.0, 1.0,
AECHO_OUT_GAIN_TEXT, AECHO_OUT_GAIN_LONGTEXT )
add_string( "aecho-delay", "1000", AECHO_DELAY_TEXT,
AECHO_DELAY_LONGTEXT )
add_string( "aecho-decay", "0.5", AECHO_DECAY_TEXT,
AECHO_DECAY_LONGTEXT )
add_shortcut("aecho")
set_callback( Open_aecho )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_aecho( vlc_object_t *p_this )
{
struct vlc_memstream ms;
float in_gain;
float out_gain;
char *delay;
char *decay;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
in_gain = var_CreateGetFloat(p_filter,"aecho-in_gain");
out_gain = var_CreateGetFloat(p_filter,"aecho-out_gain");
delay = var_CreateGetString(p_filter,"aecho-delay");
decay = var_CreateGetString(p_filter,"aecho-decay");
/** Configure filter parameters (filter_desc)**/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "aecho=%f:%f:",in_gain, out_gain);
/* Checking delay Bounds */
if (delay != NULL)
{
char *delay_all = check_Bounds(p_filter, delay, 0, 90000, 1000);
if(!delay_all)
vlc_memstream_printf(&ms, "1000:");
else
vlc_memstream_printf(&ms, "%s:", delay_all);
free(delay_all);
}
else
{
vlc_memstream_printf(&ms, "1000:");
msg_Warn(p_filter, "delay parameter not set. Set to default(1000).");
}
/* Checking decay Bounds */
if (decay != NULL)
{
char *decay_all = check_Bounds(p_filter, decay, 0, 1, 0.5);
if(!decay_all)
vlc_memstream_printf(&ms, "0.5");
else
vlc_memstream_printf(&ms, "%s", decay_all);
free(decay_all);
}
else
{
vlc_memstream_printf(&ms, "0.5");
msg_Warn(p_filter, "decay parameter not set. Set to default(0.5).");
}
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter, p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"aecho initialised: %s",ms.ptr);
free( ms.ptr );
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,217 @@
/*****************************************************************************
* aemphasis.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float level_in;
float level_out;
char* mode;
char* type;
av_filter avf;
}avfilter_sys_t;
static int Open_aemphasis( vlc_object_t *p_this );
static void Close_aemphasis( filter_t *p_filter );
static char* string_generate_aemphasis(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "aemphasis=%f:%f:%s:%s", p_sys->level_in,
p_sys->level_out, p_sys->mode, p_sys->type);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define AEMPHASIS_LEVEL_IN_TEXT N_( "level_in" )
#define AEMPHASIS_LEVEL_IN_LONGTEXT N_( "Set input gain. By default it is 1. Range is [0 - 64]." )
#define AEMPHASIS_LEVEL_OUT_TEXT N_( "level_out" )
#define AEMPHASIS_LEVEL_OUT_LONGTEXT N_( "Set output gain. By default it is 1. Range is [0 - 64]." )
#define AEMPHASIS_MODE_TEXT N_( "mode" )
#define AEMPHASIS_MODE_LONGTEXT N_( "Set filter mode. For restoring material use 'reproduction'" \
" mode, otherwise use 'production' mode. Default is 'reproduction' mode." )
#define AEMPHASIS_TYPE_TEXT N_( "type" )
#define AEMPHASIS_TYPE_LONGTEXT N_( "Set filter type. Selects medium." )
vlc_module_begin()
set_section( N_("aemphasis"), NULL )
set_shortname( N_("Aemphasis") )
set_description( N_("Audio emphasis filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "aemphasis-level_in", 1, 0.0, 64,
AEMPHASIS_LEVEL_IN_TEXT, AEMPHASIS_LEVEL_IN_LONGTEXT )
add_float_with_range( "aemphasis-level_out", 1, 0.0, 64,
AEMPHASIS_LEVEL_OUT_TEXT, AEMPHASIS_LEVEL_OUT_LONGTEXT )
add_string( "aemphasis-mode", "reproduction", AEMPHASIS_MODE_TEXT,
AEMPHASIS_MODE_LONGTEXT )
change_string_list( aemphasis_mode_list, aemphasis_mode_list_text )
add_string( "aemphasis-type", "cd", AEMPHASIS_TYPE_TEXT,
AEMPHASIS_TYPE_LONGTEXT )
change_string_list( aemphasis_type_list, aemphasis_type_list_text )
add_shortcut( "aemphasis" )
set_callback( Open_aemphasis )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_aemphasis( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_aemphasis( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "aemphasis-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "aemphasis-level_out" ) )
p_sys->level_out = newval.f_float;
if( !strcmp( psz_cmd, "aemphasis-mode" ) )
{
free(p_sys->mode);
p_sys->mode = strdup(newval.psz_string);
if(p_sys->mode == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "aemphasis-type" ) )
{
free(p_sys->type);
p_sys->type = strdup(newval.psz_string);
if(p_sys->type == NULL)
return VLC_EGENERIC;
}
if(string_generate_aemphasis(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_aemphasis( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->level_in = var_CreateGetFloat(p_aout,"aemphasis-level_in");
p_sys->level_out = var_CreateGetFloat(p_aout,"aemphasis-level_out");
p_sys->mode = var_CreateGetString(p_aout,"aemphasis-mode");
p_sys->type = var_CreateGetString(p_aout,"aemphasis-type");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "aemphasis-level_in", paramCallback_aemphasis, p_sys );
var_AddCallback( p_aout, "aemphasis-level_out", paramCallback_aemphasis, p_sys );
var_AddCallback( p_aout, "aemphasis-mode", paramCallback_aemphasis, p_sys );
var_AddCallback( p_aout, "aemphasis-type", paramCallback_aemphasis, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_aemphasis(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"aemphasis initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_aemphasis =
{ .filter_audio = Process_aemphasis, .close = Close_aemphasis };
p_filter->ops = &filter_ops_aemphasis;
return VLC_SUCCESS;
}
static void Close_aemphasis( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,300 @@
/*****************************************************************************
* agate.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float level_in;
float range;
float threshold;
float ratio;
float attack;
float release;
float makeup;
float knee;
char* detection;
char* link;
av_filter avf;
}avfilter_sys_t;
static int Open_agate( vlc_object_t *p_this );
static void Close_agate( filter_t *p_filter );
static char* string_generate_agate(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "agate=%f:range=%f:threshold=%f:"
"ratio=%f:attack=%f:release=%f:makeup=%f:knee=%f:detection=%s:link=%s",
p_sys->level_in, p_sys->range, p_sys->threshold, p_sys->ratio,
p_sys->attack, p_sys->release, p_sys->makeup, p_sys->knee, p_sys->detection,
p_sys->link);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define AGATE_LEVEL_IN_TEXT N_( "level_in" )
#define AGATE_LEVEL_IN_LONGTEXT N_( "Set input level before filtering. Default is 1." \
" Allowed range is from 0.015625 to 64." )
#define AGATE_RANGE_TEXT N_( "range" )
#define AGATE_RANGE_LONGTEXT N_( "Set the level of gain reduction when the signal" \
" is below the threshold. Default is 0.06125. Allowed range is" \
" from 0 to 1. Setting this to 0 disables reduction and then" \
" filter behaves like expander." )
#define AGATE_THRESHOLD_TEXT N_( "threshold" )
#define AGATE_THRESHOLD_LONGTEXT N_( "If a signal rises above this level the gain" \
" reduction is released. Default is 0.125. Allowed range is" \
" between 0 to 1." )
#define AGATE_RATIO_TEXT N_( "ratio" )
#define AGATE_RATIO_LONGTEXT N_( "Set a ratio by which the signal is reduced." \
" Default is 2. Allowed range is from 1 to 9000." )
#define AGATE_ATTACK_TEXT N_( "attack" )
#define AGATE_ATTACK_LONGTEXT N_( "Amount of milliseconds the signal has to rise" \
" above the threshold before gain reduction stops. Default is" \
" 20 milliseconds. Allowed range is from 0.01 to 9000." )
#define AGATE_RELEASE_TEXT N_( "release" )
#define AGATE_RELEASE_LONGTEXT N_( "Amount of milliseconds the signal has to fall" \
" below the threshold before the reduction is increased again." \
" Default is 250 milliseconds. Allowed range is from 0.01 to 9000." )
#define AGATE_MAKEUP_TEXT N_( "makeup" )
#define AGATE_MAKEUP_LONGTEXT N_( "Set amount of amplification of signal after" \
" processing. Default is 1. Allowed range is from 1 to 64." )
#define AGATE_KNEE_TEXT N_( "knee" )
#define AGATE_KNEE_LONGTEXT N_( "Curve the sharp knee around the threshold to enter" \
" gain reduction more softly. Default is 2.82. " \
" Allowed range is from 1 to 8." )
#define AGATE_DETECTION_TEXT N_( "detection" )
#define AGATE_DETECTION_LONGTEXT N_( "Choose if exact signal should be taken for" \
" detection or an RMS like one. Default is rms. Can be peak or rms." )
#define AGATE_LINK_TEXT N_( "link" )
#define AGATE_LINK_LONGTEXT N_( "Choose if the average level between all channels or the" \
" louder channel affects the reduction. Default is average." \
" Can be average or maximum." )
vlc_module_begin()
set_shortname( N_("Agate") )
set_description( N_("Gating") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "agate-level_in", 1, 0.015625, 48.0,
AGATE_LEVEL_IN_TEXT, AGATE_LEVEL_IN_LONGTEXT )
add_float_with_range( "agate-range", 0.06125, 0.0, 1.0,
AGATE_RANGE_TEXT, AGATE_RANGE_LONGTEXT )
add_float_with_range( "agate-threshold", 0.125, 0.0, 1.0,
AGATE_THRESHOLD_TEXT, AGATE_THRESHOLD_LONGTEXT )
add_float_with_range( "agate-ratio", 2.0, 1.0, 9000.0,
AGATE_RATIO_TEXT, AGATE_RATIO_LONGTEXT )
add_float_with_range( "agate-attack", 20.0, 0.01, 9000.0,
AGATE_ATTACK_TEXT, AGATE_ATTACK_LONGTEXT )
add_float_with_range( "agate-release", 250.0, 0.01, 9000.0,
AGATE_RELEASE_TEXT, AGATE_RELEASE_LONGTEXT )
add_float_with_range( "agate-makeup", 1.0, 1.0, 64.0,
AGATE_MAKEUP_TEXT, AGATE_MAKEUP_LONGTEXT )
add_float_with_range( "agate-knee", 2.82, 1.0, 8.0,
AGATE_KNEE_TEXT, AGATE_KNEE_LONGTEXT )
add_string( "agate-detection", "rms", AGATE_DETECTION_TEXT,
AGATE_DETECTION_LONGTEXT )
change_string_list( agate_detection_list, agate_detection_list_text )
add_string( "agate-link", "average", AGATE_LINK_TEXT,
AGATE_LINK_LONGTEXT )
change_string_list( agate_link_list, agate_link_list_text )
add_shortcut("agate")
set_callback( Open_agate )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_agate( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_agate( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "agate-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "agate-range" ) )
p_sys->range = newval.f_float;
if( !strcmp( psz_cmd, "agate-threshold" ) )
p_sys->threshold = newval.f_float;
if( !strcmp( psz_cmd, "agate-ratio" ) )
p_sys->ratio = newval.f_float;
if( !strcmp( psz_cmd, "agate-attack" ) )
p_sys->attack = newval.f_float;
if( !strcmp( psz_cmd, "agate-release" ) )
p_sys->release = newval.f_float;
if( !strcmp( psz_cmd, "agate-makeup" ) )
p_sys->makeup = newval.f_float;
if( !strcmp( psz_cmd, "agate-knee" ) )
p_sys->knee = newval.f_float;
if( !strcmp( psz_cmd, "agate-detection" ) )
{
free(p_sys->detection);
p_sys->detection = strdup(newval.psz_string);
if(p_sys->detection == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "agate-link" ) )
{
free(p_sys->link);
p_sys->link = strdup(newval.psz_string);
if(p_sys->link == NULL)
return VLC_EGENERIC;
}
if(string_generate_agate(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_agate( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->level_in = var_CreateGetFloat(p_aout,"agate-level_in");
p_sys->range = var_CreateGetFloat(p_aout,"agate-range");
p_sys->threshold = var_CreateGetFloat(p_aout,"agate-threshold");
p_sys->ratio = var_CreateGetFloat(p_aout,"agate-ratio");
p_sys->attack = var_CreateGetFloat(p_aout,"agate-attack");
p_sys->release = var_CreateGetFloat(p_aout,"agate-release");
p_sys->makeup = var_CreateGetFloat(p_aout,"agate-makeup");
p_sys->knee = var_CreateGetFloat(p_aout,"agate-knee");
p_sys->detection = var_CreateGetString(p_aout,"agate-detection");
p_sys->link = var_CreateGetString(p_aout,"agate-link");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "agate-level_in", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-range", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-threshold", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-ratio", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-attack", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-release", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-makeup", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-knee", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-detection", paramCallback_agate, p_sys );
var_AddCallback( p_aout, "agate-link", paramCallback_agate, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_agate(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"agate initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_agate =
{ .filter_audio = Process_agate, .close = Close_agate };
p_filter->ops = &filter_ops_agate;
return VLC_SUCCESS;
}
static void Close_agate( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,117 @@
/*****************************************************************************
* aiir.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_aiir( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define AIIR_FILTER_TEXT N_( "aiir" )
#define AIIR_FILTER_LONGTEXT N_( "Set arbitrary Infinite Impulse Response filter configuration." )
vlc_module_begin()
set_shortname( N_("Aiir") )
set_description( N_("Arbitrary Infinite Impulse Response filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_string( "aiir-filter", "aiir 2", AIIR_FILTER_TEXT,
AIIR_FILTER_LONGTEXT )
change_string_list( aiir_list, aiir_list_text )
add_shortcut("aiir")
set_callback( Open_aiir )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_aiir( vlc_object_t *p_this )
{
struct vlc_memstream ms;
char* aiir_filter_descr;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
aiir_filter_descr = var_CreateGetString(p_filter,"aiir-filter");
/** Configure filter parameters (filter_desc)**/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "aiir=%s",aiir_filter_descr);
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter ,p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"aiir initialised: %s",ms.ptr);
free( ms.ptr );
p_sys->frame_len_flag = 1;
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,222 @@
/*****************************************************************************
* alimiter.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float level_in;
float level_out;
float limit;
float attack;
float release;
av_filter avf;
}avfilter_sys_t;
static int Open_alimiter( vlc_object_t *p_this );
static void Close_alimiter( filter_t *p_filter );
static char* string_generate_alimiter(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "alimiter=%f:%f:%f:%f:%f", p_sys->level_in,
p_sys->level_out, p_sys->limit, p_sys->attack, p_sys->release);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
//alimiter
#define ALIMITER_LEVEL_IN_TEXT N_( "level_in" )
#define ALIMITER_LEVEL_IN_LONGTEXT N_( "Set input gain. Default is 1." \
" Range is [0.015625 - 64]" )
#define ALIMITER_LEVEL_OUT_TEXT N_( "level_out" )
#define ALIMITER_LEVEL_OUT_LONGTEXT N_( "Set output gain. Default is 1." \
" Range is [0.015625 - 64]" )
#define ALIMITER_LIMIT_TEXT N_( "limit" )
#define ALIMITER_LIMIT_LONGTEXT N_( "Dont let signals above this level pass the limiter." \
" Default is 0.0625. Range is [0- 1]" )
#define ALIMITER_ATTACK_TEXT N_( "attack" )
#define ALIMITER_ATTACK_LONGTEXT N_( "The limiter will reach its attenuation level in this" \
" amount of time in milliseconds. Default is 5 milliseconds." \
" Allowed range is from 0.1 to 80." )
#define ALIMITER_RELEASE_TEXT N_( "release" )
#define ALIMITER_RELEASE_LONGTEXT N_( "Come back from limiting to attenuation 1.0 in this" \
" amount of milliseconds. Default is 50 milliseconds." \
" Allowed range is from 1 to 8000." )
vlc_module_begin()
set_shortname( N_("Alimiter") )
set_description( N_("Alimiter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "alimiter-level_in", 1, 0.015625, 50,
ALIMITER_LEVEL_IN_TEXT, ALIMITER_LEVEL_IN_LONGTEXT )
add_float_with_range( "alimiter-level_out", 1, 0.015625, 50,
ALIMITER_LEVEL_OUT_TEXT, ALIMITER_LEVEL_OUT_LONGTEXT )
add_float_with_range( "alimiter-limit", 1, 0.0625, 1,
ALIMITER_LIMIT_TEXT, ALIMITER_LIMIT_LONGTEXT )
add_float_with_range( "alimiter-attack", 5.0, 0.1, 80.0,
ALIMITER_ATTACK_TEXT, ALIMITER_ATTACK_LONGTEXT )
add_float_with_range( "alimiter-release", 50.0, 1.0, 8000.0,
ALIMITER_RELEASE_TEXT, ALIMITER_RELEASE_LONGTEXT )
add_shortcut("alimiter")
set_callback( Open_alimiter )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_alimiter( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_alimiter( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "alimiter-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "alimiter-level_out" ) )
p_sys->level_out = newval.f_float;
if( !strcmp( psz_cmd, "alimiter-limit" ) )
p_sys->limit = newval.f_float;
if( !strcmp( psz_cmd, "alimiter-attack" ) )
p_sys->attack = newval.f_float;
if( !strcmp( psz_cmd, "alimiter-release" ) )
p_sys->release = newval.f_float;
if(string_generate_alimiter(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_alimiter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->level_in = var_CreateGetFloat(p_aout,"alimiter-level_in");
p_sys->level_out = var_CreateGetFloat(p_aout,"alimiter-level_out");
p_sys->limit = var_CreateGetFloat(p_aout,"alimiter-limit");
p_sys->attack = var_CreateGetFloat(p_aout,"alimiter-attack");
p_sys->release = var_CreateGetFloat(p_aout,"alimiter-release");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "alimiter-level_in", paramCallback_alimiter, p_sys );
var_AddCallback( p_aout, "alimiter-level_out", paramCallback_alimiter, p_sys );
var_AddCallback( p_aout, "alimiter-limit", paramCallback_alimiter, p_sys );
var_AddCallback( p_aout, "alimiter-attack", paramCallback_alimiter, p_sys );
var_AddCallback( p_aout, "alimiter-release", paramCallback_alimiter, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_alimiter(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"alimiter initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_alimiter =
{ .filter_audio = Process_alimiter, .close = Close_alimiter };
p_filter->ops = &filter_ops_alimiter;
return VLC_SUCCESS;
}
static void Close_alimiter( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,109 @@
/*****************************************************************************
* anull.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_anull( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define ANULL_TEXT N_( "Anull" )
#define ANULL_LONGTEXT N_( "Null : input passed to output unchanged" )
vlc_module_begin()
set_shortname( N_(ANULL_TEXT) )
set_description( N_(ANULL_LONGTEXT) )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_shortcut( "anull" )
set_callback( Open_anull )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_anull( vlc_object_t *p_this )
{
struct vlc_memstream ms;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
/** Configure filter parameters (filter_desc)**/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "anull");
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter ,p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"anull initialised: %s",ms.ptr);
free( ms.ptr );
p_sys->frame_len_flag = 0;
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,215 @@
/*****************************************************************************
* aphaser.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float in_gain;
float out_gain;
float delay;
float decay;
float speed;
av_filter avf;
}avfilter_sys_t;
static int Open_aphaser( vlc_object_t *p_this );
static void Close_aphaser( filter_t *p_filter );
static char* string_generate_aphaser(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "aphaser=%f:%f:%f:%f:%f", p_sys->in_gain,
p_sys->out_gain, p_sys->delay, p_sys->decay, p_sys->speed);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define APHASER_IN_GAIN_TEXT N_( "in_gain" )
#define APHASER_IN_GAIN_LONGTEXT N_( "Set the in_gain. Default is 0.4." )
#define APHASER_OUT_GAIN_TEXT N_( "out_gain" )
#define APHASER_OUT_GAIN_LONGTEXT N_( "Set the out_gain. Default is 0.74." )
#define APHASER_DELAY_TEXT N_( "delay" )
#define APHASER_DELAY_LONGTEXT N_( "Set delay in milliseconds. Default is 3.0." )
#define APHASER_DECAY_TEXT N_( "decay" )
#define APHASER_DECAY_LONGTEXT N_( "Set decay. Default is 0.4." )
#define APHASER_SPEED_TEXT N_( "speed" )
#define APHASER_SPEED_LONGTEXT N_( "Set modulation speed in Hz. Default is 0.5." )
vlc_module_begin()
set_shortname( N_("Aphaser") )
set_description( N_("Phasing effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "aphaser-in_gain", 0.4, 0.0, 1.0,
APHASER_IN_GAIN_TEXT, APHASER_IN_GAIN_LONGTEXT )
add_float_with_range( "aphaser-out_gain", 0.74, 0.0, 60.0,
APHASER_OUT_GAIN_TEXT, APHASER_OUT_GAIN_LONGTEXT )
add_float_with_range( "aphaser-delay", 3, 0.1, 5,
APHASER_DELAY_TEXT, APHASER_DELAY_LONGTEXT )
add_float_with_range( "aphaser-decay", 0.4, 0.0, 0.99,
APHASER_DECAY_TEXT, APHASER_DECAY_LONGTEXT )
add_float_with_range( "aphaser-speed", 0.5, 0.1, 2,
APHASER_SPEED_TEXT, APHASER_SPEED_LONGTEXT )
add_shortcut("aphaser")
set_callback( Open_aphaser )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_aphaser( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 0;
return Process_avaudio(p_filter,p_block,&p_sys->avf.avfilter,p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_aphaser( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "aphaser-in_gain" ) )
p_sys->in_gain = newval.f_float;
if( !strcmp( psz_cmd, "aphaser-out_gain" ) )
p_sys->out_gain = newval.f_float;
if( !strcmp( psz_cmd, "aphaser-delay" ) )
p_sys->delay = newval.f_float;
if( !strcmp( psz_cmd, "aphaser-decay" ) )
p_sys->decay = newval.f_float;
if( !strcmp( psz_cmd, "aphaser-speed" ) )
p_sys->speed = newval.f_float;
if(string_generate_aphaser(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_aphaser( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->in_gain = var_CreateGetFloat(p_aout,"aphaser-in_gain");
p_sys->out_gain = var_CreateGetFloat(p_aout,"aphaser-out_gain");
p_sys->delay = var_CreateGetFloat(p_aout,"aphaser-delay");
p_sys->decay = var_CreateGetFloat(p_aout,"aphaser-decay");
p_sys->speed = var_CreateGetFloat(p_aout,"aphaser-speed");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "aphaser-in_gain", paramCallback_aphaser, p_sys );
var_AddCallback( p_aout, "aphaser-out_gain", paramCallback_aphaser, p_sys );
var_AddCallback( p_aout, "aphaser-delay", paramCallback_aphaser, p_sys );
var_AddCallback( p_aout, "aphaser-decay", paramCallback_aphaser, p_sys );
var_AddCallback( p_aout, "aphaser-speed", paramCallback_aphaser, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_aphaser(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"aphaser initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_aphaser =
{ .filter_audio = Process_aphaser, .close = Close_aphaser };
p_filter->ops = &filter_ops_aphaser;
return VLC_SUCCESS;
}
static void Close_aphaser( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,304 @@
/*****************************************************************************
* apulsator.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float level_in;
float level_out;
char* mode;
float amount;
float offset_l;
float offset_r;
float width;
char* timing;
float bpm;
float ms;
float hz;
av_filter avf;
}avfilter_sys_t;
static int Open_apulsator( vlc_object_t *p_this );
static void Close_apulsator( filter_t *p_filter );
static char* string_generate_apulsator(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "apulsator=%f:%f:%s:%f:%f:%f:%f:%s=",
p_sys->level_in, p_sys->level_out, p_sys->mode, p_sys->amount,
p_sys->offset_l, p_sys->offset_r, p_sys->width, p_sys->timing);
if (!strcmp(p_sys->timing, "bpm"))
vlc_memstream_printf(&p_sys->avf.str, "%f", p_sys->bpm);
else if (!strcmp(p_sys->timing, "ms"))
vlc_memstream_printf(&p_sys->avf.str, "%f", p_sys->ms);
else
vlc_memstream_printf(&p_sys->avf.str, "%f", p_sys->hz);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define APULSATOR_LEVEL_IN_TEXT N_( "level_in" )
#define APULSATOR_LEVEL_IN_LONGTEXT N_( "Set input gain. By default it is 1. Range is [0.015625 - 64]." )
#define APULSATOR_LEVEL_OUT_TEXT N_( "level_out" )
#define APULSATOR_LEVEL_OUT_LONGTEXT N_( "Set output gain. By default it is 1. Range is [0.015625 - 64]." )
#define APULSATOR_MODE_TEXT N_( "mode" )
#define APULSATOR_MODE_LONGTEXT N_( "Set waveform shape the LFO will use. Default is sine." )
#define APULSATOR_AMOUNT_TEXT N_( "amount" )
#define APULSATOR_AMOUNT_LONGTEXT N_( "Set modulation. Define how much of original signal is affected by the LFO." )
#define APULSATOR_OFFSET_L_TEXT N_( "offset_l" )
#define APULSATOR_OFFSET_L_LONGTEXT N_( "Set left channel offset. Default is 0. Allowed range is [0 - 1]." )
#define APULSATOR_OFFSET_R_TEXT N_( "offset_r" )
#define APULSATOR_OFFSET_R_LONGTEXT N_( "Set right channel offset. Default is 0.5. Allowed range is [0 - 1]." )
#define APULSATOR_WIDTH_TEXT N_( "width" )
#define APULSATOR_WIDTH_LONGTEXT N_( "Set pulse width. Default is 1. Allowed range is [0 - 2]." )
#define APULSATOR_TIMING_TEXT N_( "timing" )
#define APULSATOR_TIMING_LONGTEXT N_( "Set possible timing mode. Default is hz." )
#define APULSATOR_BPM_TEXT N_( "bpm" )
#define APULSATOR_BPM_LONGTEXT N_( "Set bpm. Default is 120. Allowed range is [30 - 300]." \
" Only used if timing is set to bpm." )
#define APULSATOR_MS_TEXT N_( "ms" )
#define APULSATOR_MS_LONGTEXT N_( "Set ms. Default is 500. Allowed range is [10 - 2000]." \
" Only used if timing is set to ms." )
#define APULSATOR_HZ_TEXT N_( "hz" )
#define APULSATOR_HZ_LONGTEXT N_( "Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]." \
" Only used if timing is set to hz." )
vlc_module_begin()
set_shortname( N_("Apulsator") )
set_description( N_("Pulsator") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "apulsator-level_in", 1, 0.015625, 32,
APULSATOR_LEVEL_IN_TEXT, APULSATOR_LEVEL_IN_LONGTEXT )
add_float_with_range( "apulsator-level_out", 1, 0.015625, 32,
APULSATOR_LEVEL_OUT_TEXT, APULSATOR_LEVEL_OUT_LONGTEXT )
add_string( "apulsator-mode", "sine", APULSATOR_MODE_TEXT,
APULSATOR_MODE_LONGTEXT )
change_string_list( apulsator_mode_list, apulsator_mode_list_text )
add_float_with_range( "apulsator-amount", 1, 0, 1,
APULSATOR_AMOUNT_TEXT, APULSATOR_AMOUNT_LONGTEXT )
add_float_with_range( "apulsator-offset_l", 0, 0, 1,
APULSATOR_OFFSET_L_TEXT, APULSATOR_OFFSET_L_LONGTEXT )
add_float_with_range( "apulsator-offset_r", 0.5, 0, 1,
APULSATOR_OFFSET_R_TEXT, APULSATOR_OFFSET_R_LONGTEXT )
add_float_with_range( "apulsator-width", 1, 0, 2,
APULSATOR_WIDTH_TEXT, APULSATOR_WIDTH_LONGTEXT )
add_string( "apulsator-timing", "hz", APULSATOR_TIMING_TEXT,
APULSATOR_TIMING_LONGTEXT )
change_string_list( apulsator_timing_list, apulsator_timing_list_text )
add_float_with_range( "apulsator-bpm", 120, 30, 300,
APULSATOR_BPM_TEXT, APULSATOR_BPM_LONGTEXT )
add_float_with_range( "apulsator-ms", 500, 10, 2000,
APULSATOR_MS_TEXT, APULSATOR_MS_LONGTEXT )
add_float_with_range( "apulsator-hz", 2, 0.1, 100,
APULSATOR_HZ_TEXT, APULSATOR_HZ_LONGTEXT )
add_shortcut( "apulsator" )
set_callback( Open_apulsator )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_apulsator( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_apulsator( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "apulsator-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-level_out" ) )
p_sys->level_out = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-mode" ) )
{
free(p_sys->mode);
p_sys->mode = strdup(newval.psz_string);
if(p_sys->mode == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "apulsator-amount" ) )
p_sys->amount = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-offset_l" ) )
p_sys->offset_l = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-offset_r" ) )
p_sys->offset_r = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-timing" ) )
{
free(p_sys->timing);
p_sys->timing = strdup(newval.psz_string);
if(p_sys->timing == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "apulsator-bpm" ) )
p_sys->bpm = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-ms" ) )
p_sys->ms = newval.f_float;
if( !strcmp( psz_cmd, "apulsator-hz" ) )
p_sys->hz = newval.f_float;
if(string_generate_apulsator(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_apulsator( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->level_in = var_CreateGetFloat(p_aout,"apulsator-level_in");
p_sys->level_out = var_CreateGetFloat(p_aout,"apulsator-level_out");
p_sys->mode = var_CreateGetString(p_aout,"apulsator-mode");
p_sys->amount = var_CreateGetFloat(p_aout,"apulsator-amount");
p_sys->offset_l = var_CreateGetFloat(p_aout,"apulsator-offset_l");
p_sys->offset_r = var_CreateGetFloat(p_aout,"apulsator-offset_r");
p_sys->width = var_CreateGetFloat(p_aout,"apulsator-width");
p_sys->timing = var_CreateGetString(p_aout,"apulsator-timing");
p_sys->bpm = var_CreateGetFloat(p_aout,"apulsator-bpm");
p_sys->ms = var_CreateGetFloat(p_aout,"apulsator-ms");
p_sys->hz = var_CreateGetFloat(p_aout,"apulsator-hz");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "apulsator-level_in", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-level_out", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-mode", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-amount", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-offset_l", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-offset_r", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-width", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-timing", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-bpm", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-ms", paramCallback_apulsator, p_sys );
var_AddCallback( p_aout, "apulsator-hz", paramCallback_apulsator, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_apulsator(p_sys), p_filter, &p_sys->avf.avfilter) <0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"apulsator initialized: %s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_apulsator =
{ .filter_audio = Process_apulsator, .close = Close_apulsator };
p_filter->ops = &filter_ops_apulsator;
return VLC_SUCCESS;
}
static void Close_apulsator( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,189 @@
/*****************************************************************************
* asoftclip.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
char* type;
float threshold;
av_filter avf;
}avfilter_sys_t;
static int Open_asoftclip( vlc_object_t *p_this );
static void Close_asoftclip( filter_t *p_filter );
static char* string_generate_softclip(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "asoftclip=%s:%f", p_sys->type, p_sys->threshold);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define ASOFTCLIP_TYPE_TEXT N_( "type" )
#define ASOFTCLIP_TYPE_LONGTEXT N_( "Set type of soft-clipping." )
#define ASOFTCLIP_THRESHOLD_TEXT N_( "threshold" )
#define ASOFTCLIP_THRESHOLD_LONGTEXT N_( "Set threshold from where to start clipping." \
" Default value is 0dB or 1." )
vlc_module_begin()
set_shortname( N_("Asoftclip") )
set_description( N_("Audio soft clipping.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_string( "asoftclip-type", "exp", ASOFTCLIP_TYPE_TEXT,
ASOFTCLIP_TYPE_LONGTEXT )
change_string_list( softclip_type_list, softclip_type_list_text )
add_float_with_range( "asoftclip-threshold", 1, 0.01, 1,
ASOFTCLIP_THRESHOLD_TEXT, ASOFTCLIP_THRESHOLD_LONGTEXT )
add_shortcut("asoftclip")
set_callback( Open_asoftclip )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_asoftclip( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 0;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_asoftclip( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "asoftclip-type" ) )
{
free(p_sys->type);
p_sys->type = strdup(newval.psz_string);
if(p_sys->type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "asoftclip-threshold" ) )
p_sys->threshold = newval.f_float;
if(string_generate_softclip(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_asoftclip( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->type = var_CreateGetString(p_aout,"asoftclip-type");
p_sys->threshold = var_CreateGetFloat(p_aout,"asoftclip-threshold");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "asoftclip-type", paramCallback_asoftclip, p_sys );
var_AddCallback( p_aout, "asoftclip-threshold", paramCallback_asoftclip, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_softclip(p_sys), p_filter, &p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"asoftclip initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_asoftclip =
{ .filter_audio = Process_asoftclip, .close = Close_asoftclip };
p_filter->ops = &filter_ops_asoftclip;
return VLC_SUCCESS;
}
static void Close_asoftclip( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,209 @@
/*****************************************************************************
* astereowiden.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float delay;
float feedback;
float crossfeed;
float drymix;
av_filter avf;
}avfilter_sys_t;
static int Open_astereowiden( vlc_object_t *p_this );
static void Close_astereowiden( filter_t *p_filter );
static char* string_generate_astereowiden(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "stereowiden=%f:%f:%f:%f", p_sys->delay,
p_sys->feedback, p_sys->crossfeed, p_sys->drymix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define ASTEREOWIDEN_DELAY_TEXT N_( "delay" )
#define ASTEREOWIDEN_DELAY_LONGTEXT N_( "Time in milliseconds of the delay of left signal into" \
" right and vice versa. Default is 20 milliseconds." )
#define ASTEREOWIDEN_FEEDBACK_TEXT N_( "feedback" )
#define ASTEREOWIDEN_FEEDBACK_LONGTEXT N_( "Amount of gain in delayed signal into right and vice" \
" versa. Gives a delay effect of left signal in right output and vice" \
" versa which gives widening effect. Default is 0.3." )
#define ASTEREOWIDEN_CROSSFEED_TEXT N_( "crossfeed" )
#define ASTEREOWIDEN_CROSSFEED_LONGTEXT N_( "Cross feed of left into right with inverted phase." \
" This helps in suppressing the mono. If the value is 1 it will cancel" \
" all the signal common to both channels. Default is 0.3." )
#define ASTEREOWIDEN_DRYMIX_TEXT N_( "drymix" )
#define ASTEREOWIDEN_DRYMIX_LONGTEXT N_( "Set level of input signal of original channel." \
" Default is 0.8." )
vlc_module_begin()
set_shortname( N_("Astereowiden") )
set_description( N_("Stereo widening effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "astereowiden-delay", 20.0, 1.0, 100.0,
ASTEREOWIDEN_DELAY_TEXT, ASTEREOWIDEN_DELAY_LONGTEXT )
add_float_with_range( "astereowiden-feedback", 0.3, 0.0, 0.9,
ASTEREOWIDEN_FEEDBACK_TEXT, ASTEREOWIDEN_FEEDBACK_LONGTEXT )
add_float_with_range( "astereowiden-crossfeed", 0.3, 0.0, 0.8,
ASTEREOWIDEN_CROSSFEED_TEXT, ASTEREOWIDEN_CROSSFEED_LONGTEXT )
add_float_with_range( "astereowiden-drymix", 0.8, 0.0, 1.0,
ASTEREOWIDEN_DRYMIX_TEXT, ASTEREOWIDEN_DRYMIX_LONGTEXT )
add_shortcut("astereowiden")
set_callback( Open_astereowiden )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_astereowiden( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 0;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_astereowiden( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "astereowiden-delay" ) )
p_sys->delay = newval.f_float;
if( !strcmp( psz_cmd, "astereowiden-feedback" ) )
p_sys->feedback = newval.f_float;
if( !strcmp( psz_cmd, "astereowiden-crossfeed" ) )
p_sys->crossfeed = newval.f_float;
if( !strcmp( psz_cmd, "astereowiden-drymix" ) )
p_sys->drymix = newval.f_float;
if(string_generate_astereowiden(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_astereowiden( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->delay = var_CreateGetFloat(p_aout,"astereowiden-delay");
p_sys->feedback = var_CreateGetFloat(p_aout,"astereowiden-feedback");
p_sys->crossfeed = var_CreateGetFloat(p_aout,"astereowiden-crossfeed");
p_sys->drymix = var_CreateGetFloat(p_aout,"astereowiden-drymix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "astereowiden-delay", paramCallback_astereowiden, p_sys );
var_AddCallback( p_aout, "astereowiden-feedback", paramCallback_astereowiden, p_sys );
var_AddCallback( p_aout, "astereowiden-crossfeed", paramCallback_astereowiden, p_sys );
var_AddCallback( p_aout, "astereowiden-drymix", paramCallback_astereowiden, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_astereowiden(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"astereowiden initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_astereowiden =
{ .filter_audio = Process_astereowiden, .close = Close_astereowiden };
p_filter->ops = &filter_ops_astereowiden;
return VLC_SUCCESS;
}
static void Close_astereowiden( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,411 @@
/*****************************************************************************
* avaudio.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
/**
* Get AVSampleFormat for vlc audio format fourcc
*
* @param vlc_frmt -> input audio format fourcc
* @return enum AVSampleFormat
*/
enum AVSampleFormat GetAVSampleFormat(vlc_fourcc_t vlc_frmt);
int init_filters(const char *filters_descr, filter_t *p_filter, filter_sys_t *p_sys)
{
char* args;
int ret = 0;
const AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
const AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
p_sys->frame_len_flag = 1;
p_sys->frmt = GetAVSampleFormat(p_filter->fmt_in.audio.i_format);
const enum AVSampleFormat out_sample_fmts[] = { p_sys->frmt, -1 };
const uint64_t in_ch_layout = av_get_default_channel_layout(p_filter->fmt_in.audio.i_channels);
const int64_t out_channel_layouts[] = { in_ch_layout, -1 };
p_sys->i_rate = p_filter->fmt_in.audio.i_rate;
const int out_sample_rates[] = { p_sys->i_rate, -1 };
const AVFilterLink *outlink;
ret = asprintf(&args, "sample_fmt=%s:sample_rate=%d:channel_layout=0x%"PRIx64,
av_get_sample_fmt_name(p_sys->frmt), p_sys->i_rate,
in_ch_layout);
if (ret < 0) {
goto end1;
}
p_sys->filter_graph = avfilter_graph_alloc();
if (!outputs || !inputs || !p_sys->filter_graph) {
ret = AVERROR(ENOMEM);
goto end;
}
ret = avfilter_graph_create_filter(&p_sys->buffersrc_ctx, abuffersrc, "in",
args, NULL, p_sys->filter_graph);
if (ret < 0) {
msg_Dbg(p_filter,"init_filters: Could not create audio buffer source");
goto end;
}
/* buffer audio sink: to terminate the filter chain. */
ret = avfilter_graph_create_filter(&p_sys->buffersink_ctx, abuffersink, "out",
NULL, NULL, p_sys->filter_graph);
if (ret < 0) {
msg_Dbg(p_filter,"init_filters: Could not create audio buffer sink");
goto end;
}
ret = av_opt_set_int_list(p_sys->buffersink_ctx, "sample_fmts", out_sample_fmts, -1,
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
msg_Dbg(p_filter,"init_filters: Could not set output sample format.");
goto end;
}
ret = av_opt_set_int_list(p_sys->buffersink_ctx, "channel_layouts", out_channel_layouts, -1,
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
msg_Dbg(p_filter,"init_filters: Could not set output channel layout.");
goto end;
}
ret = av_opt_set_int_list(p_sys->buffersink_ctx, "sample_rates", out_sample_rates, -1,
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
msg_Dbg(p_filter,"init_filters: Could not set output sample rate");
goto end;
}
/*
* Set the endpoints for the filter graph. The filter_graph will
* be linked to the graph described by filters_descr.
*/
outputs->name = av_strdup("in");
outputs->filter_ctx = p_sys->buffersrc_ctx;
outputs->pad_idx = 0;
outputs->next = NULL;
inputs->name = av_strdup("out");
inputs->filter_ctx = p_sys->buffersink_ctx;
inputs->pad_idx = 0;
inputs->next = NULL;
ret = avfilter_graph_parse_ptr(p_sys->filter_graph, filters_descr,
&inputs, &outputs, NULL);
if (ret < 0){
msg_Dbg(p_filter, "Failed to add avfilter graph.");
goto end;
}
ret = avfilter_graph_config(p_sys->filter_graph, NULL);
if (ret < 0)
goto end;
/* args buffer is reused to store channel layout string */
outlink = p_sys->buffersink_ctx->inputs[0];
av_get_channel_layout_string(args, sizeof(args), -1, outlink->channel_layout);
end:
free(args);
end1:
avfilter_inout_free(&inputs);
avfilter_inout_free(&outputs);
return ret;
}
enum AVSampleFormat GetAVSampleFormat(vlc_fourcc_t vlc_frmt)
{
enum AVSampleFormat frmt;
switch (vlc_frmt)
{
case VLC_CODEC_U8:
frmt = AV_SAMPLE_FMT_U8;
break;
case VLC_CODEC_S16N:
frmt = AV_SAMPLE_FMT_S16;
break;
case VLC_CODEC_S32N:
frmt = AV_SAMPLE_FMT_S32;
break;
case VLC_CODEC_FL32:
frmt = AV_SAMPLE_FMT_FLT;
break;
case VLC_CODEC_FL64:
frmt = AV_SAMPLE_FMT_DBL;
break;
default:
frmt=AV_SAMPLE_FMT_NONE;
break;
}
return frmt;
}
char* check_Bounds(filter_t *p_filter,char* check_str,float min, float max,float val_default)
{
struct vlc_memstream final_str;
char* str_default;
if(asprintf(&str_default, "%f", val_default) < 0)
return NULL;
if( vlc_memstream_open( &final_str ) != 0 )
{
free(str_default);
return NULL;
}
char* current_str = strtok_r(check_str, "|", &check_str);
float current_str_val = strtof(current_str, NULL);
if(current_str_val <= min || current_str_val > max){
vlc_memstream_printf(&final_str, "%s", str_default);
msg_Warn(p_filter,"filter parameter out of bound. Set to default");
}
else
vlc_memstream_printf(&final_str, "%s", current_str);
current_str = strtok_r(check_str, "|", &check_str);
while (current_str != NULL)
{
current_str_val = strtof(current_str, NULL);
vlc_memstream_printf(&final_str, "|" );
if(current_str_val <= min || current_str_val > max){
vlc_memstream_printf(&final_str, "%s", str_default);
msg_Warn(p_filter,"filter parameter out of bound. Set to default");
}
else
vlc_memstream_printf(&final_str, "%s", current_str);
current_str = strtok_r(check_str, "|", &check_str);
}
if(vlc_memstream_close(&final_str))
{
free(str_default);
return NULL;
}
free(str_default);
return final_str.ptr;
}
/*****************************************************************************
* Process: process samples buffer
*****************************************************************************/
void vlc_av_frame_Release(block_t *block);
block_t *vlc_av_frame_Wrap(AVFrame *frame, int frame_len_flag);
block_t *convert_AVFrame( filter_t *filter , AVFrame *frame , int frame_len_flag);
block_t *Process( filter_t *p_filter, block_t *p_block )
{
filter_sys_t* p_sys = p_filter->p_sys;
return Process_avaudio(p_filter, p_block, p_filter->p_sys, p_sys->frame_len_flag);
}
block_t *Process_avaudio( filter_t *p_filter, block_t *p_block, filter_sys_t *p_sys, int frame_flag )
{
block_t *p_out_block;
block_t *temp = p_block;
int ret;
AVFrame *frame = av_frame_alloc();
if (!frame) {
msg_Err(p_filter,"Could not allocate frame.");
return p_block;
}
AVFrame *filt_frame = av_frame_alloc();
if (!filt_frame) {
msg_Err(p_filter,"Could not allocate frame.");
av_frame_free(&frame);
return p_block;
}
frame->data[0] = temp->p_buffer;
frame->linesize[0] = temp->i_buffer;
frame->nb_samples = temp->i_nb_samples;
frame->format = p_sys->frmt;
frame->pts = temp->i_pts;
frame->pkt_dts = temp->i_dts;
frame->pkt_size = temp->i_length;
frame->sample_rate = (int)p_filter->fmt_in.audio.i_rate;
frame->channel_layout = av_get_default_channel_layout(p_filter->fmt_in.audio.i_channels);
frame->channels = p_filter->fmt_in.audio.i_channels;
/* push the audio data from decoded frame into the filtergraph */
if (av_buffersrc_add_frame_flags(p_sys->buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
msg_Dbg(p_filter, "Error while feeding the audio filtergraph.");
goto end;
}
/* pull filtered audio from the filtergraph */
ret = av_buffersink_get_frame(p_sys->buffersink_ctx, filt_frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF){
msg_Err(p_filter,"Could not allocate frame.");
}
if (ret < 0 && ret != AVERROR_EOF) {
msg_Err(p_filter,"Error occurred: %s", av_err2str(ret));
goto end;
}
if(!frame_flag) //need work to avoid duplicating block
p_out_block = block_Duplicate(convert_AVFrame(p_filter,filt_frame,frame_flag));
else
p_out_block = convert_AVFrame(p_filter,filt_frame,frame_flag);
if( p_out_block == NULL ){
msg_Err(p_filter , "Could not allocate out block_t.");
goto end;
}
av_frame_free(&frame);
av_frame_free(&filt_frame);
block_Release(p_block);
return p_out_block;
end:
av_frame_free(&frame);
av_frame_free(&filt_frame);
return p_block;
}
bool Process_avaudio_2( filter_t *p_filter, av_filter *p_sys )
{
vlc_mutex_lock(&p_sys->lock);
if(p_sys->params_changed)
{
p_sys->params_changed = false;
avfilter_graph_free(&p_sys->avfilter.filter_graph);
if(init_filters(p_sys->str.ptr,p_filter,&p_sys->avfilter) < 0)
{
avfilter_graph_free(&p_sys->avfilter.filter_graph);
free(p_sys);
return false;
}
free(p_sys->str.ptr);
}
vlc_mutex_unlock( &p_sys->lock);
return true;
}
void vlc_av_frame_Release(block_t *block)
{
vlc_av_frame_t *b = container_of(block, vlc_av_frame_t , block );
free(b);
}
struct vlc_block_callbacks vlc_av_frame_cbs =
{
vlc_av_frame_Release,
};
block_t *vlc_av_frame_Wrap(AVFrame *frame, int frame_len_flag)
{
int frame_len_correct = 256;
if(frame_len_flag == 0)
frame_len_correct = 0;
for (unsigned i = 1; i < AV_NUM_DATA_POINTERS; i++)
assert(frame->linesize[i] == 0); /* only packed frame supported */
vlc_av_frame_t *b = malloc(sizeof (*b));
if (unlikely(b == NULL))
return NULL;
block_t *block = &b->block;
block_Init(block, &vlc_av_frame_cbs,
frame->extended_data[0], frame->linesize[0]-frame_len_correct);
block->i_nb_samples = frame->nb_samples;
return block;
}
/**
* Convert AVFrame* to Block_t*
*/
block_t *convert_AVFrame( filter_t *filter , AVFrame *frame , int frame_len_flag)
{
block_t *p_block;
if( av_sample_fmt_is_planar( frame->format ) )
{
p_block = block_Alloc(frame->linesize[0] * frame->channels);
if ( likely(p_block) )
{
int nb_channels = 32 < frame->channels? 32:frame->channels;
const void *planes[nb_channels];
for (int i = 0; i < nb_channels ; i++)
planes[i] = frame->extended_data[i];
aout_Interleave(p_block->p_buffer, planes, frame->nb_samples,
nb_channels, filter->fmt_in.audio.i_format);
p_block->i_nb_samples = frame->nb_samples;
}
av_frame_free(&frame);
}
else
{
p_block = vlc_av_frame_Wrap(frame, frame_len_flag);
}
return p_block;
}
/*****************************************************************************
* Close: close filter
*****************************************************************************/
void Close( filter_t *p_filter )
{
filter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,102 @@
/*****************************************************************************
* avaudio.h :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef AVAUDIO_H
#define AVAUDIO_H 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_aout_volume.h>
#include <vlc_filter.h>
#include <vlc_modules.h>
#include <vlc_plugin.h>
#include <vlc_memstream.h>
#include <libavcodec/avcodec.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/channel_layout.h>
#include <libavutil/opt.h>
/**
* Holds Instances of filter.
*/
typedef struct
{
AVFilterContext *buffersink_ctx;
AVFilterContext *buffersrc_ctx;
AVFilterGraph *filter_graph;
int frame_len_flag;
int frmt;
unsigned int i_rate;
} filter_sys_t;
typedef struct
{
struct vlc_memstream str;
filter_sys_t avfilter;
bool params_changed;
vlc_mutex_t lock;
}av_filter;
typedef struct
{
block_t block;
AVFrame *frame;
} vlc_av_frame_t;
/**
* @brief
*
* @param filters_descr
* @param p_filter
* @return int
*/
int init_filters(const char *filters_descr, filter_t *p_filter, filter_sys_t *p_sys);
/**
* Check filter parameter bounds for parameters with multiple values (list) separated by '|'.
*
* @param check_str complete parameter value string
* @param min lower range value
* @param max upper range value
* @param val_default default value for the parameter
*/
char* check_Bounds(filter_t *p_filter,char* check_str,float min, float max,float val_default);
block_t *Process( filter_t *p_filter, block_t *p_block );
block_t *Process_avaudio( filter_t *p_filter, block_t *p_block, filter_sys_t *p_sys, int frame_flag );
bool Process_avaudio_2( filter_t *p_filter, av_filter *p_sys );
void Close( filter_t *p_filter );
#endif

View File

@ -0,0 +1,237 @@
/*****************************************************************************
* avaudio_lists.h :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_AVAUDIO_LISTS_H_
#define VLC_AVAUDIO_LISTS_H_
/*****************************************************************************
* aemphasis : mode, type
*****************************************************************************/
#define NB_AEMPHASIS_MODES 2
static const char *const aemphasis_mode_list[NB_AEMPHASIS_MODES] = {
"reproduction", "production"
};
static const char *const aemphasis_mode_list_text[NB_AEMPHASIS_MODES] = {
N_("reproduction"),
N_("production")
};
#define NB_AEMPHASIS_TYPES 9
static const char *const aemphasis_type_list[NB_AEMPHASIS_TYPES] = {
"cd", "emi", "bsi",
"riaa", "col", "50fm",
"75fm", "50kf", "75kf"
};
static const char *const aemphasis_type_list_text[NB_AEMPHASIS_TYPES] = {
N_("cd"),
N_("emi"),
N_("bsi"),
N_("riaa"),
N_("col"),
N_("50fm"),
N_("75fm"),
N_("50kf"),
N_("75kf")
};
/*****************************************************************************
* agate : detection, link
*****************************************************************************/
#define NB_AGATE_DETECTION 2
static const char *const agate_detection_list[NB_AGATE_DETECTION] = {
"rms", "peak"
};
static const char *const agate_detection_list_text[NB_AGATE_DETECTION] = {
N_("rms"),
N_("peak")
};
#define NB_AGATE_LINK 2
static const char *const agate_link_list[NB_AGATE_LINK] = {
"average", "maximum"
};
static const char *const agate_link_list_text[NB_AGATE_LINK] = {
N_("average"),
N_("maximum")
};
/*****************************************************************************
* Asoftclip: soft-clip type
*****************************************************************************/
#define NB_ASOFTCLIP_TYPES 7
static const char *const softclip_type_list[NB_ASOFTCLIP_TYPES] = {
"exp", "atan", "cubic", "tanh",
"alg", "quintic", "sin"
};
static const char *const softclip_type_list_text[NB_ASOFTCLIP_TYPES] = {
N_("exp"),
N_("atan"),
N_("cubic"),
N_("tanh"),
N_("alg"),
N_("quintic"),
N_("sin")
};
/*****************************************************************************
* aiir:
*****************************************************************************/
static const char *const aiir_list[] = {
"k=1.5:z=0.10498 -2.1 3.035 -2.15 0.10502:p=5 -2.64 3 -2.62 1:f=tf:r=d",
"k=0.79575848078096756:dry=0.3"
":z=0.80918701+0.58773007i 0.80918701-0.58773007i 0.80884700+0.58784055i 0.80884700-0.58784055i"
":p=0.63892345+0.59951235i 0.63892345-0.59951235i 0.79582691+0.44198673i 0.79582691-0.44198673i:f=zp:r=s",
"k=0.79575848078096756:dry=0.3:wet=0.6"
":z=0.80918701+0.58773007i 0.80918701-0.58773007i 0.80884700+0.58784055i 0.80884700-0.58784055i"
":p=0.63892345+0.59951235i 0.63892345-0.59951235i 0.79582691+0.44198673i 0.79582691-0.44198673i:f=zp:r=s",
"k=0.79575848078096756:dry=0.8:wet=0.29"
":z=0.80918701+0.58773007i 0.80918701-0.58773007i 0.80884700+0.58784055i 0.80884700-0.58784055i"
":p=0.63892345+0.59951235i 0.63892345-0.59951235i 0.79582691+0.44198673i 0.79582691-0.44198673i:f=zp:r=s",
"k=1:dry=0.1:wet=0.82"
":z=7.957584807809675810E-1 -2.575128568908332300 3.674839853930788710 -2.57512875289799137 7.957586296317130880E-1"
":p=1 -2.86950072432325953 3.63022088054647218 -2.28075678147272232 6.361362326477423500E-1:f=tf:r=d",
"k=3:dry=0.78:wet=0.2"
":z=7.957584807809675810E-1 -2.575128568908332300 3.674839853930788710 -2.57512875289799137 7.957586296317130880E-1"
":p=1 -2.86950072432325953 3.63022088054647218 -2.28075678147272232 6.361362326477423500E-1:f=tf:r=d",
};
static const char *const aiir_list_text[] = {
N_("aiir 1"),
N_("aiir 2"),
N_("aiir 3"),
N_("aiir 4"),
N_("aiir 5"),
N_("aiir 6"),
};
/*****************************************************************************
* Apulsator : mode, timing
*****************************************************************************/
#define NB_APULSATOR_MODES 5
static const char *const apulsator_mode_list[NB_APULSATOR_MODES] = {
"sine", "triangle", "square", "sawup", "sawdown"
};
static const char *const apulsator_mode_list_text[NB_APULSATOR_MODES] = {
N_("sine"),
N_("triangle"),
N_("square"),
N_("sawup"),
N_("sawdown")
};
#define NB_APULSATOR_TIMING 3
static const char *const apulsator_timing_list[NB_APULSATOR_TIMING] = {
"bpm", "ms","hz"
};
static const char *const apulsator_timing_list_text[NB_APULSATOR_TIMING] = {
N_("bpm"),
N_("ms"),
N_("hz")
};
/*****************************************************************************
* bs2b: bs2b-profile
*****************************************************************************/
#define NB_PROFILES 3
static const char *const bs2b_profile_list[NB_PROFILES] = {
"default", "cmoy", "jmeier"
};
static const char *const bs2b_profile_list_text[NB_PROFILES] = {
N_("default"),
N_("cmoy"),
N_("jmeier")
};
/*****************************************************************************
* Deesser: output mode.
*****************************************************************************/
#define NB_DEESSER_MODES 3
static const char *const deesser_mode_list[NB_DEESSER_MODES] = {
"i", "o", "e"
};
static const char *const deesser_mode_list_text[NB_DEESSER_MODES] = {
N_("Pass input unchanged"),
N_("Pass ess filtered out"),
N_("Pass only ess")
};
/*****************************************************************************
* flanger : shape, interp
*****************************************************************************/
#define NB_FLANGER_SHAPE 2
static const char *const flanger_shape_list[NB_FLANGER_SHAPE] = {
"sinusoidal", "triangular"
};
static const char *const flanger_shape_list_text[NB_FLANGER_SHAPE] = {
N_("sinusoidal"),
N_("triangular")
};
#define NB_FLANGER_INTERP 2
static const char *const flanger_interp_list[NB_FLANGER_INTERP] = {
"linear", "quadratic"
};
static const char *const flanger_interp_list_text[NB_FLANGER_INTERP] = {
N_("Linear"),
N_("Quadratic")
};
/*****************************************************************************
* lowpass, bandpass, bandreject, highpass, treble : width_type
*****************************************************************************/
#define NB_WIDTH_TYPES 5
static const char *const lowpass_width_type_list[] = {
"h", "q", "o", "s", "k"
};
static const char *const lowpass_width_type_list_text[] = {
N_("Hz"),
N_("Q-Factor"),
N_("octave"),
N_("slope"),
N_("kHz")
};
#endif

View File

@ -0,0 +1,211 @@
/*****************************************************************************
* bandpass.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float freq;
char* width_type;
float width;
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_bandpass( vlc_object_t *p_this );
static void Close_bandpass( filter_t *p_filter );
static char* string_generate_bandpass(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "bandpass=f=%f:t=%s:w=%f:m=%f",
p_sys->freq, p_sys->width_type, p_sys->width, p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define BANDPASS_FREQUENCY_TEXT N_( "frequency" )
#define BANDPASS_FREQUENCY_LONGTEXT N_( "Set the filters central frequency. Default is 3000." \
" Range is [0-10000]" )
#define BANDPASS_WIDTH_TYPE_TEXT N_( "width type" )
#define BANDPASS_WIDTH_TYPE_LONGTEXT N_( "Set method to specify band-width of filter." )
#define BANDPASS_WIDTH_TEXT N_( "width" )
#define BANDPASS_WIDTH_LONGTEXT N_( "Specify the band-width of a filter in width_type units." )
#define BANDPASS_MIX_TEXT N_( "mix" )
#define BANDPASS_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Bandpass") )
set_description( N_("Band-pass filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "bandpass-frequency", 500, 0.1, 10000,
BANDPASS_FREQUENCY_TEXT, BANDPASS_FREQUENCY_LONGTEXT )
add_string( "bandpass-width-type", "h", BANDPASS_WIDTH_TYPE_TEXT,
BANDPASS_WIDTH_TYPE_LONGTEXT )
change_string_list( lowpass_width_type_list, lowpass_width_type_list_text )
add_float_with_range( "bandpass-width", 0.7, 0.1, 1000,
BANDPASS_WIDTH_TEXT, BANDPASS_WIDTH_LONGTEXT )
add_float_with_range( "bandpass-mix", 1, 0, 1,
BANDPASS_MIX_TEXT, BANDPASS_MIX_LONGTEXT )
add_shortcut("bandpass")
set_callback( Open_bandpass )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_bandpass( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_bandpass( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "bandpass-frequency" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "bandpass-width-type" ) )
{
free(p_sys->width_type);
p_sys->width_type = strdup(newval.psz_string);
if(p_sys->width_type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "bandpass-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "bandpass-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_bandpass(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_bandpass( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->freq = var_CreateGetFloat(p_aout,"bandpass-frequency");
p_sys->width_type = var_CreateGetString(p_aout,"bandpass-width-type");
p_sys->width = var_CreateGetFloat(p_aout,"bandpass-width");
p_sys->mix = var_CreateGetFloat(p_aout,"bandpass-mix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "bandpass-frequency", paramCallback_bandpass, p_sys );
var_AddCallback( p_aout, "bandpass-width-type", paramCallback_bandpass, p_sys );
var_AddCallback( p_aout, "bandpass-width", paramCallback_bandpass, p_sys );
var_AddCallback( p_aout, "bandpass-mix", paramCallback_bandpass, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_bandpass(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"bandpass initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_bandpass =
{ .filter_audio = Process_bandpass, .close = Close_bandpass };
p_filter->ops = &filter_ops_bandpass;
return VLC_SUCCESS;
}
static void Close_bandpass( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,212 @@
/*****************************************************************************
* bandreject.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float freq;
char* width_type;
float width;
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_bandreject( vlc_object_t *p_this );
static void Close_bandreject( filter_t *p_filter );
static char* string_generate_bandreject(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "bandreject=f=%f:t=%s:w=%f:m=%f",
p_sys->freq, p_sys->width_type, p_sys->width, p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define BANDREJECT_FREQUENCY_TEXT N_( "frequency" )
#define BANDREJECT_FREQUENCY_LONGTEXT N_( "Set the filters central frequency. Default is 3000." \
" Range is [0-10000]" )
#define BANDREJECT_WIDTH_TYPE_TEXT N_( "width type" )
#define BANDREJECT_WIDTH_TYPE_LONGTEXT N_( "Set method to specify band-width of filter." )
#define BANDREJECT_WIDTH_TEXT N_( "width" )
#define BANDREJECT_WIDTH_LONGTEXT N_( "Specify the band-width of a filter in width_type units." )
#define BANDREJECT_MIX_TEXT N_( "mix" )
#define BANDREJECT_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Bandreject") )
set_description( N_("Band-reject filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "bandreject-frequency", 500, 0.1, 10000,
BANDREJECT_FREQUENCY_TEXT, BANDREJECT_FREQUENCY_LONGTEXT )
add_string( "bandreject-width-type", "h", BANDREJECT_WIDTH_TYPE_TEXT,
BANDREJECT_WIDTH_TYPE_LONGTEXT )
change_string_list( lowpass_width_type_list, lowpass_width_type_list_text )
add_float_with_range( "bandreject-width", 0.7, 0.1, 1000,
BANDREJECT_WIDTH_TEXT, BANDREJECT_WIDTH_LONGTEXT )
add_float_with_range( "bandreject-mix", 1, 0, 1,
BANDREJECT_MIX_TEXT, BANDREJECT_MIX_LONGTEXT )
add_shortcut("bandreject")
set_callback( Open_bandreject )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_bandreject( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_bandreject( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "bandreject-frequency" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "bandreject-width-type" ) )
{
free(p_sys->width_type);
p_sys->width_type = strdup(newval.psz_string);
if(p_sys->width_type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "bandreject-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "bandreject-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_bandreject(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_bandreject( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->freq = var_CreateGetFloat(p_aout,"bandreject-frequency");
p_sys->width_type = var_CreateGetString(p_aout,"bandreject-width-type");
p_sys->width = var_CreateGetFloat(p_aout,"bandreject-width");
p_sys->mix = var_CreateGetFloat(p_aout,"bandreject-mix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "bandreject-frequency", paramCallback_bandreject, p_sys );
var_AddCallback( p_aout, "bandreject-width-type", paramCallback_bandreject, p_sys );
var_AddCallback( p_aout, "bandreject-width", paramCallback_bandreject, p_sys );
var_AddCallback( p_aout, "bandreject-mix", paramCallback_bandreject, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_bandreject(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"bandreject initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_bandreject =
{ .filter_audio = Process_bandreject, .close = Close_bandreject };
p_filter->ops = &filter_ops_bandreject;
return VLC_SUCCESS;
}
static void Close_bandreject( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,242 @@
/*****************************************************************************
* biquad.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float a[3];
float b[3];
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_biquad( vlc_object_t *p_this );
static void Close_biquad( filter_t *p_filter );
static char* string_generate_biquad(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "biquad=a0=%f:a1=%f:a2=%f:b0=%f:b1=%f:"
"b2=%f:m=%f", p_sys->a[0], p_sys->a[1], p_sys->a[2], p_sys->b[0],
p_sys->b[1], p_sys->b[2], p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define BIQUAD_A0_TEXT N_( "a0" )
#define BIQUAD_A0_LONGTEXT N_( "a0, a1, a2 are the denominator coefficients." )
#define BIQUAD_A1_TEXT N_( "a1" )
#define BIQUAD_A1_LONGTEXT N_( "a0, a1, a2 are the denominator coefficients." )
#define BIQUAD_A2_TEXT N_( "a2" )
#define BIQUAD_A2_LONGTEXT N_( "a0, a1, a2 are the denominator coefficients." )
#define BIQUAD_B0_TEXT N_( "b0" )
#define BIQUAD_B0_LONGTEXT N_( "b0, b1, b2 are the numerator coefficients" )
#define BIQUAD_B1_TEXT N_( "b1" )
#define BIQUAD_B1_LONGTEXT N_( "b0, b1, b2 are the numerator coefficients" )
#define BIQUAD_B2_TEXT N_( "b2" )
#define BIQUAD_B2_LONGTEXT N_( "b0, b1, b2 are the numerator coefficients" )
#define BIQUAD_MIX_TEXT N_( "mix" )
#define BIQUAD_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Biquad") )
set_description( N_("Biquad filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "biquad-a0", 1.0, -50.0, 50.0,
BIQUAD_A0_TEXT, BIQUAD_A0_LONGTEXT )
add_float_with_range( "biquad-a1", 0.0, -50.0, 50.0,
BIQUAD_A1_TEXT, BIQUAD_A1_LONGTEXT )
add_float_with_range( "biquad-a2", 0.0, -50.0, 50.0,
BIQUAD_A2_TEXT, BIQUAD_A2_LONGTEXT )
add_float_with_range( "biquad-b0", 0.0, -50.0, 50.0,
BIQUAD_B0_TEXT, BIQUAD_B0_LONGTEXT )
add_float_with_range( "biquad-b1", 0.0, -50.0, 50.0,
BIQUAD_B1_TEXT, BIQUAD_B1_LONGTEXT )
add_float_with_range( "biquad-b2", 0.0, -50.0, 50.0,
BIQUAD_B2_TEXT, BIQUAD_B2_LONGTEXT )
add_float_with_range( "biquad-mix", 1, 0, 1,
BIQUAD_MIX_TEXT, BIQUAD_MIX_LONGTEXT )
add_shortcut("biquad")
set_callback( Open_biquad )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_biquad( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_biquad( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "biquad-a0" ) )
{
p_sys->a[0] = newval.f_float;
if(!p_sys->a[0])
p_sys->a[0] = 1;
}
if( !strcmp( psz_cmd, "biquad-a1" ) )
p_sys->a[1] = newval.f_float;
if( !strcmp( psz_cmd, "biquad-a2" ) )
p_sys->a[2] = newval.f_float;
if( !strcmp( psz_cmd, "biquad-b0" ) )
p_sys->b[0] = newval.f_float;
if( !strcmp( psz_cmd, "biquad-b1" ) )
p_sys->b[1] = newval.f_float;
if( !strcmp( psz_cmd, "biquad-b2" ) )
p_sys->b[2] = newval.f_float;
if( !strcmp( psz_cmd, "biquad-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_biquad(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_biquad( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->a[0] = var_CreateGetFloat(p_aout,"biquad-a0");
p_sys->a[1] = var_CreateGetFloat(p_aout,"biquad-a1");
p_sys->a[2] = var_CreateGetFloat(p_aout,"biquad-a2");
p_sys->b[0] = var_CreateGetFloat(p_aout,"biquad-b0");
p_sys->b[1] = var_CreateGetFloat(p_aout,"biquad-b1");
p_sys->b[2] = var_CreateGetFloat(p_aout,"biquad-b2");
p_sys->mix = var_CreateGetFloat(p_aout,"biquad-mix");
if(!p_sys->a[0])
p_sys->a[0] = 1;
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "biquad-a0", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-a1", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-a2", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-b0", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-b1", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-b2", paramCallback_biquad, p_sys );
var_AddCallback( p_aout, "biquad-mix", paramCallback_biquad, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_biquad(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"biquad initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_biquad =
{ .filter_audio = Process_biquad, .close = Close_biquad };
p_filter->ops = &filter_ops_biquad;
return VLC_SUCCESS;
}
static void Close_biquad( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,234 @@
/*****************************************************************************
* chorus.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_chorus( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define CHORUS_IN_GAIN_TEXT N_( "in_gain" )
#define CHORUS_IN_GAIN_LONGTEXT N_( "Set the in_gain." )
#define CHORUS_OUT_GAIN_TEXT N_( "out_gain" )
#define CHORUS_OUT_GAIN_LONGTEXT N_( "Set the out_gain (reflected)." )
#define CHORUS_DELAY_TEXT N_( "delays" )
#define CHORUS_DELAY_LONGTEXT N_( "Set the delays in" \
" milliseconds separated by '|'." \
" Typical delay is arround 40ms to 60ms." \
" Allowed " \
" range for each delay is (0 - 1500.0]" )
#define CHORUS_DECAY_TEXT N_( "decays" )
#define CHORUS_DECAY_LONGTEXT N_( "Set deacays in" \
" signals separated by '|'. Allowed range for" \
" each decay is (0 - 1.0]. Default is 0.5." )
#define CHORUS_SPEED_TEXT N_( "speeds" )
#define CHORUS_SPEED_LONGTEXT N_( "Set speeds for" \
" signals separated by '|'. Allowed range for" \
" each decay is (0 - 1.0]. Default is 0.5." )
#define CHORUS_DEPTH_TEXT N_( "depths" )
#define CHORUS_DEPTH_LONGTEXT N_( "Set deacays in" \
" signals separated by '|'. Allowed range for" \
" each decay is (0 - 10]. Default is 2." )
vlc_module_begin()
set_shortname( N_("Chorus") )
set_description( N_("Chorus effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "chorus-in_gain", 0.5, 0.0, 1.0,
CHORUS_IN_GAIN_TEXT, CHORUS_IN_GAIN_LONGTEXT )
add_float_with_range( "chorus-out_gain", 0.5, 0.0, 1.0,
CHORUS_OUT_GAIN_TEXT, CHORUS_OUT_GAIN_LONGTEXT )
add_string( "chorus-delay", "20|40", CHORUS_DELAY_TEXT,
CHORUS_DELAY_LONGTEXT )
add_string( "chorus-decay", "0.4|0.6", CHORUS_DECAY_TEXT,
CHORUS_DECAY_LONGTEXT )
add_string( "chorus-speed", "1|0.5", CHORUS_SPEED_TEXT,
CHORUS_SPEED_LONGTEXT )
add_string( "chorus-depth", "0.5|0.1", CHORUS_DEPTH_TEXT,
CHORUS_DEPTH_LONGTEXT )
add_shortcut("chorus")
set_callback( Open_chorus )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_chorus( vlc_object_t *p_this )
{
struct vlc_memstream ms;
float in_gain;
float out_gain;
char *delay;
char *decay;
char *speed;
char *depth;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
in_gain = var_CreateGetFloat(p_filter,"chorus-in_gain");
out_gain = var_CreateGetFloat(p_filter,"chorus-out_gain");
delay = var_CreateGetString(p_filter,"chorus-delay");
decay = var_CreateGetString(p_filter,"chorus-decay");
speed = var_CreateGetString(p_filter,"chorus-speed");
depth = var_CreateGetString(p_filter,"chorus-depth");
/** Configure filter parameters (filters_descr) **/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "chorus=%f:%f:", in_gain, out_gain);
/* Checking delay Bounds */
if (delay != NULL)
{
char *delay_all = check_Bounds(p_filter, delay, 0, 1500, 1000);
if(!delay_all)
vlc_memstream_printf(&ms, "1000:");
else
vlc_memstream_printf(&ms, "%s:", delay_all);
free(delay_all);
}
else
{
vlc_memstream_printf(&ms, "1000:");
msg_Warn(p_filter, "delay parameter not set. Set to default(1000).");
}
/* Checking decay Bounds */
if (decay != NULL)
{
char *decay_all = check_Bounds(p_filter, decay, 0, 1, 0.5);
if(!decay_all)
vlc_memstream_printf(&ms, "0.5:");
else
vlc_memstream_printf(&ms, "%s:", decay_all);
free(decay_all);
}
else
{
vlc_memstream_printf(&ms, "0.5:");
msg_Warn(p_filter, "decay parameter not set. Set to default(0.5).");
}
/* Checking speed Bounds */
if (speed != NULL)
{
char *speed_all = check_Bounds(p_filter, speed, 0, 1, 0.5);
if(!speed_all)
vlc_memstream_printf(&ms, "0.5:");
else
vlc_memstream_printf(&ms, "%s:", speed_all);
free(speed_all);
}
else
{
vlc_memstream_printf(&ms, "0.5:");
msg_Warn(p_filter, "speed parameter not set. Set to default(0.5).");
}
/* Checking depth Bounds */
if (depth != NULL)
{
char *depth_all = check_Bounds(p_filter, depth, 0, 10, 2);
if(!depth_all)
vlc_memstream_printf(&ms, "2");
else
vlc_memstream_printf(&ms, "%s", depth_all);
free(depth_all);
}
else
{
vlc_memstream_printf(&ms, "2");
msg_Warn(p_filter, "depth parameter not set. Set to default(2).");
}
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter, p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"chorus initialized: %s",ms.ptr);
free( ms.ptr );
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,231 @@
/*****************************************************************************
* compensationdelay.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float mm;
float cm;
float m;
float dry;
float wet;
float temp;
av_filter avf;
}avfilter_sys_t;
static int Open_compensationdelay( vlc_object_t *p_this );
static void Close_compensationdelay( filter_t *p_filter );
static char* string_generate_compensationdelay(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "compensationdelay=%f:%f:%f:%f:%f:%f", p_sys->mm,
p_sys->cm, p_sys->m, p_sys->dry, p_sys->wet, p_sys->temp);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define COMPENSATIONDELAY_MM_TEXT N_( "mm" )
#define COMPENSATIONDELAY_MM_LONGTEXT N_( "Set millimeters distance. This is compensation" \
" distance for fine tuning. Default is 0." )
#define COMPENSATIONDELAY_CM_TEXT N_( "cm" )
#define COMPENSATIONDELAY_CM_LONGTEXT N_( "Set cm distance. This is compensation distance" \
" for tightening distance setup. Default is 0." )
#define COMPENSATIONDELAY_M_TEXT N_( "m" )
#define COMPENSATIONDELAY_M_LONGTEXT N_( "Set meters distance. This is compensation distance" \
" for hard distance setup. Default is 0." )
#define COMPENSATIONDELAY_DRY_TEXT N_( "dry" )
#define COMPENSATIONDELAY_DRY_LONGTEXT N_( "Set dry amount. Amount of unprocessed (dry)" \
" signal. Default is 0." )
#define COMPENSATIONDELAY_WET_TEXT N_( "wet" )
#define COMPENSATIONDELAY_WET_LONGTEXT N_( "Set wet amount. Amount of processed (wet)" \
" signal. Default is 1." )
#define COMPENSATIONDELAY_TEMP_TEXT N_( "temperature" )
#define COMPENSATIONDELAY_TEMP_LONGTEXT N_( "Set temperature in degrees Celsius. This is" \
" the temperature of the environment. Default is 20." )
vlc_module_begin()
set_shortname( N_("CompensationDelay") )
set_description( N_("Delay to compensate differing positions of microphones or speakers.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "compensationdelay-mm", 0, 0, 10,
COMPENSATIONDELAY_MM_TEXT, COMPENSATIONDELAY_MM_LONGTEXT )
add_float_with_range( "compensationdelay-cm", 0, 0, 100,
COMPENSATIONDELAY_CM_TEXT, COMPENSATIONDELAY_CM_LONGTEXT )
add_float_with_range( "compensationdelay-m", 0, 0, 100,
COMPENSATIONDELAY_M_TEXT, COMPENSATIONDELAY_M_LONGTEXT )
add_float_with_range( "compensationdelay-dry", 0.0, 0.0, 1.0,
COMPENSATIONDELAY_DRY_TEXT, COMPENSATIONDELAY_DRY_LONGTEXT )
add_float_with_range( "compensationdelay-wet", 1.0, 0.0, 1.0,
COMPENSATIONDELAY_WET_TEXT, COMPENSATIONDELAY_WET_LONGTEXT )
add_float_with_range( "compensationdelay-temperature", 20, -50, 50,
COMPENSATIONDELAY_TEMP_TEXT, COMPENSATIONDELAY_TEMP_LONGTEXT )
add_shortcut("compensationdelay")
set_callback( Open_compensationdelay )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_compensationdelay( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_compensationdelay( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "compensationdelay-mm" ) )
p_sys->mm = newval.f_float;
if( !strcmp( psz_cmd, "compensationdelay-cm" ) )
p_sys->cm = newval.f_float;
if( !strcmp( psz_cmd, "compensationdelay-m" ) )
p_sys->m = newval.f_float;
if( !strcmp( psz_cmd, "compensationdelay-dry" ) )
p_sys->dry = newval.f_float;
if( !strcmp( psz_cmd, "compensationdelay-wet" ) )
p_sys->wet = newval.f_float;
if( !strcmp( psz_cmd, "compensationdelay-temperature" ) )
p_sys->temp = newval.f_float;
if(string_generate_compensationdelay(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_compensationdelay( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->mm = var_CreateGetFloat(p_aout,"compensationdelay-mm");
p_sys->cm = var_CreateGetFloat(p_aout,"compensationdelay-cm");
p_sys->m = var_CreateGetFloat(p_aout,"compensationdelay-m");
p_sys->dry = var_CreateGetFloat(p_aout,"compensationdelay-dry");
p_sys->wet = var_CreateGetFloat(p_aout,"compensationdelay-wet");
p_sys->temp = var_CreateGetFloat(p_aout,"compensationdelay-temperature");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "compensationdelay-mm", paramCallback_compensationdelay, p_sys );
var_AddCallback( p_aout, "compensationdelay-cm", paramCallback_compensationdelay, p_sys );
var_AddCallback( p_aout, "compensationdelay-m", paramCallback_compensationdelay, p_sys );
var_AddCallback( p_aout, "compensationdelay-dry", paramCallback_compensationdelay, p_sys );
var_AddCallback( p_aout, "compensationdelay-wet", paramCallback_compensationdelay, p_sys );
var_AddCallback( p_aout, "compensationdelay-temperature", paramCallback_compensationdelay, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_compensationdelay(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"compensationdelay initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_compensationdelay =
{ .filter_audio = Process_compensationdelay, .close = Close_compensationdelay };
p_filter->ops = &filter_ops_compensationdelay;
return VLC_SUCCESS;
}
static void Close_compensationdelay( filter_t *p_filter )
{
avfilter_sys_t *p_sys_compensatedelay = p_filter->p_sys;
avfilter_graph_free(&p_sys_compensatedelay->avf.avfilter.filter_graph);
free(p_sys_compensatedelay);
}

View File

@ -0,0 +1,223 @@
/*****************************************************************************
* crossfeed.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float strength;
float range;
float slope;
float level_in;
float level_out;
av_filter avf;
}avfilter_sys_t;
static int Open_crossfeed( vlc_object_t *p_this );
static void Close_crossfeed( filter_t *p_filter );
static char* string_generate_crossfeed(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "crossfeed=strength=%f:range=%f:%f:level_in=%f:"
"level_out=%f", p_sys->strength, p_sys->range, p_sys->slope, p_sys->level_in,
p_sys->level_out);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define CROSSFEED_STRENGTH_TEXT N_( "strength" )
#define CROSSFEED_STRENGTH_LONGTEXT N_( "Set strength of crossfeed. Default is 0.2." \
" Allowed range is from 0 to 1. This sets gain of low shelf filter" \
" for side part of stereo image. Default is -6dB. Max allowed is" \
" -30db when strength is set to 1." )
#define CROSSFEED_RANGE_TEXT N_( "range" )
#define CROSSFEED_RANGE_LONGTEXT N_( "Set soundstage wideness. Default is 0.5. Allowed" \
" range is from 0 to 1. This sets cut off frequency of low shelf" \
" filter. Default is cut off near 1550 Hz. With range set to 1 cut" \
" off frequency is set to 2100 Hz.")
#define CROSSFEED_SLOPE_TEXT N_( "slope" )
#define CROSSFEED_SLOPE_LONGTEXT N_( "Set curve slope of low shelf filter. Default is" \
" 0.5. Allowed range is from 0.01 to 1.")
#define CROSSFEED_LEVEL_IN_TEXT N_( "level_in" )
#define CROSSFEED_LEVEL_IN_LONGTEXT N_( "Set input gain. Default is 0.9." \
" Range is [0 - 1]" )
#define CROSSFEED_LEVEL_OUT_TEXT N_( "level_out" )
#define CROSSFEED_LEVEL_OUT_LONGTEXT N_( "Set output gain. Default is 1." \
" Range is [0 - 1]" )
vlc_module_begin()
set_shortname( N_("Crossfeed") )
set_description( N_("Headphone crossfeed.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "crossfeed-strength", 0.2, 0, 1,
CROSSFEED_STRENGTH_TEXT, CROSSFEED_STRENGTH_LONGTEXT )
add_float_with_range( "crossfeed-range", 0.5, 0, 1,
CROSSFEED_RANGE_TEXT, CROSSFEED_RANGE_LONGTEXT )
add_float_with_range( "crossfeed-slope", 0.5, 0.01, 1,
CROSSFEED_SLOPE_TEXT, CROSSFEED_SLOPE_LONGTEXT )
add_float_with_range( "crossfeed-level_in", 0.9, 0, 1,
CROSSFEED_LEVEL_IN_TEXT, CROSSFEED_LEVEL_IN_LONGTEXT )
add_float_with_range( "crossfeed-level_out", 1, 0, 1,
CROSSFEED_LEVEL_OUT_TEXT, CROSSFEED_LEVEL_OUT_LONGTEXT )
add_shortcut("crossfeed")
set_callback( Open_crossfeed )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_crossfeed( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_crossfeed( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "crossfeed-strength" ) )
p_sys->strength = newval.f_float;
if( !strcmp( psz_cmd, "crossfeed-range" ) )
p_sys->range = newval.f_float;
if( !strcmp( psz_cmd, "crossfeed-slope" ) )
p_sys->slope = newval.f_float;
if( !strcmp( psz_cmd, "crossfeed-level_in" ) )
p_sys->level_in = newval.f_float;
if( !strcmp( psz_cmd, "crossfeed-level_out" ) )
p_sys->level_out = newval.f_float;
if(string_generate_crossfeed(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_crossfeed( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->strength = var_CreateGetFloat(p_aout,"crossfeed-strength");
p_sys->range = var_CreateGetFloat(p_aout,"crossfeed-range");
p_sys->slope = var_CreateGetFloat(p_aout,"crossfeed-slope");
p_sys->level_in = var_CreateGetFloat(p_aout,"crossfeed-level_in");
p_sys->level_out = var_CreateGetFloat(p_aout,"crossfeed-level_out");
p_sys->avf.params_changed = false;
vlc_mutex_init(&p_sys->avf.lock);
var_AddCallback( p_aout, "crossfeed-strength", paramCallback_crossfeed, p_sys );
var_AddCallback( p_aout, "crossfeed-range", paramCallback_crossfeed, p_sys );
var_AddCallback( p_aout, "crossfeed-slope", paramCallback_crossfeed, p_sys );
var_AddCallback( p_aout, "crossfeed-level_in", paramCallback_crossfeed, p_sys );
var_AddCallback( p_aout, "crossfeed-level_out", paramCallback_crossfeed, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_crossfeed(p_sys), p_filter, &p_sys->avf.avfilter) <0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"crossfeed initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_crossfeed =
{ .filter_audio = Process_crossfeed, .close = Close_crossfeed };
p_filter->ops = &filter_ops_crossfeed;
return VLC_SUCCESS;
}
static void Close_crossfeed( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,175 @@
/*****************************************************************************
* crystalizer.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float intensity;
av_filter avf;
}avfilter_sys_t;
static int Open_crystalizer( vlc_object_t *p_this );
static void Close_crystalizer( filter_t *p_filter );
static char* string_generate_crystalizer(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "crystalizer=i=%f", p_sys->intensity);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define CRYSTALIZER_I_TEXT N_( "intensity" )
#define CRYSTALIZER_I_LONGTEXT N_( "Set the intensity of effect (default: 2.0)." \
" Must be in range between 0 (unchanged sound) to 10.0" \
" (maximum effect)." )
#define CRYSTALIZER_C_TEXT N_( "clipping" )
#define CRYSTALIZER_C_LONGTEXT N_( "Enable clipping. By default is enabled." )
vlc_module_begin()
set_shortname( N_("Crystalizer") )
set_description("Noise sharpening")
set_help( N_("Linearly increases differences betweeen each audio sample.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "crystalizer-i", 2.0, 0, 9,
CRYSTALIZER_I_TEXT, CRYSTALIZER_I_LONGTEXT )
add_shortcut("crystalizer")
set_callback( Open_crystalizer )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_crystalizer( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 0;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_crystalizer( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "crystalizer-i" ) )
p_sys->intensity = newval.f_float;
if(string_generate_crystalizer(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_crystalizer( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->intensity = var_CreateGetFloat(p_aout,"crystalizer-i");
p_sys->avf.params_changed = false;
vlc_mutex_init(&p_sys->avf.lock);
var_AddCallback( p_aout, "crystalizer-i", paramCallback_crystalizer, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_crystalizer(p_sys), p_filter, &p_sys->avf.avfilter) <0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"crystalizer initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_crystalizer =
{ .filter_audio = Process_crystalizer, .close = Close_crystalizer };
p_filter->ops = &filter_ops_crystalizer;
return VLC_SUCCESS;
}
static void Close_crystalizer( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,212 @@
/*****************************************************************************
* deesser.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float intensity;
float m;
float freq;
char* mode;
av_filter avf;
}avfilter_sys_t;
static int Open_deesser( vlc_object_t *p_this );
static void Close_deesser( filter_t *p_filter );
static char* string_generate_deesser(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "deesser=i=%f:m=%f:f=%f:s=%s", p_sys->intensity,
p_sys->m, p_sys->freq, p_sys->mode);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define DEESSER_INTENSITY_TEXT N_( "i" )
#define DEESSER_INTENSITY_LONGTEXT N_( "Set intensity for triggering de-essing." \
" Allowed range is from 0 to 1. Default is 0." )
#define DEESSER_M_TEXT N_( "m" )
#define DEESSER_M_LONGTEXT N_( "Set amount of ducking on treble part of sound." \
" Allowed range is from 0 to 1. Default is 0.5." )
#define DEESSER_F_TEXT N_( "f" )
#define DEESSER_F_LONGTEXT N_( "How much of original frequency content to keep" \
" when de-essing. Allowed range is from 0 to 1. Default is 0.5." )
#define DEESSER_MODE_TEXT N_( "output mode" )
#define DEESSER_MODE_LONGTEXT N_( "Set the output mode." )
vlc_module_begin()
set_shortname( N_("DeEsser") )
set_description( N_("Audio de-essing") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "deesser-i", 0, 0.0, 1.0,
DEESSER_INTENSITY_TEXT, DEESSER_INTENSITY_LONGTEXT )
add_float_with_range( "deesser-m", 0.5, 0.0, 1.0,
DEESSER_M_TEXT, DEESSER_M_LONGTEXT )
add_float_with_range( "deesser-f", 0.5, 0.0, 1.0,
DEESSER_F_TEXT, DEESSER_F_LONGTEXT )
add_string( "deesser-mode", "o", DEESSER_MODE_TEXT,
DEESSER_MODE_LONGTEXT )
change_string_list( deesser_mode_list, deesser_mode_list_text )
add_shortcut( "deesser" )
set_callback( Open_deesser )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_deesser( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_deesser( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "deesser-i" ) )
p_sys->intensity = newval.f_float;
if( !strcmp( psz_cmd, "deesser-m" ) )
p_sys->m = newval.f_float;
if( !strcmp( psz_cmd, "deesser-f" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "deesser-mode" ) )
{
free(p_sys->mode);
p_sys->mode = strdup(newval.psz_string);
if(p_sys->mode == NULL)
return VLC_EGENERIC;
}
if(string_generate_deesser(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_deesser( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->intensity = var_CreateGetFloat(p_aout,"deesser-i");
p_sys->m = var_CreateGetFloat(p_aout,"deesser-m");
p_sys->freq = var_CreateGetFloat(p_aout,"deesser-f");
p_sys->mode = var_CreateGetString(p_aout,"deesser-mode");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "deesser-i", paramCallback_deesser, p_sys );
var_AddCallback( p_aout, "deesser-m", paramCallback_deesser, p_sys );
var_AddCallback( p_aout, "deesser-f", paramCallback_deesser, p_sys );
var_AddCallback( p_aout, "deesser-mode", paramCallback_deesser, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_deesser(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"deesser initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_deesser =
{ .filter_audio = Process_deesser, .close = Close_deesser };
p_filter->ops = &filter_ops_deesser;
return VLC_SUCCESS;
}
static void Close_deesser( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,187 @@
/*****************************************************************************
* extrastereo.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float m;
bool c;
av_filter avf;
}avfilter_sys_t;
static int Open_extrastereo( vlc_object_t *p_this );
static void Close_extrastereo( filter_t *p_filter );
static char* string_generate_extrastereo(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "extrastereo=m=%f:", p_sys->m);
if(p_sys->c)
vlc_memstream_printf(&p_sys->avf.str, "c=1");
else
vlc_memstream_printf(&p_sys->avf.str, "c=0");
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define EXTRASTEREO_M_TEXT N_( "difference coefficient" )
#define EXTRASTEREO_M_LONGTEXT N_( "Sets the difference coefficient" \
" (default: 2.5). 0.0 means mono sound (average of both" \
" channels), with 1.0 sound will be unchanged, with -1.0" \
" left and right channels will be swapped." )
#define EXTRASTEREO_C_TEXT N_( "clipping" )
#define EXTRASTEREO_C_LONGTEXT N_( "Enable clipping. By default is enabled." )
vlc_module_begin()
set_shortname( N_("Extrastereo") )
set_description("Psuedo live effect")
set_help( N_("Linearly increases the difference between left and right" \
" channels which adds some sort of 'live' effect to playback.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "extrastereo-m", 2.5, -10, 10,
EXTRASTEREO_M_TEXT, EXTRASTEREO_M_LONGTEXT )
add_bool( "extrastereo-c", true, EXTRASTEREO_C_TEXT,
EXTRASTEREO_C_LONGTEXT )
add_shortcut("extrastereo")
set_callback( Open_extrastereo )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_extrastereo( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 0;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_extrastereo( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "extrastereo-m" ) )
p_sys->m = newval.f_float;
if(string_generate_extrastereo(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_extrastereo( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->m = var_CreateGetFloat(p_aout,"extrastereo-m");
p_sys->c = var_CreateGetBool(p_aout,"extrastereo-c");
p_sys->avf.params_changed = false;
vlc_mutex_init(&p_sys->avf.lock);
var_AddCallback( p_aout, "extrastereo-m", paramCallback_extrastereo, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_extrastereo(p_sys), p_filter, &p_sys->avf.avfilter) <0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"extrastereo initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_extrastereo =
{ .filter_audio = Process_extrastereo, .close = Close_extrastereo };
p_filter->ops = &filter_ops_extrastereo;
return VLC_SUCCESS;
}
static void Close_extrastereo( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,267 @@
/*****************************************************************************
* flanger.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float delay;
float depth;
float regen;
float width;
float speed;
char* shape;
float phase;
char* interp;
av_filter avf;
}avfilter_sys_t;
static int Open_flanger( vlc_object_t *p_this );
static void Close_flanger( filter_t *p_filter );
static char* string_generate_flanger(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "flanger=%f:%f:%f:%f:%f:%s:%f:%s",
p_sys->delay, p_sys->depth, p_sys->regen, p_sys->width, p_sys->speed,
p_sys->shape, p_sys->phase, p_sys->interp);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define FLANGER_DELAY_TEXT N_( "delay" )
#define FLANGER_DELAY_LONGTEXT N_( "Set base delay in milliseconds. Range from" \
" 0 to 30. Default value is 0." )
#define FLANGER_DEPTH_TEXT N_( "depth" )
#define FLANGER_DEPTH_LONGTEXT N_( "Set added sweep delay in milliseconds. Range" \
" from 0 to 10. Default value is 2." )
#define FLANGER_REGEN_TEXT N_( "regeneration" )
#define FLANGER_REGEN_LONGTEXT N_( "Set percentage regeneration (delayed signal" \
" feedback). Range from -95 to 95. Default value is 0." )
#define FLANGER_WIDTH_TEXT N_( "width" )
#define FLANGER_WIDTH_LONGTEXT N_( "Set percentage of delayed signal mixed with" \
" original. Range from 0 to 100. Default value is 71." )
#define FLANGER_SPEED_TEXT N_( "speed" )
#define FLANGER_SPEED_LONGTEXT N_( "Set sweeps per second (Hz). Range from 0.1" \
" to 10. Default value is 0.5." )
#define FLANGER_SHAPE_TEXT N_( "shape" )
#define FLANGER_SHAPE_LONGTEXT N_( "Set swept wave shape, can be triangular or" \
" sinusoidal. Default value is sinusoidal." )
#define FLANGER_PHASE_TEXT N_( "phase" )
#define FLANGER_PHASE_LONGTEXT N_( "Set swept wave percentage-shift for multi" \
" channel. Range from 0 to 100. Default value is 25." )
#define FLANGER_INTERP_TEXT N_( "interp" )
#define FLANGER_INTERP_LONGTEXT N_( "Set delay-line interpolation, linear or" \
" quadratic. Default is linear." )
vlc_module_begin()
set_shortname( N_("Flanger") )
set_description( N_("Flanging effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "flanger-delay", 0.0, 0.0, 30.0,
FLANGER_DELAY_TEXT, FLANGER_DELAY_LONGTEXT )
add_float_with_range( "flanger-depth", 2.0, 0.0, 10.0,
FLANGER_DEPTH_TEXT, FLANGER_DEPTH_LONGTEXT )
add_float_with_range( "flanger-regen", 0.0, -95.0, 95.0,
FLANGER_REGEN_TEXT, FLANGER_REGEN_LONGTEXT )
add_float_with_range( "flanger-width", 71.0, 0.0, 100.0,
FLANGER_WIDTH_TEXT, FLANGER_WIDTH_LONGTEXT )
add_float_with_range( "flanger-speed", 0.5, 0.1, 10.0,
FLANGER_SPEED_TEXT, FLANGER_SPEED_LONGTEXT )
add_string( "flanger-shape", "sinusoidal", FLANGER_SHAPE_TEXT,
FLANGER_SHAPE_LONGTEXT )
change_string_list( flanger_shape_list, flanger_shape_list_text )
add_float_with_range( "flanger-phase", 25.0, 0.0, 100.0,
FLANGER_PHASE_TEXT, FLANGER_PHASE_LONGTEXT )
add_string( "flanger-interp", "linear", FLANGER_INTERP_TEXT,
FLANGER_INTERP_LONGTEXT )
change_string_list( flanger_interp_list, flanger_interp_list_text )
add_shortcut("flanger")
set_callback( Open_flanger )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_flanger( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_flanger( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "flanger-delay" ) )
p_sys->delay = newval.f_float;
if( !strcmp( psz_cmd, "flanger-depth" ) )
p_sys->depth = newval.f_float;
if( !strcmp( psz_cmd, "flanger-regen" ) )
p_sys->regen = newval.f_float;
if( !strcmp( psz_cmd, "flanger-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "flanger-speed" ) )
p_sys->speed = newval.f_float;
if( !strcmp( psz_cmd, "flanger-shape" ) )
{
free(p_sys->shape);
p_sys->shape = strdup(newval.psz_string);
if(p_sys->shape == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "flanger-phase" ) )
p_sys->phase = newval.f_float;
if( !strcmp( psz_cmd, "flanger-interp" ) )
{
free(p_sys->interp);
p_sys->interp = strdup(newval.psz_string);
if(p_sys->interp == NULL)
return VLC_EGENERIC;
}
if(string_generate_flanger(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_flanger( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->delay = var_CreateGetFloat(p_aout,"flanger-delay");
p_sys->depth = var_CreateGetFloat(p_aout,"flanger-depth");
p_sys->regen = var_CreateGetFloat(p_aout,"flanger-regen");
p_sys->width = var_CreateGetFloat(p_aout,"flanger-width");
p_sys->speed = var_CreateGetFloat(p_aout,"flanger-speed");
p_sys->shape = var_CreateGetString(p_aout,"flanger-shape");
p_sys->phase = var_CreateGetFloat(p_aout,"flanger-phase");
p_sys->interp = var_CreateGetString(p_aout,"flanger-interp");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "flanger-delay", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-depth", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-regen", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-width", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-speed", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-shape", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-phase", paramCallback_flanger, p_sys );
var_AddCallback( p_aout, "flanger-interp", paramCallback_flanger, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_flanger(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"flanger initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_flanger =
{ .filter_audio = Process_flanger, .close = Close_flanger };
p_filter->ops = &filter_ops_flanger;
return VLC_SUCCESS;
}
static void Close_flanger( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,263 @@
/*****************************************************************************
* haas.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_haas( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static const int haas_middle_src_vlclist[] = { 0, 1, 2, 3 };
static const char *const haas_middle_src_vlctext[] =
{
"left",
"right",
"mid",
"side",
};
#define HAAS_LEVEL_IN_TEXT N_( "level_in" )
#define HAAS_LEVEL_IN_LONGTEXT N_( "Set input level. By default is 1, or 0dB" )
#define HAAS_LEVEL_OUT_TEXT N_( "level_out" )
#define HAAS_LEVEL_OUT_LONGTEXT N_( "Set output level. By default is 1, or 0dB." )
#define HAAS_SIDE_GAIN_TEXT N_( "side_gain" )
#define HAAS_SIDE_GAIN_LONGTEXT N_( "Set gain applied to side part of signal." \
" By default is 1." )
#define HAAS_MIDDLE_SRC_TEXT N_( "middle_source" )
#define HAAS_MIDDLE_SRC_LONGTEXT N_( "Set kind of middle source." )
#define HAAS_MIDDLE_PHASE_TEXT N_( "middle_phase" )
#define HAAS_MIDDLE_PHASE_LONGTEXT N_( "Change middle phase. By default is disabled." )
#define HAAS_LEFT_DELAY_TEXT N_( "left_delay" )
#define HAAS_LEFT_DELAY_LONGTEXT N_( "Set left channel delay. By default is 2.05 milliseconds." )
#define HAAS_LEFT_BAL_TEXT N_( "left_balance" )
#define HAAS_LEFT_BAL_LONGTEXT N_( "Set left channel balance. By default is -1." )
#define HAAS_LEFT_GAIN_TEXT N_( "left_gain" )
#define HAAS_LEFT_GAIN_LONGTEXT N_( "Set left channel gain. By default is 1." )
#define HAAS_LEFT_PHASE_TEXT N_( "left_phase" )
#define HAAS_LEFT_PHASE_LONGTEXT N_( "Change left phase. By default is disabled." )
#define HAAS_RIGHT_DELAY_TEXT N_( "right_delay" )
#define HAAS_RIGHT_DELAY_LONGTEXT N_( "Set right channel delay. By default is 2.05 milliseconds." )
#define HAAS_RIGHT_BAL_TEXT N_( "right_balance" )
#define HAAS_RIGHT_BAL_LONGTEXT N_( "Set right channel balance. By default is -1." )
#define HAAS_RIGHT_GAIN_TEXT N_( "right_gain" )
#define HAAS_RIGHT_GAIN_LONGTEXT N_( "Set right channel gain. By default is 1." )
#define HAAS_RIGHT_PHASE_TEXT N_( "right_phase" )
#define HAAS_RIGHT_PHASE_LONGTEXT N_( "Change right phase. By default is disabled." )
vlc_module_begin()
set_shortname( N_("Haas") )
set_description( N_("Haas effect") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "level_in", 1, 0.015625, 64,
HAAS_LEVEL_IN_TEXT, HAAS_LEVEL_IN_LONGTEXT )
add_float_with_range( "level_out", 1, 0.015625, 64,
HAAS_LEVEL_OUT_TEXT, HAAS_LEVEL_OUT_LONGTEXT )
add_float_with_range( "side_gain", 1, 0.015625, 64,
HAAS_SIDE_GAIN_TEXT, HAAS_SIDE_GAIN_LONGTEXT )
add_integer( "middle_source", 2,
HAAS_MIDDLE_SRC_TEXT, HAAS_MIDDLE_SRC_LONGTEXT )
change_integer_list( haas_middle_src_vlclist,
haas_middle_src_vlctext )
add_bool( "middle_phase", false, HAAS_MIDDLE_PHASE_TEXT,
HAAS_MIDDLE_PHASE_LONGTEXT )
add_float_with_range( "left_delay", 2.05, 0, 40,
HAAS_LEFT_DELAY_TEXT, HAAS_LEFT_DELAY_LONGTEXT )
add_float_with_range( "left_balance", -1, -1, 1,
HAAS_LEFT_BAL_TEXT, HAAS_LEFT_BAL_LONGTEXT )
add_float_with_range( "left_gain", 1, 0.015625, 64,
HAAS_LEFT_GAIN_TEXT, HAAS_LEFT_GAIN_LONGTEXT )
add_bool( "left_phase", false, HAAS_LEFT_PHASE_TEXT,
HAAS_LEFT_PHASE_LONGTEXT )
add_float_with_range( "right_delay", 2.12, 0, 40,
HAAS_RIGHT_DELAY_TEXT, HAAS_RIGHT_DELAY_LONGTEXT )
add_float_with_range( "right_balance", 1, -1, 1,
HAAS_RIGHT_BAL_TEXT, HAAS_RIGHT_BAL_LONGTEXT )
add_float_with_range( "right_gain", 1, 0.015625, 64,
HAAS_RIGHT_GAIN_TEXT, HAAS_RIGHT_GAIN_LONGTEXT )
add_bool( "right_phase", false, HAAS_RIGHT_PHASE_TEXT,
HAAS_RIGHT_PHASE_LONGTEXT )
add_shortcut("haas")
set_callback( Open_haas )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_haas( vlc_object_t *p_this )
{
struct vlc_memstream ms;
float level_in;
float level_out;
float side_gain;
int middle_src;
bool mid_phase;
float left_delay;
float left_bal;
float left_gain;
bool left_phase;
float right_delay;
float right_bal;
float right_gain;
bool right_phase;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
level_in = var_CreateGetFloat(p_filter,"level_in");
level_out = var_CreateGetFloat(p_filter,"level_out");
side_gain = var_CreateGetFloat(p_filter,"side_gain");
middle_src = var_CreateGetInteger(p_filter,"middle_source");
mid_phase = var_CreateGetBool(p_filter,"middle_phase");
left_delay = var_CreateGetFloat(p_filter,"left_delay");
left_bal = var_CreateGetFloat(p_filter,"left_balance");
left_gain = var_CreateGetFloat(p_filter,"left_gain");
left_phase = var_CreateGetBool(p_filter,"left_phase");
right_delay = var_CreateGetFloat(p_filter,"right_delay");
right_bal = var_CreateGetFloat(p_filter,"right_balance");
right_gain = var_CreateGetFloat(p_filter,"right_gain");
right_phase = var_CreateGetBool(p_filter,"right_phase");
/** Configure filter parameters (filters_descr) **/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "haas=%f:%f:%f:", level_in, level_out, side_gain);
switch (middle_src)
{
case 0:
vlc_memstream_printf(&ms, "left:");
break;
case 1:
vlc_memstream_printf(&ms, "right:");
break;
case 2:
vlc_memstream_printf(&ms, "mid:");
break;
case 3:
vlc_memstream_printf(&ms, "side:");
break;
default:
break;
}
vlc_memstream_printf(&ms, "middle_phase=");
if(mid_phase)
vlc_memstream_printf(&ms, "1:");
else
vlc_memstream_printf(&ms, "0:");
vlc_memstream_printf(&ms, "left_delay=%f:left_balance=%f:left_gain=%f:"
"left_phase=", left_delay, left_bal, left_gain);
if(left_phase)
vlc_memstream_printf(&ms, "1:");
else
vlc_memstream_printf(&ms, "0:");
vlc_memstream_printf(&ms, "right_delay=%f:right_balance=%f:right_gain=%f:"
"right_phase=", right_delay, right_bal, right_gain);
if(right_phase)
vlc_memstream_printf(&ms, "1");
else
vlc_memstream_printf(&ms, "0");
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter, p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"hass initialized: %s",ms.ptr);
free(ms.ptr);
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,223 @@
/*****************************************************************************
* highpass.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float freq;
float poles;
char* width_type;
float width;
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_highpass( vlc_object_t *p_this );
static void Close_highpass( filter_t *p_filter );
static char* string_generate_highpass(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "highpass=f=%f:p=%f:t=%s:w=%f:m=%f",
p_sys->freq, p_sys->poles, p_sys->width_type, p_sys->width, p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define HIGHPASS_FREQUENCY_TEXT N_( "frequency" )
#define HIGHPASS_FREQUENCY_LONGTEXT N_( "Set frequency in Hz. Default is 3000. Range is [0-10000]" )
#define HIGHPASS_POLES_TEXT N_( "poles" )
#define HIGHPASS_POLES_LONGTEXT N_( "Set number of poles. Default is 2." \
" The filter can be either single-pole or double-pole" )
#define HIGHPASS_WIDTH_TYPE_TEXT N_( "width type" )
#define HIGHPASS_WIDTH_TYPE_LONGTEXT N_( "Set method to specify band-width of filter." )
#define HIGHPASS_WIDTH_TEXT N_( "width" )
#define HIGHPASS_WIDTH_LONGTEXT N_( "Specify the band-width of a filter in width_type units." \
" Applies only to double-pole filter. Default 0.7" )
#define HIGHPASS_MIX_TEXT N_( "mix" )
#define HIGHPASS_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Highpass") )
set_description( N_("Highpass filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "highpass-frequency", 500, 0.1, 10000,
HIGHPASS_FREQUENCY_TEXT, HIGHPASS_FREQUENCY_LONGTEXT )
add_float_with_range( "highpass-poles", 2, 1, 2,
HIGHPASS_POLES_TEXT, HIGHPASS_POLES_LONGTEXT )
add_string( "highpass-width-type", "h", HIGHPASS_WIDTH_TYPE_TEXT,
HIGHPASS_WIDTH_TYPE_LONGTEXT )
change_string_list( lowpass_width_type_list, lowpass_width_type_list_text )
add_float_with_range( "highpass-width", 0.7, 0.1, 1000,
HIGHPASS_WIDTH_TEXT, HIGHPASS_WIDTH_LONGTEXT )
add_float_with_range( "highpass-mix", 1, 0, 1,
HIGHPASS_MIX_TEXT, HIGHPASS_MIX_LONGTEXT )
add_shortcut("highpass")
set_callback( Open_highpass )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_highpass( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_highpass( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "highpass-frequency" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "highpass-poles" ) )
p_sys->poles = newval.f_float;
if( !strcmp( psz_cmd, "highpass-width-type" ) )
{
free(p_sys->width_type);
p_sys->width_type = strdup(newval.psz_string);
if(p_sys->width_type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "highpass-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "highpass-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_highpass(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_highpass( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->freq = var_CreateGetFloat(p_aout,"highpass-frequency");
p_sys->poles = var_CreateGetFloat(p_aout,"highpass-poles");
p_sys->width_type = var_CreateGetString(p_aout,"highpass-width-type");
p_sys->width = var_CreateGetFloat(p_aout,"highpass-width");
p_sys->mix = var_CreateGetFloat(p_aout,"highpass-mix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "highpass-frequency", paramCallback_highpass, p_sys );
var_AddCallback( p_aout, "highpass-poles", paramCallback_highpass, p_sys );
var_AddCallback( p_aout, "highpass-width-type", paramCallback_highpass, p_sys );
var_AddCallback( p_aout, "highpass-width", paramCallback_highpass, p_sys );
var_AddCallback( p_aout, "highpass-mix", paramCallback_highpass, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_highpass(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"highpass initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_highpass =
{ .filter_audio = Process_highpass, .close = Close_highpass };
p_filter->ops = &filter_ops_highpass;
return VLC_SUCCESS;
}
static void Close_highpass( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,223 @@
/*****************************************************************************
* lowpass.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float freq;
float poles;
char* width_type;
float width;
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_lowpass( vlc_object_t *p_this );
static void Close_lowpass( filter_t *p_filter );
static char* string_generate_lowpass(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "lowpass=f=%f:p=%f:t=%s:w=%f:m=%f",
p_sys->freq, p_sys->poles, p_sys->width_type, p_sys->width, p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define LOWPASS_FREQUENCY_TEXT N_( "frequency" )
#define LOWPASS_FREQUENCY_LONGTEXT N_( "Set frequency in Hz. Default is 500. Range is [0-10000]" )
#define LOWPASS_POLES_TEXT N_( "poles" )
#define LOWPASS_POLES_LONGTEXT N_( "Set number of poles. Default is 2." \
" The filter can be either single-pole or double-pole" )
#define LOWPASS_WIDTH_TYPE_TEXT N_( "width type" )
#define LOWPASS_WIDTH_TYPE_LONGTEXT N_( "Set method to specify band-width of filter." )
#define LOWPASS_WIDTH_TEXT N_( "width" )
#define LOWPASS_WIDTH_LONGTEXT N_( "Specify the band-width of a filter in width_type units." \
" Applies only to double-pole filter. Default 0.7" )
#define LOWPASS_MIX_TEXT N_( "mix" )
#define LOWPASS_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Lowpass") )
set_description( N_("Lowpass filter") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "lowpass-frequency", 500, 0.1, 10000,
LOWPASS_FREQUENCY_TEXT, LOWPASS_FREQUENCY_LONGTEXT )
add_float_with_range( "lowpass-poles", 2, 1, 2,
LOWPASS_POLES_TEXT, LOWPASS_POLES_LONGTEXT )
add_string( "lowpass-width-type", "h", LOWPASS_WIDTH_TYPE_TEXT,
LOWPASS_WIDTH_TYPE_LONGTEXT )
change_string_list( lowpass_width_type_list, lowpass_width_type_list_text )
add_float_with_range( "lowpass-width", 0.7, 0.1, 1000,
LOWPASS_WIDTH_TEXT, LOWPASS_WIDTH_LONGTEXT )
add_float_with_range( "lowpass-mix", 1, 0, 1,
LOWPASS_MIX_TEXT, LOWPASS_MIX_LONGTEXT )
add_shortcut("lowpass")
set_callback( Open_lowpass )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_lowpass( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_lowpass( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "lowpass-frequency" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "lowpass-poles" ) )
p_sys->poles = newval.f_float;
if( !strcmp( psz_cmd, "lowpass-width-type" ) )
{
free(p_sys->width_type);
p_sys->width_type = strdup(newval.psz_string);
if(p_sys->width_type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "lowpass-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "lowpass-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_lowpass(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_lowpass( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->freq = var_CreateGetFloat(p_aout,"lowpass-frequency");
p_sys->poles = var_CreateGetFloat(p_aout,"lowpass-poles");
p_sys->width_type = var_CreateGetString(p_aout,"lowpass-width-type");
p_sys->width = var_CreateGetFloat(p_aout,"lowpass-width");
p_sys->mix = var_CreateGetFloat(p_aout,"lowpass-mix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "lowpass-frequency", paramCallback_lowpass, p_sys );
var_AddCallback( p_aout, "lowpass-poles", paramCallback_lowpass, p_sys );
var_AddCallback( p_aout, "lowpass-width-type", paramCallback_lowpass, p_sys );
var_AddCallback( p_aout, "lowpass-width", paramCallback_lowpass, p_sys );
var_AddCallback( p_aout, "lowpass-mix", paramCallback_lowpass, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_lowpass(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"lowpass initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_lowpass =
{ .filter_audio = Process_lowpass, .close = Close_lowpass };
p_filter->ops = &filter_ops_lowpass;
return VLC_SUCCESS;
}
static void Close_lowpass( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,109 @@
/*****************************************************************************
* mcompand.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
static int Open_mcompand( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define MCOMPAND_TEXT N_( "Mcompand" )
#define MCOMPAND_LONGTEXT N_( "Multiband Compress or expand" )
vlc_module_begin()
set_shortname( N_(MCOMPAND_TEXT) )
set_description( N_(MCOMPAND_LONGTEXT) )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_shortcut( "mcompand" )
set_callback( Open_mcompand )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static int Open_mcompand( vlc_object_t *p_this )
{
struct vlc_memstream ms;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
/** Configure filter parameters (filter_desc)**/
if( vlc_memstream_open( &ms ) != 0 )
{
free(p_sys);
return VLC_EGENERIC;
}
vlc_memstream_printf(&ms, "mcompand");
if(vlc_memstream_close(&ms))
{
free(p_sys);
return VLC_EGENERIC;
}
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(ms.ptr, p_filter ,p_sys) <0)
{
avfilter_graph_free(&p_sys->filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"mcompand initialized: %s",ms.ptr);
free( ms.ptr );
p_sys->frame_len_flag = 1;
static const struct vlc_filter_operations filter_ops =
{ .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
}

View File

@ -0,0 +1,224 @@
/*****************************************************************************
* treble.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float gain;
float freq;
char* width_type;
float width;
float mix;
av_filter avf;
}avfilter_sys_t;
static int Open_treble( vlc_object_t *p_this );
static void Close_treble( filter_t *p_filter );
static char* string_generate_treble(avfilter_sys_t *p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "treble=g=%f:f=%f:t=%s:w=%f:m=%f", p_sys->gain,
p_sys->freq, p_sys->width_type, p_sys->width, p_sys->mix);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define TREBLE_GAIN_TEXT N_( "gain" )
#define TREBLE_GAIN_LONGTEXT N_( "Set gain Its useful range is about -20 (for a large cut) to +20" \
" (for a large boost). Beware of clipping when using a positive gain." )
#define TREBLE_FREQUENCY_TEXT N_( "frequency" )
#define TREBLE_FREQUENCY_LONGTEXT N_( "Set the filters central frequency and so can be used to" \
" extend or reduce the frequency range to be boosted or cut." \
" The default value is 3000 Hz." )
#define TREBLE_WIDTH_TYPE_TEXT N_( "width type" )
#define TREBLE_WIDTH_TYPE_LONGTEXT N_( "Set method to specify band-width of filter." )
#define TREBLE_WIDTH_TEXT N_( "width" )
#define TREBLE_WIDTH_LONGTEXT N_( "Determine how steep is the filters shelf transition." )
#define TREBLE_MIX_TEXT N_( "mix" )
#define TREBLE_MIX_LONGTEXT N_( "Set mixing amount. Default is 1." \
" Range is [0 - 1]")
vlc_module_begin()
set_shortname( N_("Treble") )
set_description( N_("Boost or cut treble frequencies") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "treble-gain", 0, -150, 50,
TREBLE_GAIN_TEXT, TREBLE_GAIN_LONGTEXT )
add_float_with_range( "treble-frequency", 500, 0.1, 10000,
TREBLE_FREQUENCY_TEXT, TREBLE_FREQUENCY_LONGTEXT )
add_string( "treble-width-type", "h", TREBLE_WIDTH_TYPE_TEXT,
TREBLE_WIDTH_TYPE_LONGTEXT )
change_string_list( lowpass_width_type_list, lowpass_width_type_list_text )
add_float_with_range( "treble-width", 0.7, 0.1, 1000,
TREBLE_WIDTH_TEXT, TREBLE_WIDTH_LONGTEXT )
add_float_with_range( "treble-mix", 1, 0, 1,
TREBLE_MIX_TEXT, TREBLE_MIX_LONGTEXT )
add_shortcut("treble")
set_callback( Open_treble )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_treble( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_treble( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "treble-gain" ) )
p_sys->gain = newval.f_float;
if( !strcmp( psz_cmd, "treble-frequency" ) )
p_sys->freq = newval.f_float;
if( !strcmp( psz_cmd, "treble-width-type" ) )
{
free(p_sys->width_type);
p_sys->width_type = strdup(newval.psz_string);
if(p_sys->width_type == NULL)
return VLC_EGENERIC;
}
if( !strcmp( psz_cmd, "treble-width" ) )
p_sys->width = newval.f_float;
if( !strcmp( psz_cmd, "treble-mix" ) )
p_sys->mix = newval.f_float;
if(string_generate_treble(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_treble( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->gain = var_CreateGetFloat(p_aout,"treble-gain");
p_sys->freq = var_CreateGetFloat(p_aout,"treble-frequency");
p_sys->width_type = var_CreateGetString(p_aout,"treble-width-type");
p_sys->width = var_CreateGetFloat(p_aout,"treble-width");
p_sys->mix = var_CreateGetFloat(p_aout,"treble-mix");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "treble-gain", paramCallback_treble, p_sys );
var_AddCallback( p_aout, "treble-frequency", paramCallback_treble, p_sys );
var_AddCallback( p_aout, "treble-width-type", paramCallback_treble, p_sys );
var_AddCallback( p_aout, "treble-width", paramCallback_treble, p_sys );
var_AddCallback( p_aout, "treble-mix", paramCallback_treble, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_treble(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"treble initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_treble =
{ .filter_audio = Process_treble, .close = Close_treble };
p_filter->ops = &filter_ops_treble;
return VLC_SUCCESS;
}
static void Close_treble( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,184 @@
/*****************************************************************************
* avaudio_filters.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float mfreq;
float mdepth;
av_filter avf;
}avfilter_sys_t;
static int Open_tremolo( vlc_object_t *p_this );
static void Close_tremolo( filter_t *p_filter );
static char* string_generate_tremolo(avfilter_sys_t* p_sys)
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "tremolo=%f:%f", p_sys->mfreq, p_sys->mdepth);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define TREMOLO_MOD_FREQUENCY_TEXT N_( "mod frequency" )
#define TREMOLO_MOD_FREQUENCY_LONGTEXT N_( "Modulation frequency in Hertz. Modulation frequencies" \
" in the subharmonic range (20 Hz or lower) will result in a tremolo effect." \
" This filter may also be used as a ring modulator by specifying a modulation" \
" frequency higher than 20 Hz. Range is 0.1 - 20000.0." \
" Default value is 5.0 Hz." )
#define TREMOLO_MOD_DEPTH_TEXT N_( "mod depth" )
#define TREMOLO_MOD_DEPTH_LONGTEXT N_( "Depth of modulation as a percentage. Range is 0.0 - 1.0." \
" Default value is 0.5." )
vlc_module_begin()
set_shortname( N_("Tremolo") )
set_description( N_("Tremolo: Sinusoidal amp modulation.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "tremolo-mod-freq", 5, 0.1, 2000,
TREMOLO_MOD_FREQUENCY_TEXT, TREMOLO_MOD_FREQUENCY_LONGTEXT )
add_float_with_range( "tremolo-mod-depth", 0.5, 0, 1,
TREMOLO_MOD_DEPTH_TEXT, TREMOLO_MOD_DEPTH_LONGTEXT )
add_shortcut("tremolo")
set_callback( Open_tremolo )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_tremolo( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter, p_block, &p_sys->avf.avfilter, p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_tremolo( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "tremolo-mod-freq" ) )
p_sys->mfreq = newval.f_float;
if( !strcmp( psz_cmd, "tremolo-mod-depth" ) )
p_sys->mdepth = newval.f_float;
if(string_generate_tremolo(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_tremolo( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->mfreq = var_CreateGetFloat(p_aout,"tremolo-mod-freq");
p_sys->mdepth = var_CreateGetFloat(p_aout,"tremolo-mod-depth");
p_sys->avf.params_changed = false;
vlc_mutex_init(&p_sys->avf.lock);
var_AddCallback( p_aout, "tremolo-mod-freq", paramCallback_tremolo, p_sys );
var_AddCallback( p_aout, "tremolo-mod-depth", paramCallback_tremolo, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_tremolo(p_sys),p_filter, &p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"tremolo initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_tremolo =
{ .filter_audio = Process_tremolo, .close = Close_tremolo };
p_filter->ops = &filter_ops_tremolo;
return VLC_SUCCESS;
}
static void Close_tremolo( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}

View File

@ -0,0 +1,181 @@
/*****************************************************************************
* vibrato.c :
*****************************************************************************
* Copyright © 2022 VLC authors and VideoLAN
*
* Authors: Razdutt Sarnaik <rajduttsarnaik@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "avaudio.h"
#include "avaudio_lists.h"
typedef struct
{
float mfreq;
float mdepth;
av_filter avf;
}avfilter_sys_t;
static int Open_vibrato( vlc_object_t *p_this );
static void Close_vibrato( filter_t *p_filter );
static char* string_generate_vibrato(avfilter_sys_t *p_sys )
{
if( vlc_memstream_open( &p_sys->avf.str ) != 0 )
return NULL;
vlc_memstream_printf(&p_sys->avf.str, "vibrato=%f:%f", p_sys->mfreq, p_sys->mdepth);
if(vlc_memstream_close(&p_sys->avf.str))
return NULL;
return p_sys->avf.str.ptr;
}
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define VIBRATO_MOD_FREQUENCY_TEXT N_( "mod frequency" )
#define VIBRATO_MOD_FREQUENCY_LONGTEXT N_( "Modulation frequency in Hertz. Range is 0.1 - 20000.0." \
" Default value is 5.0 Hz." )
#define VIBRATO_MOD_DEPTH_TEXT N_( "mod depth" )
#define VIBRATO_MOD_DEPTH_LONGTEXT N_( "Depth of modulation as a percentage. Range is 0.0 - 1.0." \
" Default value is 0.5." )
vlc_module_begin()
set_shortname( N_("Vibrato") )
set_description( N_("Vibrato: Sinusoidal phase modulation.") )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
add_float_with_range( "vibrato-mod-freq", 5, 0.1, 2000,
VIBRATO_MOD_FREQUENCY_TEXT, VIBRATO_MOD_FREQUENCY_LONGTEXT )
add_float_with_range( "vibrato-mod-depth", 0.5, 0, 1,
VIBRATO_MOD_DEPTH_TEXT, VIBRATO_MOD_DEPTH_LONGTEXT )
add_shortcut("vibrato")
set_callback( Open_vibrato )
vlc_module_end()
/*****************************************************************************
* Open: initialize filter
*****************************************************************************/
static block_t *Process_vibrato( filter_t *p_filter, block_t *p_block )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
if(!Process_avaudio_2(p_filter,&p_sys->avf))
return p_block;
p_sys->avf.avfilter.frame_len_flag = 1;
return Process_avaudio(p_filter,p_block,&p_sys->avf.avfilter,p_sys->avf.avfilter.frame_len_flag);
}
static int paramCallback_vibrato( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
avfilter_sys_t *p_sys;
p_sys = p_data;
vlc_mutex_lock(&p_sys->avf.lock);
if( !strcmp( psz_cmd, "vibrato-mod-freq" ) )
p_sys->mfreq = newval.f_float;
if( !strcmp( psz_cmd, "vibrato-mod-depth" ) )
p_sys->mdepth = newval.f_float;
if(string_generate_vibrato(p_sys) == NULL)
return VLC_EGENERIC;
p_sys->avf.params_changed = true;
vlc_mutex_unlock(&p_sys->avf.lock);
return VLC_SUCCESS;
}
static int Open_vibrato( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
avfilter_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
p_filter->p_sys = p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
p_sys->mfreq = var_CreateGetFloat(p_aout,"vibrato-mod-freq");
p_sys->mdepth = var_CreateGetFloat(p_aout,"vibrato-mod-depth");
p_sys->avf.params_changed = false;
vlc_mutex_init( &p_sys->avf.lock );
var_AddCallback( p_aout, "vibrato-mod-freq", paramCallback_vibrato, p_sys );
var_AddCallback( p_aout, "vibrato-mod-depth", paramCallback_vibrato, p_sys );
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
/* initialize ffmpeg filter */
if(init_filters(string_generate_vibrato(p_sys),p_filter,&p_sys->avf.avfilter) < 0)
{
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
return VLC_EGENERIC;
}
/*filter description*/
msg_Dbg(p_filter,"vibrato initialized:%s",p_sys->avf.str.ptr);
free(p_sys->avf.str.ptr);
static const struct vlc_filter_operations filter_ops_vibrato =
{ .filter_audio = Process_vibrato, .close = Close_vibrato };
p_filter->ops = &filter_ops_vibrato;
return VLC_SUCCESS;
}
static void Close_vibrato( filter_t *p_filter )
{
avfilter_sys_t *p_sys = p_filter->p_sys;
avfilter_graph_free(&p_sys->avf.avfilter.filter_graph);
free(p_sys);
}