isamert / empv.el

An Emacs media player, media library manager, radio player, YouTube frontend
GNU General Public License v3.0
107 stars 19 forks source link

Adding additional commands to empv such as audio filters #43

Closed tvraman closed 10 months ago

tvraman commented 1 year ago

Q: Why the two calls to empv-send-command?

Macro empv--transform-property --- https://github.com/isamert/empv.el/blob/main/empv.el#L637 has two calls to empv-send-command, I couldn't quite understand why.

Asking because I am thinking of implementing additional empv commands that add audio filters etc while something is playing.

isamert commented 11 months ago

Examine the following empv--transform-property call:

(empv--transform-property 'volume
  (lambda (current)
    (max (floor (- current empv-volume-step)) 0)))

The callback function gets the current volume. To be able to do so, empv--transform-property needs to get the current property value and then set it. Hence two calls to the empv--send-command function. First one with get_property command to get the given property and then the second one with the set_property command to set the given property.

If you have concrete ideas for the commands you want to write, we can work on them together.

tvraman commented 11 months ago

Thanks!

Here is why I was exploring that portion of the code:

I'd like to add audio filters on the fly.

I wrote myself this tiny hack to learn how: emacspeak-empv-toggle-filter https://github.com/tvraman/emacspeak/blob/master/lisp/emacspeak-empv.el#L203 The above is just a start and when complete should ideally go into empv.el.

Complete:

A. Build a completion table of available filters along with their argument spec -- we should do this by reflection -- may need to ask mpv folks to provide a json dict that lists all filters? B. Once that is available the rest is a small amount of elisp.

  Note: I built something similar years ago for mplayer -- but that
  was a bit of a hack in that I parsed out the available filters and
  their args from mplayer's  af=help output
  See https://github.com/tvraman/emacspeak/blob/master/lisp/emacspeak-m-player.el#L680

--

isamert commented 11 months ago

we should do this by reflection -- may need to ask mpv folks to provide a json dict that lists all filters?

Like mplayer, mpv also have mpv --af=help but I guess we don't want to go that route. I wasn't also able to find any way to retrieve available filter list through JSON IPC.

Otherwise, as you stated, it would be simply retrieving the filters and doing a basic empv--send-command.

tvraman commented 10 months ago

closing since mpv developers indicate this is not going to become feasible any time soon