Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
47c1409f
Commit
47c1409f
authored
Jun 29, 2011
by
Akash Mehrotra
Committed by
Jean-Baptiste Kempf
Jun 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Luahttp can access and modify equalizer settings
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
4fc0e980
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
10 deletions
+158
-10
modules/lua/libs/equalizer.c
modules/lua/libs/equalizer.c
+138
-4
share/lua/http/requests/README.txt
share/lua/http/requests/README.txt
+6
-0
share/lua/http/requests/equalizer.xml
share/lua/http/requests/equalizer.xml
+14
-6
No files found.
modules/lua/libs/equalizer.c
View file @
47c1409f
/*****************************************************************************
/*****************************************************************************
* equalizer.c
* equalizer.c
*****************************************************************************
*****************************************************************************
* Copyright (C) 2011
the VideoLAN team
* Copyright (C) 2011
VideoLAN and VLC authors
* $Id$
* $Id$
*
*
* Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
* Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_aout.h>
#include <vlc_input.h>
#include <vlc_input.h>
#include <vlc_charset.h>
#include <lua.h>
/* Low level lua C API */
#include <lua.h>
/* Low level lua C API */
#include <lauxlib.h>
/* Higher level C API */
#include <lauxlib.h>
/* Higher level C API */
...
@@ -42,6 +43,18 @@
...
@@ -42,6 +43,18 @@
#include "input.h"
#include "input.h"
#include "../libs.h"
#include "../libs.h"
#if !defined WIN32
# include <locale.h>
#else
# include <windows.h>
#endif
#ifdef __APPLE__
# include <string.h>
# include <xlocale.h>
#endif
/*****************************************************************************
/*****************************************************************************
* Get the preamp level
* Get the preamp level
*****************************************************************************/
*****************************************************************************/
...
@@ -51,11 +64,16 @@ static int vlclua_preamp_get( lua_State *L )
...
@@ -51,11 +64,16 @@ static int vlclua_preamp_get( lua_State *L )
if
(
p_input
)
if
(
p_input
)
{
{
aout_instance_t
*
p_aout
=
input_GetAout
(
p_input
);
aout_instance_t
*
p_aout
=
input_GetAout
(
p_input
);
vlc_object_release
(
p_input
);
char
*
psz_af
=
var_GetNonEmptyString
(
p_aout
,
"audio-filter"
);
if
(
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
{
vlc_object_release
(
p_aout
);
return
0
;
}
float
preamp
=
var_GetFloat
(
p_aout
,
"equalizer-preamp"
);
float
preamp
=
var_GetFloat
(
p_aout
,
"equalizer-preamp"
);
lua_pushnumber
(
L
,
preamp
);
lua_pushnumber
(
L
,
preamp
);
vlc_object_release
(
p_aout
);
vlc_object_release
(
p_aout
);
vlc_object_release
(
p_input
);
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -70,20 +88,136 @@ static int vlclua_preamp_set( lua_State *L )
...
@@ -70,20 +88,136 @@ static int vlclua_preamp_set( lua_State *L )
if
(
p_input
)
if
(
p_input
)
{
{
aout_instance_t
*
p_aout
=
input_GetAout
(
p_input
);
aout_instance_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
(
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
{
vlc_object_release
(
p_aout
);
return
0
;
}
float
preamp
=
luaL_checknumber
(
L
,
1
);
float
preamp
=
luaL_checknumber
(
L
,
1
);
var_SetFloat
(
p_aout
,
"equalizer-preamp"
,
preamp
);
var_SetFloat
(
p_aout
,
"equalizer-preamp"
,
preamp
);
lua_pushnumber
(
L
,
preamp
);
lua_pushnumber
(
L
,
preamp
);
vlc_object_release
(
p_aout
);
return
1
;
}
return
0
;
}
/*****************************************************************************
Bands:
Band 0: 60 Hz
Band 1: 170 Hz
Band 2: 310 Hz
Band 3: 600 Hz
Band 4: 1 kHz
Band 5: 3 kHz
Band 6: 6 kHz
Band 7: 12 kHz
Band 8: 14 kHz
Band 9: 16 kHz
*****************************************************************************/
/*****************************************************************************
* Get the equalizer level for the specified band
*****************************************************************************/
static
int
vlclua_equalizer_get
(
lua_State
*
L
)
{
input_thread_t
*
p_input
=
vlclua_get_input_internal
(
L
);
if
(
p_input
)
{
float
level
=
0
;
aout_instance_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
(
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
{
vlc_object_release
(
p_aout
);
return
0
;
}
int
bandid
=
luaL_checknumber
(
L
,
1
);
char
*
bands
=
var_GetNonEmptyString
(
p_aout
,
"equalizer-bands"
);
locale_t
loc
=
newlocale
(
LC_NUMERIC_MASK
,
"C"
,
NULL
);
locale_t
oldloc
=
uselocale
(
loc
);
while
(
bandid
>=
0
)
{
level
=
strtof
(
bands
,
&
bands
);
bandid
--
;
}
if
(
loc
!=
(
locale_t
)
0
)
{
uselocale
(
oldloc
);
freelocale
(
loc
);
}
if
(
bandid
!=
-
1
)
{
vlc_object_release
(
p_aout
);
vlc_object_release
(
p_aout
);
return
0
;
}
lua_pushnumber
(
L
,
level
);
vlc_object_release
(
p_aout
);
return
1
;
}
return
0
;
}
/*****************************************************************************
* Set the equalizer level for the specified band
*****************************************************************************/
static
int
vlclua_equalizer_set
(
lua_State
*
L
)
{
input_thread_t
*
p_input
=
vlclua_get_input_internal
(
L
);
if
(
p_input
)
{
int
i_pos
=
0
,
j
=
0
;
aout_instance_t
*
p_aout
=
input_GetAout
(
p_input
);
vlc_object_release
(
p_input
);
vlc_object_release
(
p_input
);
if
(
!
p_aout
)
{
return
0
;
}
char
*
psz_af
=
var_GetNonEmptyString
(
p_aout
,
"audio-filter"
);
if
(
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
{
vlc_object_release
(
p_aout
);
return
0
;
}
int
bandid
=
luaL_checknumber
(
L
,
1
);
float
level
=
luaL_checknumber
(
L
,
2
);
char
*
bands
=
var_GetString
(
p_aout
,
"equalizer-bands"
);
char
newstr
[
7
];
while
(
j
!=
bandid
)
{
i_pos
++
;
if
(
bands
[
i_pos
]
==
'.'
)
{
i_pos
++
;
j
++
;
}
}
if
(
bandid
!=
0
)
i_pos
++
;
snprintf
(
newstr
,
sizeof
(
newstr
)
,
"%6.1f"
,
level
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
bands
[
i_pos
+
i
]
=
newstr
[
i
];
var_SetString
(
p_aout
,
"equalizer-bands"
,
bands
);
vlc_object_release
(
p_aout
);
return
1
;
return
1
;
}
}
return
0
;
return
0
;
}
}
static
const
luaL_Reg
vlclua_equalizer_reg
[]
=
{
static
const
luaL_Reg
vlclua_equalizer_reg
[]
=
{
{
"preampget"
,
vlclua_preamp_get
},
{
"preampget"
,
vlclua_preamp_get
},
{
"preampset"
,
vlclua_preamp_set
},
{
"preampset"
,
vlclua_preamp_set
},
{
"equalizerget"
,
vlclua_equalizer_get
},
{
"equalizerset"
,
vlclua_equalizer_set
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
...
share/lua/http/requests/README.txt
View file @
47c1409f
...
@@ -129,3 +129,9 @@ equalizer.xml:
...
@@ -129,3 +129,9 @@ equalizer.xml:
=============
=============
>command=preamp&val=<val in dB>
>command=preamp&val=<val in dB>
sets the preamp value, must be >=-20 and <=20
sets the preamp value, must be >=-20 and <=20
>command=equalizer&band=<band>&val=<gain in dB, must be >=-20 and <=20)
<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
share/lua/http/requests/equalizer.xml
View file @
47c1409f
...
@@ -28,11 +28,19 @@ vim:syntax=lua
...
@@ -28,11 +28,19 @@ vim:syntax=lua
local command = _GET['command']
local command = _GET['command']
local val = _GET['val']
local val = _GET['val']
local band = _GET['band']
function round(what, precision)
function round(what, precision)
return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
if what then return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision) else return "" end
end
end
if command == "preamp" then vlc.equalizer.preampset(val) end
if command == "preamp" then vlc.equalizer.preampset(val)
elseif command == "equalizer" then vlc.equalizer.equalizerset(band,val)
end
freq = { 60 , 170 , 310 , 600 , 1000 , 3000 , 6000 , 12000 , 14000 , 16000 }
?>
?>
<root>
<root>
<preamp>
<?vlc print(round(vlc.equalizer.preampget(),2)) ?>
</preamp>
<preamp>
<?vlc print(round(vlc.equalizer.preampget(),2)) ?>
</preamp>
<equalizer>
<
?vlc for i = 0,9
do print("
<band
id=
'"..i.."'
freqency =
'"..freq[i+1].."'
>
"..round(vlc.equalizer.equalizerget(i),1).."
</band>
") end ?>
</equalizer>
</root>
</root>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment