Conky & Ubuntu - music visualization (music bars)?

7,188

Solution 1

I think it is possible, using PulseAudio. I don't know how to go about it fully, but here is a utility I found that'll help you get the amplitudes - I suppose you could then find something to convert that into conky charts.

Solution 2

I know it has been quite a while since you posted this, however I found a great CLI visualizer the other day: https://github.com/dpayne/cli-visualizer

Now, this does not solve your update interval issue of course, but you still might find it as interesting as I do.

Share:
7,188

Related videos on Youtube

Eti
Author by

Eti

Played with Linspire (later forked to freespire), Ubuntu 5 / 6, OpenSUSE 8 / 9 / 10, Ubuntu 11.04, Linux Mint 11, Ubuntu 11.10. Among many others, I’m quite interested in: Rust, C++, all things GNU/Linux, Rust, gamedev (with Rust), reverse engineering, microservices, cloud, web development, Rust. I use Arch btw.

Updated on September 18, 2022

Comments

  • Eti
    Eti almost 2 years

    I started playing with Conky a few days ago and managed to achieve this:

    (Note: although I've written it from scratch, I got inspired by this photo, credits to the author for their creativity)

    As you can see, I have some free space between the digital clock ("21:20") and the connection statistics.

    Now I'd love to have what I called "music bars" in that space. That is, animated bars that move following the sound currently played by my music player (which is Clementine at the moment). I've already managed to display the current track, artist, year, etc. thanks to some scripts and the qbus command.

    However, I have to main questions:

    • How would I get the actual music data (I think it's called amplitudes)?
    • How would I animate that in a fairly smooth way?

    I'm using conky and lua with cairographics, but animation really seems to be something complicated, as I haven't found a way to make lua/cairographics "repaint". This forces me to reduce the update_interval in .conkyrc to achieve something "close" to an animation.

    Unfortunately, setting a very small value to update_interval makes conky consume a lot of CPU resources, because it doesn't only redraw every (for example) 50 milliseconds, but it also recalculates variables and re-executes scripts if necessary.

    Therefore, for the animation, I'm looking for a way have a smooth animation (10 fps would be enough) without making conky eat up the CPU resources.

    It would be awesome if anybody could give me some ideas. It does not necessarily have to be in LUA, and if there's a good alternative to conky (should be something lightweight), feel free to let me know!

    --

    Thanks a lot for the ideas and suggestions!

    • Admin
      Admin over 12 years
      This is close to impossible IMHO. You'll need to intercept and buffer audio data played by your player, then analyse it, to get info you are looking for.
    • Admin
      Admin over 12 years
      As long as it's acceptable in terms of performance (conky should remain lightweight), I don't mind doing complicated things. :-) However, I'm starting to think the main issue is the actual animation...
    • Admin
      Admin over 12 years
      I don't use conky, but from what I see I doubt it's designed to do more then one cycle per second while being usable. Let aside you'll have to do PSD on buffered signal and average it on bins that would be presented in your bars. It has nothing to do with amplitude and sorry to suggest, but I would just forget about it
    • Admin
      Admin over 12 years
      @zetah Indeed, but I think cairographics (which can used by conky, as I did) allows pretty advanced 2D drawing. If only I could find a way to make cairo redraw multiple times within one conky interval, a whole lot of problems would be solved!
  • Eti
    Eti over 12 years
    Now that's something useful! Thanks for your post. Yes, turning that into bars shouldn't be a big deal. My main concern is the update interval though... Having the bars move only once every second wouldn't look very exceptionnel I guess. :)
  • Vadim Peretokin
    Vadim Peretokin over 12 years
    Well, no - but you could either ask the author or modify it yourself to check on shorter intervals. It only checks once a second with this code: if (now < time(NULL)) { now = time(NULL); time being a function that returns second precision: cplusplus.com/reference/clibrary/ctime/time or you could remove the check entirely, though I'm not sure how fast would it be checking then (could be checking all the time and wasting your cpu)