RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Background Music [Continued from Help/Support]

    Scheduled Pinned Locked Moved General Discussion and Gaming
    musicbgm
    343 Posts 109 Posters 325.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      smellslikekimchi @synack
      last edited by

      @synack @ZingZonZot aha, thank yall for this. I will hold off until I can figure out a way to have it stop on sleep. I'm new to this so it may take me a while. I'm curious, at cursory glance at Livewire's code do you think it would pause music during sleep?

      synackS 1 Reply Last reply Reply Quote 0
      • synackS
        synack @smellslikekimchi
        last edited by

        @smellslikekimchi sorry, but no -- it would not stop.

        S 1 Reply Last reply Reply Quote 0
        • S
          smellslikekimchi @synack
          last edited by

          @synack roger that. Thank you for your help

          1 Reply Last reply Reply Quote 0
          • Z
            ZingZonZot @ZingZonZot
            last edited by

            nevermind I solved my own game sound issue, @synack Thank you for your help I really appreciate it, man!

            1 Reply Last reply Reply Quote 1
            • K
              karmakode @synack
              last edited by

              @synack good stuff man i was able to get this to work but i noticed whenever i try to go to retropie setup in the menu the screen goes black and i cant see anything but can hear the music still.....Did i do something wrong?

              1 Reply Last reply Reply Quote 0
              • K
                karmakode @synack
                last edited by

                @synack nevermind i was ssh into the pi at the same time. thats why i was getting a blank screen. it would be awesome if there was a way to get different music when your in each system like recallbox

                1 Reply Last reply Reply Quote 0
                • R
                  raspy+
                  last edited by

                  @synack

                  thank you very much for this wonderful method!

                  if I was to type "emulationstation" at the command-line can I get the player to start again or do I have to reboot to autostart the process?

                  Thanks,

                  synackS 1 Reply Last reply Reply Quote 0
                  • synackS
                    synack @raspy+
                    last edited by

                    @raspy+ You can either reboot or execute the autostart.sh script which will invoke the mp3 player as well as emulationstation.

                    /opt/retropie/configs/all/autostart.sh
                    
                    R 1 Reply Last reply Reply Quote 0
                    • R
                      raspy+ @synack
                      last edited by raspy+

                      @synack

                      thanks for your quick response! ... I did a little poking around on the internet and even read up on how to make a basic shell script since I am such a noob. I just end up modifying the existing (/usr/bin/emulationstation) script by adding your script before "clear" and after "reset" like so and I can launch "emulationstation" with the same results from command-line:

                      #!/bin/bash

                      if [[ $(id -u) -eq 0 ]]; then
                      echo "emulationstation should not be run as root. If you used 'sudo emulationstation' please run without sudo."
                      exit 1
                      fi

                      if [[ "$(uname --machine)" != 86 ]]; then
                      if [[ -n "$(pidof X)" ]]; then
                      echo "X is running. Please shut down X in order to mitigate problems with losing keyboard input. For example, logout from LXDE."
                      exit 1
                      fi
                      fi

                      while pgrep omxplayer >/dev/null; do sleep 1; done
                      mpg123 -Z /media/usb0/music/*.mp3 2>/media/usb0/music/playlist &

                      clear
                      tput civis
                      "/opt/retropie/supplementary/emulationstation/emulationstation.sh" "$@"
                      reset

                      pkill mpg123

                      EDIT: I forgot to mention that even though I can execute the "autostart.sh" script to achieve the same thing however I have Kodi booting first and I wanted to just launch emulationstation when I am at the command-line.

                      Thanks,

                      S 1 Reply Last reply Reply Quote 1
                      • M
                        MoMan_
                        last edited by

                        Audio continues playing when running ">ports_" games (Super Mario War, at least).

                        What would I add to the script to kill audio when playing ported games?

                        1 Reply Last reply Reply Quote 1
                        • S
                          smellslikekimchi @raspy+
                          last edited by

                          @raspy+ Thank you for this update. This in conjunction with @synack 's tutorial gave me exactly what I wanted except for one small question:

                          When I exit a game the menu music comes back on immediately when I exit to the game select screen. How do I add a bit of delay or "sleep" until the music starts back up again?

                          Thanks!

                          synackS 1 Reply Last reply Reply Quote 0
                          • synackS
                            synack @smellslikekimchi
                            last edited by

                            @smellslikekimchi

                            to force a delay, edit /opt/retropie/configs/all/runcommand-onend.sh and instead of

                            pkill -CONT mpg123
                            

                            use

                            (sleep 2; pkill -CONT mpg123) &
                            

                            Of course, adjust the sleep # to your heart's desire.

                            S 1 Reply Last reply Reply Quote 0
                            • S
                              smellslikekimchi @synack
                              last edited by

                              @synack you are a king among peasants. This worked like a charm. Thank you again for your help.

                              1 Reply Last reply Reply Quote 0
                              • C
                                CraveClone
                                last edited by

                                @Livewire
                                Just wanted to say thanks for the script, just what i was looking for and it worked perfectly!

                                1 Reply Last reply Reply Quote 0
                                • D
                                  dragon3gabriel
                                  last edited by

                                  Script is working great, music is fully loaded and works fine turning it self off and back on across many different emulators except one. When I load up PPSSPP, it continues with out pause. Any solution to mute it like the other emu's?

                                  1 Reply Last reply Reply Quote 1
                                  • C
                                    Concat
                                    last edited by Concat

                                    I did a search and it seems there is a command to control volume: https://sourceforge.net/p/mpg123/feature-requests/35/

                                    Any idea how to implement...?

                                    EDIT: I just added -f 5000, and it reduced the volume. Choose a number between 1 and 32768

                                    mpg123 -f 5000 -Z /home/pi/Music/*.mp3 >/dev/null 2>&1 &

                                    Also, normally emulationstation loads while my video splashscreen is playing. Of course, now everything waits for the video to be done, so I have to sit through emulationstiation loadscreen. Plus I see the terminal flash in between. No longer seamless boot up. Is there no way to get the music going AFTER emulationstation has started?

                                    1 Reply Last reply Reply Quote 0
                                    • C
                                      Concat
                                      last edited by

                                      Hmmm terminal is spitting out "ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred" now.

                                      S 1 Reply Last reply Reply Quote 0
                                      • C
                                        Concat
                                        last edited by Concat

                                        In autostart I put:

                                        emulationstation & 
                                        while pgrep omxplayer >/dev/null; do sleep 1; done; 
                                        mpg123 -f 5000 -Z /home/pi/Music/*.mp3 >/dev/null 2>/dev/null &
                                        while (ps x |grep -v grep |grep -c "emulationstation")>0;do sleep 1; done;
                                        pkill mpg123; exit
                                        

                                        This makes sure emulationstation loads while the video splashscreen is playing, and then as soon as the video is over, mpg123 plays. No more ES load screen.

                                        The script monitors processes for the string "emulationstation". As soon as it gets no results, it kills mpg123. This ensures when you exit emulationstation, you don't get stuck in the script with the music playing

                                        -f 5000 is for volume. See above.

                                        I'm a total noob, so this is just cobbled together from some googling. I have no idea if this is very efficient.

                                        fellegF W 2 Replies Last reply Reply Quote 0
                                        • fellegF
                                          felleg @Concat
                                          last edited by felleg

                                          @Concat That's a neat idea! However, I only have one problem. When my video plays, I can see the white borders of EmulationStation loading in the background (my video is a square shape). What could fix this? Also, strangely, the music does not start at all when ES is launched.

                                          I started writing this post before you edited yours, so I only have tried the first three lines of your code. I also get the black screen upon editing ES, which you mentionned in your post before editing it. Fortunately, just pressing enter makes the terminal active again.

                                          I'd like to implement your code, but so far it brings more problems for me. If I find what I was doing wrong, I'll let you know. By the way, neat find about the volume control for mpg123! I looked in their manual, and -f is to "scale". There is no mention of volume anywhere, it's like they made it cryptic on purpose :P

                                          Edit: just FYI, I used -f 20000 instead of -f 5000 for mpg123 as you wrote in your post. I think 5000 is not loud enough ;)

                                          1 Reply Last reply Reply Quote 0
                                          • C
                                            Concat
                                            last edited by

                                            @felleg
                                            Hey, the video splashscreen just renders on top, so that's why you can see the white of ES around it. I assume the easiest fix would be to just make a 16:9 video so it fills the screen.

                                            I'm not sure about the other issues you're having. Did you only just try to implement this, or was it working for you before? ...what version of RetroPie are you running? ...and are you sure you put the music into the right folder? If you look at my code, you'll see I have mine in /home/pi/Music

                                            As for volume, I wasn't recommending 5000, that's just what I have. Maybe the track I have is just really loud.

                                            This page lists the arguments: https://linux.die.net/man/1/mpg123

                                            I see a few RVA arguments that sound like they normalize the volume from track to track. I will probably try to include this as well.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.