various: convert tabs to spaces

This commit is contained in:
Guido Cella 2024-10-18 18:21:31 +02:00 committed by Kacper Michajłow
parent 7fe12574fa
commit 1b53793a4c
2 changed files with 110 additions and 110 deletions

View File

@ -8,151 +8,151 @@ local mp = require 'mp'
local options = require 'mp.options' local options = require 'mp.options'
local o = { local o = {
default_enable = false, default_enable = false,
show_osd = true, show_osd = true,
osd_timeout = 4000, osd_timeout = 4000,
filter_label = mp.get_script_name(), filter_label = mp.get_script_name(),
key_toggle = 'n', key_toggle = 'n',
key_increase_threshold = 'F1', key_increase_threshold = 'F1',
key_decrease_threshold = 'Shift+F1', key_decrease_threshold = 'Shift+F1',
key_increase_ratio = 'F2', key_increase_ratio = 'F2',
key_decrease_ratio = 'Shift+F2', key_decrease_ratio = 'Shift+F2',
key_increase_knee = 'F3', key_increase_knee = 'F3',
key_decrease_knee = 'Shift+F3', key_decrease_knee = 'Shift+F3',
key_increase_makeup = 'F4', key_increase_makeup = 'F4',
key_decrease_makeup = 'Shift+F4', key_decrease_makeup = 'Shift+F4',
key_increase_attack = 'F5', key_increase_attack = 'F5',
key_decrease_attack = 'Shift+F5', key_decrease_attack = 'Shift+F5',
key_increase_release = 'F6', key_increase_release = 'F6',
key_decrease_release = 'Shift+F6', key_decrease_release = 'Shift+F6',
default_threshold = -25.0, default_threshold = -25.0,
default_ratio = 3.0, default_ratio = 3.0,
default_knee = 2.0, default_knee = 2.0,
default_makeup = 8.0, default_makeup = 8.0,
default_attack = 20.0, default_attack = 20.0,
default_release = 250.0, default_release = 250.0,
step_threshold = -2.5, step_threshold = -2.5,
step_ratio = 1.0, step_ratio = 1.0,
step_knee = 1.0, step_knee = 1.0,
step_makeup = 1.0, step_makeup = 1.0,
step_attack = 10.0, step_attack = 10.0,
step_release = 10.0, step_release = 10.0,
} }
options.read_options(o) options.read_options(o)
local params = { local params = {
{ name = 'attack', min=0.01, max=2000, hide_default=true, dB='' }, { name = 'attack', min=0.01, max=2000, hide_default=true, dB='' },
{ name = 'release', min=0.01, max=9000, hide_default=true, dB='' }, { name = 'release', min=0.01, max=9000, hide_default=true, dB='' },
{ name = 'threshold', min= -30, max= 0, hide_default=false, dB='dB' }, { name = 'threshold', min= -30, max= 0, hide_default=false, dB='dB' },
{ name = 'ratio', min= 1, max= 20, hide_default=false, dB='' }, { name = 'ratio', min= 1, max= 20, hide_default=false, dB='' },
{ name = 'knee', min= 1, max= 10, hide_default=true, dB='dB' }, { name = 'knee', min= 1, max= 10, hide_default=true, dB='dB' },
{ name = 'makeup', min= 0, max= 24, hide_default=false, dB='dB' }, { name = 'makeup', min= 0, max= 24, hide_default=false, dB='dB' },
} }
local function parse_value(value) local function parse_value(value)
-- Using nil here because tonumber differs between lua 5.1 and 5.2 when -- Using nil here because tonumber differs between lua 5.1 and 5.2 when
-- parsing fractions in combination with explicit base argument set to 10. -- parsing fractions in combination with explicit base argument set to 10.
-- And we can't omit it because gsub returns 2 values which would get -- And we can't omit it because gsub returns 2 values which would get
-- unpacked and cause more problems. Gotta love scripting languages. -- unpacked and cause more problems. Gotta love scripting languages.
return tonumber(value:gsub('dB$', ''), nil) return tonumber(value:gsub('dB$', ''), nil)
end end
local function format_value(value, dB) local function format_value(value, dB)
return string.format('%g%s', value, dB) return string.format('%g%s', value, dB)
end end
local function show_osd(filter) local function show_osd(filter)
if not o.show_osd then if not o.show_osd then
return return
end end
if not filter.enabled then if not filter.enabled then
mp.commandv('show-text', 'Dynamic range compressor: disabled', o.osd_timeout) mp.commandv('show-text', 'Dynamic range compressor: disabled', o.osd_timeout)
return return
end end
local pretty = {} local pretty = {}
for _,param in ipairs(params) do for _,param in ipairs(params) do
local value = parse_value(filter.params[param.name]) local value = parse_value(filter.params[param.name])
if not (param.hide_default and value == o['default_' .. param.name]) then if not (param.hide_default and value == o['default_' .. param.name]) then
pretty[#pretty+1] = string.format('%s: %g%s', param.name:gsub("^%l", string.upper), pretty[#pretty+1] = string.format('%s: %g%s', param.name:gsub("^%l", string.upper),
value, param.dB) value, param.dB)
end end
end end
if #pretty == 0 then if #pretty == 0 then
pretty = '' pretty = ''
else else
pretty = '\n(' .. table.concat(pretty, ', ') .. ')' pretty = '\n(' .. table.concat(pretty, ', ') .. ')'
end end
mp.commandv('show-text', 'Dynamic range compressor: enabled' .. pretty, o.osd_timeout) mp.commandv('show-text', 'Dynamic range compressor: enabled' .. pretty, o.osd_timeout)
end end
local function get_filter() local function get_filter()
local af = mp.get_property_native('af', {}) local af = mp.get_property_native('af', {})
for i = 1, #af do for i = 1, #af do
if af[i].label == o.filter_label then if af[i].label == o.filter_label then
return af, i return af, i
end end
end end
af[#af+1] = { af[#af+1] = {
name = 'acompressor', name = 'acompressor',
label = o.filter_label, label = o.filter_label,
enabled = false, enabled = false,
params = {}, params = {},
} }
for _,param in pairs(params) do for _,param in pairs(params) do
af[#af].params[param.name] = format_value(o['default_' .. param.name], param.dB) af[#af].params[param.name] = format_value(o['default_' .. param.name], param.dB)
end end
return af, #af return af, #af
end end
local function toggle_acompressor() local function toggle_acompressor()
local af, i = get_filter() local af, i = get_filter()
af[i].enabled = not af[i].enabled af[i].enabled = not af[i].enabled
mp.set_property_native('af', af) mp.set_property_native('af', af)
show_osd(af[i]) show_osd(af[i])
end end
local function update_param(name, increment) local function update_param(name, increment)
for _,param in pairs(params) do for _,param in pairs(params) do
if param.name == string.lower(name) then if param.name == string.lower(name) then
local af, i = get_filter() local af, i = get_filter()
local value = parse_value(af[i].params[param.name]) local value = parse_value(af[i].params[param.name])
value = math.max(param.min, math.min(value + increment, param.max)) value = math.max(param.min, math.min(value + increment, param.max))
af[i].params[param.name] = format_value(value, param.dB) af[i].params[param.name] = format_value(value, param.dB)
af[i].enabled = true af[i].enabled = true
mp.set_property_native('af', af) mp.set_property_native('af', af)
show_osd(af[i]) show_osd(af[i])
return return
end end
end end
mp.msg.error('Unknown parameter "' .. name .. '"') mp.msg.error('Unknown parameter "' .. name .. '"')
end end
mp.add_key_binding(o.key_toggle, "toggle-acompressor", toggle_acompressor) mp.add_key_binding(o.key_toggle, "toggle-acompressor", toggle_acompressor)
mp.register_script_message('update-param', update_param) mp.register_script_message('update-param', update_param)
for _,param in pairs(params) do for _,param in pairs(params) do
for direction,step in pairs({increase=1, decrease=-1}) do for direction,step in pairs({increase=1, decrease=-1}) do
mp.add_key_binding(o['key_' .. direction .. '_' .. param.name], mp.add_key_binding(o['key_' .. direction .. '_' .. param.name],
'acompressor-' .. direction .. '-' .. param.name, 'acompressor-' .. direction .. '-' .. param.name,
function() update_param(param.name, step*o['step_' .. param.name]); end, function() update_param(param.name, step*o['step_' .. param.name]); end,
{ repeatable = true }) { repeatable = true })
end end
end end
if o.default_enable then if o.default_enable then
local af, i = get_filter() local af, i = get_filter()
af[i].enabled = true af[i].enabled = true
mp.set_property_native('af', af) mp.set_property_native('af', af)
end end

View File

@ -17,11 +17,11 @@ SHARP cycle audio # switch audio streams
+ add audio-delay 0.100 + add audio-delay 0.100
= add audio-delay 0.100 = add audio-delay 0.100
- add audio-delay -0.100 - add audio-delay -0.100
[ multiply speed 0.9091 # scale playback speed [ multiply speed 0.9091 # scale playback speed
] multiply speed 1.1 ] multiply speed 1.1
{ multiply speed 0.5 { multiply speed 0.5
} multiply speed 2.0 } multiply speed 2.0
BS set speed 1.0 # reset speed to normal BS set speed 1.0 # reset speed to normal
q quit q quit
ESC quit ESC quit
ENTER playlist-next force # skip to next file ENTER playlist-next force # skip to next file
@ -57,10 +57,10 @@ d cycle framedrop
D cycle deinterlace # toggle deinterlacer (auto-inserted filter) D cycle deinterlace # toggle deinterlacer (auto-inserted filter)
r add sub-pos -1 # move subtitles up r add sub-pos -1 # move subtitles up
t add sub-pos +1 # down t add sub-pos +1 # down
#? sub-step +1 # immediately display next subtitle #? sub-step +1 # immediately display next subtitle
#? sub-step -1 # previous #? sub-step -1 # previous
#? add sub-scale +0.1 # increase subtitle font size #? add sub-scale +0.1 # increase subtitle font size
#? add sub-scale -0.1 # decrease subtitle font size #? add sub-scale -0.1 # decrease subtitle font size
f cycle fullscreen f cycle fullscreen
T cycle ontop # toggle video window ontop of other windows T cycle ontop # toggle video window ontop of other windows
w add panscan -0.1 # zoom out with -panscan 0 -fs w add panscan -0.1 # zoom out with -panscan 0 -fs