Page 1 of 1

How to add music in the background when I open Emulation Station?

Posted: Sun Oct 31, 2021 2:45 am
by redandwhitestripes

Hi everyone,

I'm after a particular script to run in both Puppy and Linux Mint.

Quick bit of explanation: Emulation Station is software that runs inside Retropie. It launches video game emulators from separate software called Retroarch.

What I am after is a service to play music from a particular directory in the background when I open Retropie and emulation station (ES) and move through my game lists, and fade out when I launch a game inside ES and Retroarch starts. When I close the game and return to the ES menu, thus closing Retroarch, I'd like the music to start again.

I'm guessing a console-based player would be the best choice. I also guess that the script will tell Linux to check when ES services are running to start the player, then kill the player when the Retroarch services start, then kill the music player when those services stop. How to draft that though, I have no idea! I can use MOCP or any other console player, but it needs to *not* open a window.

Any help appreciated.


Re: How to add music in the background when I open Emulation Station?

Posted: Sun Oct 31, 2021 9:45 am
by mikewalsh

@redandwhitestripes :-

Mm. Okay; sounds 'do-able', I guess.

What are we talking about here? Steadily working its way through a playlist of tunes.....or a single piece of music, repeated over & over? How much time, on average, would you say you spend browsing your lists before choosing a game?

It's easy enough to get music to play in the background. Peebee's Pups have had a 'startup sound' for a long while - that plays after 'X' has started (an idea I pinched for my own Pups. I found a startup jingle I like, and I use the old XP one at shutdown). This uses mplayer from the command-line for actually playing, along with setting the volume to a specific level before it does so.

Code: Select all

#!/bin/sh
amixer -c 0 -- sset Master playback -36dB
mplayer /usr/share/audio/logon-1.mp3 &

(You get the 'dB' reading by running 'alsamixer' in the terminal, setting the volume to where you want it to be, then noting the dB readout in the mixer. You then use that as the value in the script.)

The point being that you need to have a trigger for your script. My startup one runs from /root/Startup, and the shutdown one is linked in to the 'wmpoweroff' script. So; as you say, can the script detect when startup routines are running for Retroarch? That's the bit we need to work out.....

Mike. ;)


Re: How to add music in the background when I open Emulation Station?

Posted: Sun Oct 31, 2021 12:41 pm
by redandwhitestripes

Thanks Mike! What I'm after is for my music player to play a random track from a specified folder.

I would happily attach the script to a keyboard shortcut that I launch at the same time I launch Retropie. In my mind, the trigger for fade out would be when Retroarch process start.

If it helps, I saw this script on another page, it won't work in Puppy or Mint I fear, but some of it looks familiar.

while pgrep omxplayer >/dev/null; do sleep 1; done
(sleep 5; mpg123 -f 5000 --random /home/pi/RetroPie/roms/bgm/*.mp3 >/dev/null 2>&1) &
emulationstation #auto