One quick way is to run a script in the background checking for the existence of a few processes. The bash script should work if you use all RetroArch emulators, and will play random mp3s in the background until a game is launched.
#!/bin/bash
while true; do
RA=$(pgrep retroarch)
ES=$(pgrep emulationstat)
M123=$(pgrep mpg123)
if [ "$RA" ]; then
pkill mpg123
elif [ ! "$RA" ] && [ ! "$M123" ] && [ "$ES" ]; then
mpg123 -q -Z ~/RetroPie/media/mp3/* &>/dev/null &
fi
sleep 1
done