MPD +卢阿 +康基
我需要帮助编写 conkyrc 文件。它(应该)调用一个 lua 脚本,该脚本读取 MPD 生成的 PCM 数据的 FIFO 管道。该 FIFO 用于在 NCMPCPP 中生成可视化,但我更希望它显示在桌面上的条形图上。是的,我知道它需要快速更新才能看起来不错。我希望我可以做一个更简单的可视化,而不是完整的频谱分析,不需要昂贵的 FFT 或小波......只是我可以将其传输到显示当前音乐活动的图表中。
[编辑] 取得了进展,尽管有很多忽悠因素...
我的 conkyrc 文件
lua_load /home/adam/Programming/myWork/conky/mpd.lua
update_interval .05
TEXT
HERP DEE DERP DEE DERP DEE DUUUR
${lua_bar fifo_func}
我的 lua 文件
do
-- configuration
local interval = 5
-- local variables protected from the evil outside world
local next_update
local buf
local int = 0
local colour = 0
local function update_buf()
buf = os.time()
end
local f = assert(io.open("/tmp/mpd.fifo", "rb"))
local block = 2048 * 2 --2048 samples, 2 bytes per sample
local list = {}
function conky_fifo_func()
local bytes = f:read(block) --read a sample of block bytes
local power = 0
for i = 0, 2047 do
--j = string.byte(bytes, 2*i, 2*i+1) --extract 2 bytes
j = string.format("%u", string.byte(bytes, i*2, i*2+1))
power = power + math.abs(j-(256/2))
--io.write(j..'\n')
end
r=((power/10000)-20) * 15
io.write(r .. '\n')
return r
end
-- returns a percentage value that loops around
function conky_int_func()
int = int + 1
return int % 100
end
end
基于 NCMPCPP源代码,FIFO是一个2048个16bit的数组整数
I need help writing a conkyrc file. It (should) call a lua script, which reads a FIFO pipe of PCM data generated by MPD. This FIFO is used to generate visualization in NCMPCPP but I'd rather it go to a bar graph on my desktop. And yeah, I'm aware that it would need to be updated pretty fast in order to look good. I'm hoping that instead of a full spectral analysis, I can do a simpler visualization that doesn't require an expensive FFT or wavlets... just something I can pipe into a graph showing activity of music at the moment.
[edit] Progress made, albeit with a lot of fudge factor...
my conkyrc file
lua_load /home/adam/Programming/myWork/conky/mpd.lua
update_interval .05
TEXT
HERP DEE DERP DEE DERP DEE DUUUR
${lua_bar fifo_func}
My lua file
do
-- configuration
local interval = 5
-- local variables protected from the evil outside world
local next_update
local buf
local int = 0
local colour = 0
local function update_buf()
buf = os.time()
end
local f = assert(io.open("/tmp/mpd.fifo", "rb"))
local block = 2048 * 2 --2048 samples, 2 bytes per sample
local list = {}
function conky_fifo_func()
local bytes = f:read(block) --read a sample of block bytes
local power = 0
for i = 0, 2047 do
--j = string.byte(bytes, 2*i, 2*i+1) --extract 2 bytes
j = string.format("%u", string.byte(bytes, i*2, i*2+1))
power = power + math.abs(j-(256/2))
--io.write(j..'\n')
end
r=((power/10000)-20) * 15
io.write(r .. '\n')
return r
end
-- returns a percentage value that loops around
function conky_int_func()
int = int + 1
return int % 100
end
end
Based on the
NCMPCPP source code, the FIFO is an array of 2048 16bit ints
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论