martineausimon / nvim-lilypond-suite

Neovim plugin for writing LilyPond scores, with asynchronous make, midi/mp3 player, fast syntax highlighting, "hyphenation" function, and support for LaTex and Texinfo files
GNU General Public License v3.0
130 stars 11 forks source link

mpv player doesn't use my defaults #7

Closed kflak closed 1 year ago

kflak commented 1 year ago

Hi,

Getting a weird behavior from mpv when using LilyPlayer: For some reason it defaults to using the internal soundcard, even when all other mpv use gets routed through my external one via jack. In my mpv.conf I have

fs=yes
audio-device=jack 
vo=gpu

If I remove the config-dir flag in this function:

  vim.api.nvim_buf_call(lilyPlayer.bufnr, function() 
    fn.execute("term mpv --msg-level=cplayer=no,ffmpeg=no " ..
      "--loop --config-dir=/tmp/ " .. file)
    fn.execute('stopinsert')
  end)

everything seems to work normally, except that everything gets mixed to mono and routed into the left speaker. Adding the --audio-channels=stereo flag still results in mono, but at least it gets routed to both speakers.

So I guess the main problem here is that mpv doesn't source the user's config. Is there a specific reason for using /tmp instead?

EDIT: thinking a bit further on this: would it be an idea to expose the mpv flags to the user through a g: variable?

martineausimon commented 1 year ago

Hi,

Thanks for that feedback. I originally pointed the MPV config to /tmp to intentionally use the default mpv config (maybe /dev/null is a better way to do this). This is needed in case the user config contains different mappings, which can cause conflicts with the plugin.

But in any case I find the idea of being able to customize the mpv flags interesting, thank you for this suggestion ! I just added this variable to the setup() function :

require('nvls').setup({
  player = {
    options = {
      mpv_flags = "--msg-level=cplayer=no,ffmpeg=no --loop --config-dir=/dev/null"
    }
  }
})

Let me know if it works better for you !

Simon

martineausimon commented 1 year ago

I've just change mpv_flags to a table, I find it easier to config :

require('nvls').setup({
  player = {
    options = {
      mpv_flags = {
        "--msg-level=cplayer=no,ffmpeg=no",
        "--loop",
        "--config-dir=/dev/null"
      }
    }
  }
})
kflak commented 1 year ago

This is fantastic! I am also very happy that this allows me to choose in my config whether or not to loop playback. Most of the time I don't want that, so this kills numerous birds with one stone.

Oh, and thanks for finding a way to get nvim-cmp working. I didn't know about cmp-dictionary before. A total gamechanger!