dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

visualizer.lua (21444B)


      1 -- various audio visualization
      2 
      3 local opts = {
      4     mode = "novideo",
      5     -- off              disable visualization
      6     -- noalbumart       enable visualization when no albumart and no video
      7     -- novideo          enable visualization when no video
      8     -- force            always enable visualization
      9 
     10     name = "avectorscope",
     11     -- off
     12     -- showcqt
     13     -- avectorscope
     14     -- showspectrum
     15     -- showcqtbar
     16     -- showwaves
     17 
     18     quality = "high",
     19     -- verylow
     20     -- low
     21     -- medium
     22     -- high
     23     -- veryhigh
     24 
     25     height = 6,
     26     -- [4 .. 12]
     27 }
     28 
     29 -- key bindings
     30 -- cycle visualizer
     31 local cycle_key = "c"
     32 
     33 if not (mp.get_property("options/lavfi-complex", "") == "") then
     34     return
     35 end
     36 
     37 local visualizer_name_list = {
     38     "off",
     39     "showcqt",
     40     "avectorscope",
     41     -- "showspectrum",
     42     -- "showcqtbar",
     43     "showwaves",
     44 }
     45 
     46 local axis_0 = "image/png;base64," ..
     47 "iVBORw0KGgoAAAANSUhEUgAAB4AAAAAgCAQAAABZEK0tAAAACXBIWXMAAA7EAAAOxAGVKw4bAAASO0lEQVR42u2de2wU1xXGV/IfSJEqVUJCQrIUISFFiiqhSFWkKFKFokpB1TqxHROT8ApueDgEE9u4MW4TSqFA" ..
     48 "3TSUQmkSChRwII6BkAQCDSYlBtc1hiSA4/CyMcYGtsZvY3t3vXu719vVPjxzz71zd+wBvnOkdvHZ78w5v7mZmbt7Z9blgsFgMBgMBoPBYDAYDAaDwWAwGAwGg8FgMBgMBoPBYDAYDAaDwWCw+9HYBFbKboe8lE1A" ..
     49 "HHHEEUccccQRRxxxxBFHHPEHNe4KBSJWijjiiCOOOOKII4444ogjjjjiD1icwWAwGAwGg8FgMBgM9hAYJsAwGAwGg8FgMBgMBnsozOVyR7zuQOSPdQeif0UcccQRRxxxxBFHHHHEEUcc8QciHn05KaPuwGDHYEfd"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32K93en329dfwZdCfOvIAoyN/Y8xskbF9eqfXZ3d/EV/zZsDXdV30qDl79U6vz+7+bPJknAAG2oe6jm///hhjdfvvPz3lxfkXDtcfZay7" ..
     82 "pf5obYX02vKk6Z1en739PTuP37PQ1VR/tP6o5yJjks92S5re6fXZ3Z/L3VzdXP351oObqvcNdfv6jX/mwU690+uzu7+wn9jZfinysInx0Du9Pvv662rsaancvn9TzT5vz1D3tOyx1ju9Prv7c7n5mb3hn59u6bjC" ..
     83 "TJcY26l3en1298f9nqf7+njqnV6fff2Vv8t/4urEzu8+8/V7e1Izx1rv9Prs7u/xF2srTuy4+q9gYKizcPnY651en9392ezJSLJ+5VAXX4DdenZq1v2oF3vl9uhN1v7+2Id1j43e6fXZ29/shfF3RryQM7Z6p9dn" ..
     84 "d38ud/W+yL0Zva3rV4693un12d0f9x+n8x+zZ+yeZ1LGeOidXp+d/ZVv9PaE9293i9kdtnbqnV6f3f3x59u3/Cf84JQv3h8PvdPrs7s/l/uR5/pu6Sxu19U7vT57+6v9OHyG6WuL/tTLWOqdXp+9/WXk8AfMMea5" ..
     85 "+ItXxkPv9Prs7s9mT9YpIHepTvvjrYfD4Waempm7tDj/+QVWl7fo6p1en939wcfXH3luweKifLMfmbFf7/T67O6Pe/ary/MefWH89E6vz+7+4OPpU7Pyls38pfXzi67e6fXZ29/kzOV5OrMLXb3T67O7P1sdBxc4" ..
     86 "HA6Hw+FwOBwOhz8UDgRwOBwOh8PhcDgcDn8oHAjgcDgcDofD4XA4HP4w+P8AQEuXMXpD8/kAAAAASUVORK5CYII="
     87 
     88 local axis_1 = "image/png;base64," ..
     89 "iVBORw0KGgoAAAANSUhEUgAAB4AAAAAwCAQAAABaxq+2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAATVklEQVR42u2df0xUZ7rHJ+EPkiabbGJiYkLSmJg0aTYxTTZNmiYb09ykZjO0QLHY+quy9Qe1YgG5Re62rlev" ..
     90 "etluXVevt62rrkq1FLG21epW7FqUZRFtq1LqL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gQha4/cfWN+TunP2r+5+cy9sX/WK+v69etT83/ie7P" ..
    122 "mP/qt/hN5vij4gLGTu9VrarrT1x9Y/7O6U80/wvz9N5hdP2JqC+a/07oz5j/Vx8ytnNDUuqMzMaqgH96pmpVXX/i6hvzd05/5vN/euamNTkrTu/jr2Slsq4/MfXN578z+qPef20J/RKHtjK25R3+6GZ1wKd+ADLR" ..
    123 "frl4FBbAD2d/G4t8vUE//2zvmVf/vHH8/U4fn939RWP3RsbMP+O13+/08dnT39VvOq/z4D/1dvuc+v5N1+/08dnd37SMyLV+H61nbO/m8fY7fXx29zc9c3io+xZ/lL2csb/9Zbz9Th+f3f2F4/xh0fkd9vudPj77" ..
    124 "+mv4OuhPGbmB0bH/ZczsJGP7/E4fn939RWL92wFf103Rrebs9Tt9fHb3Z1Mk4g1goH2o6+SuH08wVnfo4fNTUZR36Wj9cca6W+qP15ZLn1ueML/Tx2dvf88v5NcsdDXVH68/7rnMmOS93RLmd/r47O7P5W6ubq7+" ..
    125 "csfhrdUHh7p9/cY/82Cn3+njs7u/cJza034lcrOJifA7fXz29dfV2NNSuevQ1pqD3p6h7plZ4+13+vjs7s/l5u/sDX/9fHvHNWZ6irGdfqePz+7+eDzwdN+cSL/Tx2dff2Xv85+4OrXnhy98/d6elIzx9jt9fHb3" ..
    126 "9+TLteWndl//WzAw1Fmwavz9Th+f3f3ZHIkosmnNUBc/Abv1/IzMh9Evjspd0Yus/f2xN+seH7/Tx2dvf/OWjL4y4qXs8fU7fXx29+dyVx+MXJvR27ppzfj7nT4+u/vj8fM0/mP2jD3wTE2fCL/Tx2dnf2VbvD3h" ..
    127 "7dvdYnaFrZ1+p4/P7v74/e1b/hG+ccpXH06E3+njs7s/l/uxF/ru6Jzcrut3+vjs7a/20/A7TF9b9KdextPv9PHZ2196Nr/BHGOey79+bSL8Th+f3f3ZHIl6C8hZodP+RPsRCIRZpGTkrCjKe3Gx1dNbdP1OH5/d" ..
    128 "/SEmNh57YfGywjyzH5mx3+/08dndH4+s11flPv7SxPmdPj67+0NMZMzIzF055zfW3190/U4fn739TctYlauzutD1O318dvdna2DngkAgEAgEAoFAIBCISRFAgEAgEAgEAoFAIBCISRHRh1PT6yqGOoc66yqMr6NC" ..
    129 "HnnkkUceeeSRRx555JFHHvmHOB99WFcRuZGO8b00kUceeeSRRx555JFHHnnkkUf+Ic4zCIIgCIIgCIIgCJoEwgIYgiAIgiAIgiAImhRyRcVK/v+vJS4DIY888sgjjzzyyCOPPPLII4/8o5B3seTQU+6EooQlI488" ..
    130 "8sgjjzzyyCOPPPLII4/8o5qHIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiCEqf/A/SNfayCCBqGAAAAAElFTkSuQmCC"
    131 
    132 local options = require 'mp.options'
    133 local msg     = require 'mp.msg'
    134 
    135 options.read_options(opts)
    136 opts.height = math.min(12, math.max(4, opts.height))
    137 opts.height = math.floor(opts.height)
    138 
    139 local function get_visualizer(name, quality)
    140     local w, h, fps
    141 
    142     if quality == "verylow" then
    143         w = 640
    144         fps = 30
    145     elseif quality == "low" then
    146         w = 960
    147         fps = 30
    148     elseif quality == "medium" then
    149         w = 1280
    150         fps = 60
    151     elseif quality == "high" then
    152         w = 1920
    153         fps = 60
    154     elseif quality == "veryhigh" then
    155         w = 2560
    156         fps = 60
    157     else
    158         msg.log("error", "invalid quality")
    159         return ""
    160     end
    161 
    162     h = w * opts.height / 16
    163 
    164     if name == "showcqt" then
    165         local count = math.ceil(w * 180 / 1920 / fps)
    166 
    167         return "[aid1] asplit [ao]," ..
    168             "afifo, aformat     = channel_layouts = stereo," ..
    169             "firequalizer       =" ..
    170                 "gain           = '1.4884e8 * f*f*f / (f*f + 424.36) / (f*f + 1.4884e8) / sqrt(f*f + 25122.25)':" ..
    171                 "scale          = linlin:" ..
    172                 "wfunc          = tukey:" ..
    173                 "zero_phase     = on:" ..
    174                 "fft2           = on," ..
    175             "showcqt            =" ..
    176                 "fps            =" .. fps .. ":" ..
    177                 "size           =" .. w .. "x" .. h .. ":" ..
    178                 "count          =" .. count .. ":" ..
    179                 "csp            = bt709:" ..
    180                 "bar_g          = 2:" ..
    181                 "sono_g         = 4:" ..
    182                 "bar_v          = 9:" ..
    183                 "sono_v         = 17:" ..
    184                 "axisfile       = data\\\\:'" .. axis_0 .. "':" ..
    185                 "font           = 'Nimbus Mono L,Courier New,mono|bold':" ..
    186                 "fontcolor      = 'st(0, (midi(f)-53.5)/12); st(1, 0.5 - 0.5 * cos(PI*ld(0))); r(1-ld(1)) + b(ld(1))':" ..
    187                 "tc             = 0.33:" ..
    188                 "attack         = 0.033:" ..
    189                 "tlength        = 'st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))'," ..
    190             "format             = yuv420p [vo]"
    191 
    192 
    193     elseif name == "avectorscope" then
    194         return "[aid1] asplit [ao]," ..
    195             "afifo," ..
    196             "aformat            =" ..
    197                 "sample_rates   = 192000," ..
    198             "avectorscope       =" ..
    199                 "size           =" .. w .. "x" .. h .. ":" ..
    200                 "r              =" .. fps .. "," ..
    201             "format             = rgb0 [vo]"
    202 
    203 
    204     elseif name == "showspectrum" then
    205         return "[aid1] asplit [ao]," ..
    206             "afifo," ..
    207             "showspectrum       =" ..
    208                 "size           =" .. w .. "x" .. h .. ":" ..
    209                 "win_func       = blackman [vo]"
    210 
    211 
    212     elseif name == "showcqtbar" then
    213         local axis_h = math.ceil(w * 12 / 1920) * 4
    214 
    215         return "[aid1] asplit [ao]," ..
    216             "afifo, aformat     = channel_layouts = stereo," ..
    217             "firequalizer       =" ..
    218                 "gain           = '1.4884e8 * f*f*f / (f*f + 424.36) / (f*f + 1.4884e8) / sqrt(f*f + 25122.25)':" ..
    219                 "scale          = linlin:" ..
    220                 "wfunc          = tukey:" ..
    221                 "zero_phase     = on:" ..
    222                 "fft2           = on," ..
    223             "showcqt            =" ..
    224                 "fps            =" .. fps .. ":" ..
    225                 "size           =" .. w .. "x" .. (h + axis_h)/2 .. ":" ..
    226                 "count          = 1:" ..
    227                 "csp            = bt709:" ..
    228                 "bar_g          = 2:" ..
    229                 "sono_g         = 4:" ..
    230                 "bar_v          = 9:" ..
    231                 "sono_v         = 17:" ..
    232                 "sono_h         = 0:" ..
    233                 "axisfile       = data\\\\:'" .. axis_1 .. "':" ..
    234                 "axis_h         =" .. axis_h .. ":" ..
    235                 "font           = 'Nimbus Mono L,Courier New,mono|bold':" ..
    236                 "fontcolor      = 'st(0, (midi(f)-53.5)/12); st(1, 0.5 - 0.5 * cos(PI*ld(0))); r(1-ld(1)) + b(ld(1))':" ..
    237                 "tc             = 0.33:" ..
    238                 "attack         = 0.033:" ..
    239                 "tlength        = 'st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))'," ..
    240             "format             = yuv420p," ..
    241             "split [v0]," ..
    242             "crop               =" ..
    243                 "h              =" .. (h - axis_h)/2 .. ":" ..
    244                 "y              = 0," ..
    245             "vflip [v1];" ..
    246             "[v0][v1] vstack [vo]"
    247 
    248 
    249     elseif name == "showwaves" then
    250         return "[aid1] asplit [ao]," ..
    251             "afifo," ..
    252             "showwaves          =" ..
    253                 "size           =" .. w .. "x" .. h .. ":" ..
    254                 "r              =" .. fps .. ":" ..
    255                 "mode           = p2p," ..
    256             "format             = rgb0 [vo]"
    257     elseif name == "off" then
    258         return "[aid1] afifo [ao]; [vid1] fifo [vo]"
    259     end
    260 
    261     msg.log("error", "invalid visualizer name")
    262     return ""
    263 end
    264 
    265 local function select_visualizer(atrack, vtrack, albumart)
    266     if opts.mode == "off" then
    267         return ""
    268     elseif opts.mode == "force" then
    269         return get_visualizer(opts.name, opts.quality)
    270     elseif opts.mode == "noalbumart" then
    271         if albumart == 0 and vtrack == 0 then
    272             return get_visualizer(opts.name, opts.quality)
    273         end
    274         return ""
    275     elseif opts.mode == "novideo" then
    276         if vtrack == 0 then
    277             return get_visualizer(opts.name, opts.quality)
    278         end
    279         return ""
    280     end
    281 
    282     msg.log("error", "invalid mode")
    283     return ""
    284 end
    285 
    286 local function visualizer_hook()
    287     local count = mp.get_property_number("track-list/count", -1)
    288     local atrack = 0
    289     local vtrack = 0
    290     local albumart = 0
    291     if count <= 0 then
    292         return
    293     end
    294     for tr = 0,count-1 do
    295         if mp.get_property("track-list/" .. tr .. "/type") == "audio" then
    296             atrack = atrack + 1
    297         else
    298             if mp.get_property("track-list/" .. tr .. "/type") == "video" then
    299                 if mp.get_property("track-list/" .. tr .. "/albumart") == "yes" then
    300                     albumart = albumart + 1
    301                 else
    302                     vtrack = vtrack + 1
    303                 end
    304             end
    305         end
    306     end
    307 
    308     mp.set_property("options/lavfi-complex", select_visualizer(atrack, vtrack, albumart))
    309 end
    310 
    311 mp.add_hook("on_preloaded", 50, visualizer_hook)
    312 
    313 local function cycle_visualizer()
    314     local i, index = 1
    315     for i = 1, #visualizer_name_list do
    316         if (visualizer_name_list[i] == opts.name) then
    317             index = i + 1
    318             if index > #visualizer_name_list then
    319                 index = 1
    320             end
    321             break
    322         end
    323     end
    324     opts.name = visualizer_name_list[index]
    325     visualizer_hook()
    326 end
    327 
    328 mp.add_key_binding(cycle_key, "cycle-visualizer", cycle_visualizer)