Commit d0ea236c authored by Akash Mehrotra's avatar Akash Mehrotra Committed by Jean-Baptiste Kempf

LUA: EQ Preset setter

parent 7384460f
......@@ -176,7 +176,7 @@ static int vlclua_equalizer_get( lua_State *L )
free(str);
asprintf( &str , "band_%d", i++ );
lua_setfield( L , -2 , str );
free(str);
free( str );
}
free( psz_bands_origin );
if (loc != (locale_t)0)
......@@ -239,6 +239,47 @@ static int vlclua_equalizer_set( lua_State *L )
return 1;
}
/*****************************************************************************
* Set the preset specified by preset id
*****************************************************************************/
static int vlclua_equalizer_setpreset( lua_State *L )
{
int presetid = luaL_checknumber( L, 1 );
if( presetid >= NB_PRESETS || presetid < 0 )
return 0;
input_thread_t *p_input = vlclua_get_input_internal( L );
if( p_input )
{
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if ( !p_aout )
{
return 0;
}
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
if ( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
{
vlc_object_release( p_aout );
return 0;
}
char *newstr;
if( asprintf( &newstr , "%6.1f" , eqz_preset_10b[presetid].f_amp[0] ) == -1 )
return 0;
for ( int i = 1 ; i < 10 ; i++ )
{
if ( asprintf( &newstr, "%s%6.1f",newstr ,eqz_preset_10b[presetid].f_amp[i]) == -1 )
return 0;
}
var_SetString( p_aout, "equalizer-bands",newstr );
var_SetFloat( p_aout, "equalizer-preamp", eqz_preset_10b[presetid].f_preamp );
var_SetString( p_aout , "equalizer-preset" , preset_list[presetid] );
vlc_object_release( p_aout );
free( newstr );
return 1;
}
return 0;
}
/****************************************************************************
* Enable/disable Equalizer
*****************************************************************************/
......@@ -271,7 +312,8 @@ static const luaL_Reg vlclua_equalizer_reg[] = {
{ "equalizerget", vlclua_equalizer_get },
{ "equalizerset", vlclua_equalizer_set },
{ "enable", vlclua_equalizer_enable },
{"presets",vlclua_equalizer_get_presets },
{ "presets",vlclua_equalizer_get_presets },
{ "setpreset", vlclua_equalizer_setpreset },
{ NULL, NULL }
};
......
......@@ -125,6 +125,9 @@ status.xml or status.json
0 -- disables the equalizer
1 -- enables the equalizer
>command=setpreset&val=<presetid>
set the equalizer preset as per the id specified
<Displays the equalizer band gains.
Band 0: 60 Hz, 1: 170 Hz, 2: 310 Hz, 3: 600 Hz, 4: 1 kHz,
5: 3 kHz, 6: 6 kHz, 7: 12 kHz , 8: 14 kHz , 9: 16 kHz
......
......@@ -172,6 +172,8 @@ processcommands = function ()
vlc.equalizer.equalizerset(band,val)
elseif command == "enableeq" then
if val == '0' then vlc.equalizer.enable(false) else vlc.equalizer.enable(true) end
elseif command == "setpreset" then
vlc.equalizer.setpreset(val)
end
local input = nil
......
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