Tom-Hirschberger / MMM-MplayerRadio

An MagicMirror² module which playes m3u radio playlists with MPlayer and supports various stations to rotate through
MIT License
7 stars 0 forks source link

Radio volume very low compared to other MagicMirror sounds #25

Closed lxne closed 1 year ago

lxne commented 1 year ago

Hi, I am using MplayerRadio with vlc. It works great, only the volume is pretty low even if system volume is at 100%. Is there a way to adjust the volume better to other sound outputs? Maybe by 'telling' vlc to stream louder?

Tom-Hirschberger commented 1 year ago

Hi,

as of https://wiki.videolan.org/VLC_command-line_help/ you may try the --gain option of vlc which supports values between 0.0 and 8.0. But be aware that to big values will cause a horrible sound.

Your custom commands section should look something like this example then:

  customCommand: "/usr/bin/vlc",
  customCommandArgs: ["--gain", "2.0", "-I","dummy","###URL###"],

It should be possible to set the option either for the whole module or only for some specific station.

lxne commented 1 year ago

Hi,

as of https://wiki.videolan.org/VLC_command-line_help/ you may try the --gain option of vlc which supports values between 0.0 and 8.0. But be aware that to big values will cause a horrible sound.

Your custom commands section should look something like this example then:

  customCommand: "/usr/bin/vlc",
  customCommandArgs: ["--gain", "2.0", "-I","dummy","###URL###"],

It should be possible to set the option either for the whole module or only for some specific station.

Thank you for your reply. Unfortunately --gain only distorts the audio but it won't make it louder.

I also tried --waveout-volume but then there is no audio output at all.

When I use the module EXT-RadioPlayer, which is also using vlc to play, I get normal volume levels. But that one is not as nice as yours and can't be controlled by buttons in a reasonable way.

Tom-Hirschberger commented 1 year ago

EXT-RadioPlayer uses a more complex way to call the vlc process, opens a reverse telnet shell and sets the volume by passing a command to the vlc process. I do not see a chance to integrate this way to my module but maybe there is a chance to set volume either in the GUI of vlc (which will be saved for the the next call) or with the tool pavucontrol which is a GUI to control PulseAudio.

lxne commented 1 year ago

Ok, what I found out:

MplayerRadio streams via vlc are being played back with the level that was last set when playing a stream via the GUI. If the level was set to 0, nothing can be heard via a command line call, even if one adds --gain 8 attribute to the command. An example I tried: cvlc http://streams.br.de/bayern1nbopf_2.m3u --gain 8

Somehow I can't believe that there is no way to set the volume level via command line!? Apparently there used to be a --volume attribute. When trying to use it, it says Warning: option --volume no longer exists. Also --volume-step does not affect the volume of the stream at all. And with --gain you can influence the volume only conditionally (provided the level is not 0) - but the more you boost the level with gain, the more distorted is the audio output.

At least I now know the workaround how to set the volume in the GUI.

lxne commented 1 year ago

With this little tool the job can be done: https://github.com/rhaas80/pa_volume

After installation for example ./pa_volume/pa_volume video 30 sets the volume for the stream to 30%.

Tom-Hirschberger commented 1 year ago

That's great to hear. If I have time I will try to write a small wrapper so you can set the volume in the module Config for each station. I am very busy at the moment but it should not be a big deal.

lxne commented 1 year ago

If I have time I will try to write a small wrapper so you can set the volume in the module Config for each station.

That would be a great addition to your awesome module!

Tom-Hirschberger commented 1 year ago

Just released version 0.0.14 of the module which contains a wrapper called vlcPaWrapper.bash that sets the volume with pa_volume before playing the stream. The wrapper takes two arguments. The first one is the volume the second one the url of the stream. I added a small part of documentation the the readme, too.

lxne commented 1 year ago

@Tom-Hirschberger Awesome! I will check it out on the weekend. Thank you!

lxne commented 1 year ago

Had to do it now :) Setting the volume works. But I got an issue. For controlling MplayerRadio I only use the three commands toggle/previous/next. Now if I use previous or next the already playing station won't stop but a second station starts. With each step forward or backward a new station starts but the old one won't stop. And the toggle command is then doing nothing.

This is actually a new issue. I would open a new one if you'd prefer that.

PS: And the command mv pa_volume/pa_volume . from your docs is not working, because the folder has the same name as the executable and it won't overwrite the folder. I had to rename the folder first. Then moving the file worked.

Tom-Hirschberger commented 1 year ago

Not good. I I am pritty sure I can look at the problems this weekend.

Tom-Hirschberger commented 1 year ago

I pushed a new version of the wrapper script a few seconds ago. It kills all vlc instances before the script itself closes. This should work now

lxne commented 1 year ago

Yes, so far it is working great! Thank you.

lxne commented 1 year ago

PS: And the command mv pa_volume/pa_volume . from your docs is not working, because the folder has the same name as the executable and it won't overwrite the folder. I had to rename the folder first. Then moving the file worked.

Maybe the easiest and best solution would be to move/copy the file to /usr/local/sbin. And change the script accordingly. That's what I did to be able to use the command anywhere.

Tom-Hirschberger commented 1 year ago

Ahhh. Sorry, forgot that issue. Just pushed a new version of the script and updated the README. The binary now is moved to /usr/local/sbin/ as you suggested.

lxne commented 1 year ago

Thank you! Just one little typo in the documentation. sudo chmod a+x /usr/local/bin/pa_volume You wrote 'bin' instead of 'sbin' there. Module works great!

Tom-Hirschberger commented 1 year ago

😂 Fixed now

lxne commented 1 year ago

blush sorry, now I saw After this process should have the binary pa_volume in the same directory as the wrapper script. in the following paragraph. Obviously this is not the case anymore. I will be quiet now. Good night.

lxne commented 1 year ago

Oh no, I still used the script edited by myself. Now I updated and realized two problems. You forgot the 's' in sbin in the script (line 34) and the -vvv in line 37 is messing things up. Was it -vv for verbose? In any case with -vvv the module doesn't do its job correctly. At first no audio is being played at all and after a view station changes suddenly multiple stations start playing. Kind of a strange behavior – and definitely not controllable :) /usr/bin/vlc -I dummy "$STREAM" & works for me.

Tom-Hirschberger commented 1 year ago

Sorry for the mess. I tried to integrate information about the current stream even if vlc is used. But vlc only displays the information in debug mode. I could not manage things to work yet.

I replaced the line and added the "s"

lxne commented 1 year ago

No worries. Sure, steam infos would be cool – but in the end only a goodie. Thank you.

Tom-Hirschberger commented 1 year ago

I integrated the stream information for vlc today. I needed to modify the options in the vlcPaWrapper.bash to enable the debug output and redirect it to stdout. If you use the new wrapper of the new version 0.1.0 of the module stream information should be visible if the station transmit it now.

lxne commented 1 year ago

Awesome. Works like a charm. Thank you!

Tom-Hirschberger commented 1 year ago

Great to hear that. Perfect. Have fun with the module and feel free to ask questions or create issues if needed.