mihaiolteanu / vuiet

The music player and explorer for Emacs
https://mihaiolteanu.me/vuiet
GNU General Public License v3.0
278 stars 15 forks source link

Title: Add volume control to mpv #20

Closed tvraman closed 4 years ago

tvraman commented 4 years ago

mpv --- the program --- can adjust volume via softvol, ie you can independently increae/decrease volume of the playing track relative to the volume level of your soundcard. Could we add support for this in mpv, so it can be used from vuiet?

mihaiolteanu commented 4 years ago

Hello Raman,

Yes, I think that should be easy enough. I'm not listening anything much except last.fm on my machine, that's why I haven't even thought about it.

My question now is, would a volume indication in the mode-line also help? And, once set, I would expect the user would want for the same volume to persist between auditions. So, then, a defcustom with the selected volume should also be implemented? Maybe even saving it between sessions?

tvraman commented 4 years ago

Title: Add volume control to mpv

Hi

I think we mostly need the volume control because volume is not normalized across all tracks, ie some tracks can be louder. So the volume control is something I'd expect the user only if a track is too loud or too soft, so persisting it etc likely are not useful. Ditto re showing it on the modeline --- think of the vol control as something you use rarely.

For now, I'm also using lastfm, and I think what I play is streaming from youtube -- at least pidof mpv shows a ytdl://ytsearch url.

mihaiolteanu commented 4 years ago

Yes, both vuiet and the lastfm website are streaming directly from youtube.

I think we mostly need the volume control because volume is not normalized across all tracks

I agree, but I'm using the volume control of my machine for that. I don't find much use for mpv volume control on top of that. Or am I missing something?

tvraman commented 4 years ago

Title: Title: Add volume control to mpv

If mpv is the only thing playing audio, then you're correct, you can use the master volume on your machine.

In my case, that is not so --- my machine is talking to me using the sound-card; and in that case, mpv's ability to use softvol to control the volume of the music playback means that I can increase/decrease music volume independent of the text-to-speech volume. Hope this helps clarify --

mihaiolteanu commented 4 years ago

It makes sense, thanks for taking the time to explain why you need it. I've added it. Let me know if anything bad comes up :)

tvraman commented 4 years ago

thanks will pull and use --- thanks for adding it. --

tvraman commented 4 years ago

Title: Add volume control to mpv

The code in vuiet works correctly for volume inc/dec, however the underlying mpv has a bug/problem (the mpv executable, not your library).

Problem: You can tell mpv which mixer to use for changing volume, the choices are "master" (global volume) or "pcm". Default is "master", so I set alsa-mixer-device=pcm in my mpv.conf file.

But if you do that, mpv throws an error when you get/set property "ao-volume" with the message "no such property available".

The error goes away if I take the mvp.conf setting away ---

mihaiolteanu commented 4 years ago

I've modified the code to use the volume property instead of ao-volume. I think this should be the right property to use. In my case, the volume control works with both, but the documentation for mpv clearly states that ao-volume is prone to errors, depending on your sound card (if I understand correctly).

Let me know if this works for you.

tvraman commented 4 years ago

thanks, will try it soon. --

tvraman commented 4 years ago

Title: Add volume control to mpv

Did an update, reloaded vuiet.

It was still setting master volume.

then I remembered mpv.conf, and uncommented alsa-mixer-device=pcm now, it throws an error saying cannot get property.

tvraman commented 4 years ago

It's working!

At least if I call mpv-set-property directly it works correctly with alsa-mixer-device=pcm

Suspect something just goes wrong because the vuiet from melpa doesn't have the newest bits and something is getting loaded in the wrong order. Will wait a couple of days for everything to refresh, and report back if the problem persists.

But for now calling mpv-set-property like so (mpv-set-property "volume" 85) does the write thing, ie does not affect master volume but turns down the music volume.