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

    Arcade Ambience MP3

    Scheduled Pinned Locked Moved Ideas and Development
    mp3ambientbackgroundmusic
    23 Posts 14 Posters 13.3k 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.
    • GraboidG
      Graboid
      last edited by

      Hi All,

      It would be great that once ES has booted and you are scrollinjg through the menus, that it could pllay one of the Arcade Ambience MP3's located here Arcade Ambience Project to give that 'being in an arcade' feel.

      Not sure if possible, but would be a great addition.

      Built Space Invaders Themed Bartop - Check it out here:- https://retropie.org.uk/forum/topic/5593/space-invaders-themed-bartop-arcade-uk-completed

      BriganeB 1 Reply Last reply Reply Quote 0
      • BriganeB
        Brigane @Graboid
        last edited by

        @Graboid I agree with you that this could be a nice feature. Personally I think that all these mixed sounds are quite annoying. It's just static to my ears. I'm almost certain that the RetroPie building team will make it happen when the time is right :)

        Systems: Raspberry Pi 0/2/3 Model B+
        Os: RetroPie 4.5
        Frontend: Emulationstation & Attract Mode

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

          I have something set up to play background mp3s while in the ES menus --

          1. install mpg123 (my command line mp3 player of choice)
          sudo apt-get install mpg123
          
          1. make folder to store the mp3s, then copy mp3s here
          mkdir /home/pi/bgm
          
          1. create a script to play the music while ES is running but not retroarch/Kodi
          nano /home/pi/bgm.sh
          

          copy/paste the following

          #!/bin/bash
          while true; do
            RA=$(pgrep retroarch)
            ES=$(pgrep emulationstat)
            PLAYER=$(pgrep mpg123)
            KODI=$(pgrep kodi.bin)
          
            if [ "$RA" ] || [ ! "$ES" ] || [ "$KODI" ]; then
              pkill mpg123 &>/dev/null
            elif [ ! "$RA" ] && [ ! "$PLAYER" ] && [ ! "$KODI" ] && [ "$ES" ]; then
              SONG=$(ls /home/pi/bgm/*.mp3 | shuf -n1)
              mpg123 -q "$SONG" &
            fi
          
            sleep 2s
          done
          
          1. set the bgm.sh script to be executable
          chmod a+x /home/pi/bgm.sh
          
          1. Have the script called on startup. Edit your /etc/rc.local and before the exit 0 line, add the following:
          /home/pi/bgm.sh &>/dev/null &
          

          150 of my favorite NES chiptunes in (mp3 format) are available at the following location in case anyone is interested:
          https://dl.dropboxusercontent.com/u/23611685/open/NES_bgm.zip

          meleuM S MapleStoryM 3 Replies Last reply Reply Quote 2
          • meleuM
            meleu @synack
            last edited by

            @synack Maybe you can improve your scheme taking advantage of runcommand-onstart and runcommand-onend scripts (avoiding the checking every 2 seconds). ;-)

            • Useful topics
            • joystick-selection tool
            • rpie-art tool
            • achievements I made
            synackS 1 Reply Last reply Reply Quote 0
            • synackS
              synack @meleu
              last edited by

              @meleu Thank you, I was not aware of that part of the system.

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

                @synack Couple this be setup to play certain sounds on certain sub menus? like the Arcade Ambience for MAME/FBA, and a Nintendo one for NES/SNES, or is this only play in the main ES menus?

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

                  @Sinistar83 As far as I'm aware, ES doesn't provide an external indicator to tell you what menu set it's currently on, so proactively changing the mp3 is probably not possible. However, using the runcommand-onend script that @meleu mentions, you can read the the parameters passed to it and determine if you're existing MAME or something else. From there, you can set the desired tune accordingly -- but of course, only retroactively on exit of a particular emulator. If you're not hopping from system to system constantly, this could be a worthwhile solution.

                  I've got my current system boxed up already for a secret santa gift, but plan on building another in a few days. I'll try to revisit this thread and provide some updated instructions.

                  D W 2 Replies Last reply Reply Quote 1
                  • D
                    detron @Brigane
                    last edited by

                    @Brigane I am with you, would like to see this, and agree that the best execution of this would be by the build team, however, I do understand that there are probably higher priorities than this.

                    1 Reply Last reply Reply Quote 1
                    • MapleStoryM
                      MapleStory @synack
                      last edited by

                      @synack Just tried your script and I still can't get music to play. I copied all the code line for line and pasted it via Putty. Is there a step missing or a mistake anywhere in the code itself?

                      B 1 Reply Last reply Reply Quote 0
                      • B
                        backstander @MapleStory
                        last edited by

                        @MapleStory
                        You also need to make the script executable:

                        chmod +x /home/pi/bgm.sh
                        
                        MapleStoryM 1 Reply Last reply Reply Quote 2
                        • MapleStoryM
                          MapleStory @backstander
                          last edited by

                          @backstander said in Arcade Ambience MP3:

                          chmod +x /home/pi/bgm.sh

                          That did the trick, huge thanks for that! Just one last thing. Is there some way to lower music volume to say, 70%? The music comes out blasting sometimes after playing a game. haha

                          B 1 Reply Last reply Reply Quote 1
                          • B
                            backstander @MapleStory
                            last edited by

                            @MapleStory

                            There's an alternate RetroPie BGM python script by @Livewire that has an option to set a volume and fade out & in:
                            https://retropie.org.uk/forum/topic/347/background-music-continued-from-help-support

                            I believe all he is doing is added mixer.music.set_volume(70); to set the volume to 70%

                            I'm not much of a python programmer so I'm not sure if you'd need to run sudo apt-get install python-pygame first for this to work or not.

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

                              It looks like @Livewire put some thought into his setup, definitely worth checking out.

                              However, I'm probably going to stick with what I know. Using the runcommand-onend.sh script mentioned earlier in the thread, another quick and easy method for BGM would be the following (and doesn't require checking for various processes every couple of seconds)

                              1. edit /etc/rc.local and insert the following before the "exit 0" line
                              (sleep 10; sudo -u pi mpg123 -Z /home/pi/bgm/*.mp3 >/dev/null 2>&1) &
                              

                              change the sleep time as needed before music starts playing
                              2) edit/create /opt/retropie/configs/all/runcommand-onstart.sh and add the following

                              pkill -STOP mpg123
                              
                              1. edit/create /opt/retropie/configs/all/runcommand-onend.sh and add the following
                              pkill -CONT mpg123
                              
                              1. make sure both scripts are executable
                              chmod a+x /opt/retropie/configs/all/runcommand-onstart.sh
                              chmod a+x /opt/retropie/configs/all/runcommand-onend.sh
                              

                              If you wanted to play music based on the system you're exiting, instead of adding the command above to runcommand-onend.sh, you can add a check like the following and then play mp3s from the desired directory

                              if [[ $1 == *mame* ]]; then
                                pkill mpg123
                                mpg123 -Z /path/to/mame/mp3s/*.mp3 >/dev/null 2>&1 &
                              else
                                pkill -CONT mpg123
                              fi
                              
                              1 Reply Last reply Reply Quote 2
                              • D
                                df13 @synack
                                last edited by

                                @synack I like your script a lot since it's just an mp3 player in the background. However, I had an idea.
                                Although ES doesn't detect what menu you're on, the theme should detect it right? If so, would it be possible to alter the .xml of the theme and tell it to play a certain folder of bg music?

                                I know very little about programming so I could be way off, but it's just an idea.
                                Thanks for the script by the way!

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

                                  @df13 Unfortunately no, it doesn't work like that since the music playing is completely external. If ES accessed the individual XML files every time a new system was selected it would be possible using the 'last accessed time' of the files, but ES loads all of the files upon startup.

                                  D 1 Reply Last reply Reply Quote 0
                                  • K
                                    kcsims
                                    last edited by

                                    when running arcade games using pifba emulator, the music doesn't stop playing...any fix?

                                    1 Reply Last reply Reply Quote 0
                                    • D
                                      deadeye @synack
                                      last edited by

                                      @synack This is actually a really great and simple solution... But I'm not sure if I'm going crazy or not, but it doesn't seem to kill mpg123 if I boot up Kodi. Not sure why that would be.

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

                                        @deadeye I don't know either. Is it only with Kodi? I also use it and have confirmed it works on my side.

                                        Make sure you're using the latest version of the runcommand script and ensure /opt/retropie/configs/all/runcommand-onstart.sh contains pkill -STOP mpg123

                                        D 2 Replies Last reply Reply Quote 1
                                        • D
                                          deadeye @synack
                                          last edited by

                                          @synack thanks - yeah, it works for everything else. I tried both iterations you posted. The first didn't kill when loading up n64/kodi, the latter just kodi. I'll try updating and see if that changes anything. I'll post back to confirm. Cheers.

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

                                            @synack Ah, figured it out. It's only an issue if KODI is launched as an emulator. If I launch it through the Ports, it kills the music.

                                            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.