karlstav / cava

Cross-platform Audio Visualizer
MIT License
4.3k stars 234 forks source link

[GUI] CAVA GUI Foreground Opacity not working #192

Closed rharish101 closed 6 years ago

rharish101 commented 6 years ago

I know that the comments in the config mention that it's buggy, but it's not working at all!

With a light background: cava-colour

With a dark background (this screenshot was before the overshooting fix): cava-overshoot

nikp123 commented 6 years ago

It works fine, I see transparency in those screenshots (although they are subtle).

Firstly it's hacky code. There is no "legit" way of doing this in Xlib. I think you'll have much more luck with OpenGL. The code basically does this: foreground_color = (opacity*255)<<24 + foreground % 0x1000000;

Non-techy: I'm touching variables that I shouldn't do normally in my code.

It's results are unpredictable, but it created an interesting effect so I decided to leave it in as an option.

rharish101 commented 6 years ago

Actually, I intended to have no transparency, and thus I opened up this issue since the transparency's not changing at all. I also have enabled OpenGL support. I also tried out this one: https://github.com/HaCk3Dq/spectrumyzer . Opacity control works well with this app, though it's missing some features from CAVA, and it's only GUI. You could look into this if you're interested.

nikp123 commented 6 years ago

@rharish101 This is actually an issue. Will commit patch soon.

Source of issue: OpenGL context doesn't have transparency by default.

nikp123 commented 6 years ago

Patch applied, recompile and test again. Thanks for finding out this (makes shadows look better TBH). I didn't know it was broken.

rharish101 commented 6 years ago

It sorta works; I can change transparency, but I still can't get full opacity. Here are 2 images: At value 0.5: cava-half At value 1.0: cava-full 100% opacity is still missing though.

nikp123 commented 6 years ago

@rharish101 Have you recompiled? I didn't notice this issue in my testing.

rharish101 commented 6 years ago

Yeah, I reinstalled it from the AUR, which should recompile it. Also, it there was no difference between values 0.5 and 1 before your patch.

nikp123 commented 6 years ago

@rharish101 Sorry but I couldn't reproduce the issue. IDK, what's wrong. Have you tried commenting the line and see if that works.

rharish101 commented 6 years ago

Yeah, I tried that; it has the same effect as opacity value 1.0. Also, if I disable transparency, I get this error:

TERMINATED
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  44
  Current serial number in output stream:  45

Maybe it's related? Meanwhile, here's my config in txt format: config.txt

nikp123 commented 6 years ago

@rharish101 You can't disable transparency and have opacity. I forgot to put a error check, I guess.

TODO: ^

nikp123 commented 6 years ago

@rharish101 Just vertified it on my Arch rig. Even with your configuration it works fine. Are you using a non-standard system fxp. running in Wayland or using a heavy compozitor as compiz? Are you running propriatery drivers such as nvidia ones (those cause a ton of problems)? Sorry for asking, but may you share system specs? It will be really helpful if you do.

rharish101 commented 6 years ago

Yeah sure:

nikp123 commented 6 years ago

@rharish101 The issue is at driver level, nVidia drivers by default don't support transparent GLX windows. To fix this:

1) Backup /etc/X11/xorg.conf 2) Run " sudo nvidia-xconfig -d 24 --add-argb-glx-visuals --allow-glx-with-composite --randr-rotation" 3) Reboot/restart X properly 4) Run cava again

rharish101 commented 6 years ago

The command nvidia-xconfig did not accept --randr-rotation. Also, after doing it without the last flag, GDM started at a lower resolution, and logging in showed a black screen. Is there some other way?

nikp123 commented 6 years ago

@rharish101 But still the issue is not on my end, nVidia have "non-feature complete" drivers. There are workarounds however, 1) Use i915 drivers for openGL instead 2) Switch to nouveau completely 3) Try that command patch if none of these worked.

The issue remains open, sorry but I can't help much since the whole thing is built upon GLX. And nVidia drivers don't like the GLX alpha channel.

rharish101 commented 6 years ago

Well, I can't switch to nouveau since I need the Nvidia drivers for Tensorflow. I'll look into the 1st one and try it out. Anyway, thanks for the support. I'll close the issue.

nikp123 commented 5 years ago

@rharish101 i figured it out finally.... turns out that nvidia drivers need Xrender in order to have a proper color profile

first test on an dedicated nvidia gpu seems to work, i'll push this update once it doesn't break half of the code

screenshot: https://i.imgur.com/p90Rz8c.png

nikp123 commented 5 years ago

the issue was that the transparency was calculated as a subtraction from the pure white color in RGB space and as such caused that bug, still curious about why it only happens on the nvidia driver (its not hardware because nouveau fixes this)

edit: the nvidia driver ignores the alpha channel completely without this

nikp123 commented 5 years ago

@rharish101 https://i.imgur.com/wLOCIhZ.png we got the same gpu now lol

nikp123 commented 5 years ago

commit applied

credit due: https://stackoverflow.com/questions/40676229/linux-x11-transparent-opengl-object-on-transparent-window-with-solid-backgroun

rharish101 commented 5 years ago

Awesome! Could you now update the AUR PKGBUILD soon? It's the only thing left.

nikp123 commented 5 years ago

@rharish101 updated, however things have changed:

1) foreground_opacity doens't work (as you can tell) it does, I was just using it wrong 2) it's not cava-gui it's xava now

rharish101 commented 5 years ago

Thanks for updating the AUR package! I have two issues now:

  1. Background transparency is not working, ie. there is no transparency at all when I use the Nvidia drivers (I'm now using bumblebee to use the GPU only on demand), but everything works well with the Intel integrated card.
  2. The config file that is auto-created is empty. I'm currently using the older one.
nikp123 commented 5 years ago

@rharish101 Sorry if i sound rude a bit here, but I don't think bumblebee should be or was EVEN INTENDED used for any type of compositing application since it emulates an invisible X server and just copies the image into a new window (that includes the background too, so no transparency is just the result of that). Just to remind you that the last commit was from 2013 so don't expect any good support/results.

You can try running a another transparent app through bumblebee and see if it creates a desired result, I could be totally wrong on this, idk.

But yeah, I should sort out the config thing.