Commit 3f2e13bc authored by Gildas Bazin's avatar Gildas Bazin

* src/audio_output/input.c: ability to switch between equalizers on the fly.

* modules/gui/wxwindows/menus.cpp: added equalizers to the menus.
parent 7f800bc0
......@@ -2,7 +2,7 @@
* equalizer.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: goom.c 8019 2004-06-22 19:35:01Z fenrir $
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -67,7 +67,7 @@ static char *preset_list[] = {
};
static char *preset_list_text[] = {
N_("Flat"), N_("Classical"), N_("Club"), N_("Dance"), N_("Full bass"),
N_("Full bass and treeble"), N_("Full treeble"), N_("Laptop speakers and Headphones"),
N_("Full bass and treeble"), N_("Full treeble"), N_("Headphones"),
N_("Large Hall"), N_("Live"), N_("Party"), N_("Pop"), N_("Reggae"),
N_("Rock"), N_("Ska"), N_("Soft"), N_("Soft rock"), N_("Techno"),
};
......@@ -75,11 +75,15 @@ static char *preset_list_text[] = {
vlc_module_begin();
set_description( _("Equalizer 10 bands") );
set_capability( "audio filter", 0 );
add_string( "equalizer-preset", "flat", NULL, PRESET_TEXT, PRESET_LONGTEXT, VLC_TRUE );
add_string( "equalizer-preset", "flat", NULL, PRESET_TEXT,
PRESET_LONGTEXT, VLC_TRUE );
change_string_list( preset_list, preset_list_text, 0 );
add_string( "equalizer-bands", NULL, NULL, BANDS_TEXT, BANDS_LONGTEXT, VLC_TRUE );
add_bool( "equalizer-2pass", 0, NULL, TWOPASS_TEXT, TWOPASS_LONGTEXT, VLC_TRUE );
add_float( "equalizer-preamp", 0.0, NULL, PREAMP_TEXT, PREAMP_LONGTEXT, VLC_TRUE );
add_string( "equalizer-bands", NULL, NULL, BANDS_TEXT,
BANDS_LONGTEXT, VLC_TRUE );
add_bool( "equalizer-2pass", 0, NULL, TWOPASS_TEXT,
TWOPASS_LONGTEXT, VLC_TRUE );
add_float( "equalizer-preamp", 0.0, NULL, PREAMP_TEXT,
PREAMP_LONGTEXT, VLC_TRUE );
set_callbacks( Open, Close );
add_shortcut( "equalizer" );
vlc_module_end();
......@@ -115,8 +119,8 @@ static void DoWork( aout_instance_t *, aout_filter_t *,
aout_buffer_t *, aout_buffer_t * );
#define EQZ_IN_FACTOR (0.25)
static int EqzInit( aout_filter_t *, int i_rate );
static void EqzFilter( aout_filter_t *, float *out, float *in, int i_samples, int i_channels );
static int EqzInit( aout_filter_t *, int );
static void EqzFilter( aout_filter_t *, float *, float *, int, int );
static void EqzClean( aout_filter_t * );
/*****************************************************************************
......@@ -174,8 +178,9 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
EqzFilter( p_filter, (float*)p_out_buf->p_buffer, (float*)p_in_buf->p_buffer,
p_in_buf->i_nb_samples, aout_FormatNbChannels( &p_filter->input ) );
EqzFilter( p_filter, (float*)p_out_buf->p_buffer,
(float*)p_in_buf->p_buffer, p_in_buf->i_nb_samples,
aout_FormatNbChannels( &p_filter->input ) );
}
/*****************************************************************************
......@@ -192,6 +197,7 @@ typedef struct
float f_beta;
float f_gamma;
} band[];
} eqz_config_t;
/* Value from equ-xmms */
......@@ -498,7 +504,8 @@ static int EqzInit( aout_filter_t *p_filter, int i_rate )
return VLC_SUCCESS;
}
static void EqzFilter( aout_filter_t *p_filter, float *out, float *in, int i_samples, int i_channels )
static void EqzFilter( aout_filter_t *p_filter, float *out, float *in,
int i_samples, int i_channels )
{
aout_filter_sys_t *p_sys = p_filter->p_sys;
int i, ch, j;
......@@ -568,4 +575,3 @@ static void EqzClean( aout_filter_t *p_filter )
free( p_sys->f_amp );
}
......@@ -165,6 +165,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "equalizer";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object );
}
......@@ -304,6 +306,8 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "equalizer";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object );
}
......
......@@ -38,7 +38,9 @@
#include "aout_internal.h"
static int VisualizationCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
vlc_value_t, vlc_value_t, void * );
static int EqualizerCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static aout_filter_t * allocateUserChannelMixer( aout_instance_t *,
audio_sample_format_t *,
audio_sample_format_t * );
......@@ -128,6 +130,34 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
}
if( var_Type( p_aout, "equalizer" ) == 0 )
{
module_config_t *p_config;
int i;
p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
if( p_config && p_config->i_list )
{
var_Create( p_aout, "equalizer",
VLC_VAR_STRING | VLC_VAR_HASCHOICE );
text.psz_string = _("Equalizer");
var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
val.psz_string = ""; text.psz_string = _("Disable");
var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
for( i = 0; i < p_config->i_list; i++ )
{
val.psz_string = p_config->ppsz_list[i];
text.psz_string = p_config->ppsz_list_text[i];
var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
&val, &text );
}
var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
}
}
if( var_Type( p_aout, "audio-filter" ) == 0 )
{
var_Create( p_aout, "audio-filter",
......@@ -475,6 +505,47 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
return 0;
}
static void ChangeFiltersString( aout_instance_t * p_aout,
char *psz_name, vlc_bool_t b_add )
{
vlc_value_t val;
char *psz_parser;
var_Get( p_aout, "audio-filter", &val );
if( !val.psz_string ) val.psz_string = strdup("");
psz_parser = strstr( val.psz_string, psz_name );
if( b_add )
{
if( !psz_parser )
{
psz_parser = val.psz_string;
asprintf( &val.psz_string, (*val.psz_string) ? "%s,%s" : "%s%s",
val.psz_string, psz_name );
free( psz_parser );
}
}
else
{
if( psz_parser )
{
memmove( psz_parser, psz_parser + strlen(psz_name) +
(*(psz_parser + strlen(psz_name)) == ',' ? 1 : 0 ),
strlen(psz_parser + strlen(psz_name)) + 1 );
}
else
{
free( val.psz_string );
return;
}
}
var_Set( p_aout, "audio-filter", val );
free( val.psz_string );
}
static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
......@@ -485,14 +556,15 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
if( !psz_mode || !*psz_mode )
{
val.psz_string = "";
var_Set( p_aout, "audio-filter", val );
ChangeFiltersString( p_aout, "goom", VLC_FALSE );
ChangeFiltersString( p_aout, "visual", VLC_FALSE );
}
else
{
if( !strcmp( "goom", psz_mode ) )
{
val.psz_string = "goom";
ChangeFiltersString( p_aout, "visual", VLC_FALSE );
ChangeFiltersString( p_aout, "goom", VLC_TRUE );
}
else
{
......@@ -500,10 +572,38 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
var_Create( p_aout, "effect-list", VLC_VAR_STRING );
var_Set( p_aout, "effect-list", val );
val.psz_string = "visual";
ChangeFiltersString( p_aout, "goom", VLC_FALSE );
ChangeFiltersString( p_aout, "visual", VLC_TRUE );
}
}
/* That sucks */
for( i = 0; i < p_aout->i_nb_inputs; i++ )
{
p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
}
return VLC_SUCCESS;
}
var_Set( p_aout, "audio-filter", val );
static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
aout_instance_t *p_aout = (aout_instance_t *)p_this;
char *psz_mode = newval.psz_string;
vlc_value_t val;
int i;
if( !psz_mode || !*psz_mode )
{
ChangeFiltersString( p_aout, "equalizer", VLC_FALSE );
}
else
{
val.psz_string = psz_mode;
var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
var_Set( p_aout, "equalizer-preset", val );
ChangeFiltersString( p_aout, "equalizer", VLC_TRUE );
}
/* That sucks */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment