{"id":965,"date":"2021-02-10T01:39:11","date_gmt":"2021-02-10T01:39:11","guid":{"rendered":"http:\/\/bullyrooks.com\/?p=965"},"modified":"2021-02-10T02:35:51","modified_gmt":"2021-02-10T02:35:51","slug":"adding-background-music-to-emulationstation","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/10\/adding-background-music-to-emulationstation\/","title":{"rendered":"Adding Background Music to EmulationStation"},"content":{"rendered":"\n<p>One of the features I saw used in some of the images I looked at was background music playing while browsing the library.  I&#8217;ll show you how to get that setup.<\/p>\n\n\n\n<p>I&#8217;ll be following <a href=\"https:\/\/www.reddit.com\/r\/RetroPie\/comments\/617tnn\/quick_and_easy_guide_to_adding_music_to\/\">the instructions here<\/a> for the most part.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up mpg123<\/h2>\n\n\n\n<p>SSH into your Pi and run this command to install the mpg123 package<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pi@retropie:~ $ sudo apt-get install mpg123\nReading package lists... Done\nBuilding dependency tree\n...<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Enable Music on Start<\/h2>\n\n\n\n<p>First, create a location to store the music files.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> $ mkdir RetroPie\/roms\/bgm<\/code><\/pre>\n\n\n\n<p>Edit the autostart script<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/opt\/retropie\/configs\/all\/autostart.sh<\/code><\/pre>\n\n\n\n<p>add this line above<code> emulationstation #auto<\/code> (following <a href=\"https:\/\/manpages.debian.org\/unstable\/mpg321\/mpg123.1.en.html\">the docs here<\/a>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while pgrep omxplayer >\/dev\/null; do sleep 1; done\n(sleep 5; mpg123 -f 5000 --random \/home\/pi\/RetroPie\/roms\/bgm\/*.mp3 >\/dev\/null 2>&amp;1) &amp;\nemulationstation #auto\n<\/code><\/pre>\n\n\n\n<p>We&#8217;re telling the player to wait 5s to start up, then start the mpg player at 15% volume (5000\/32768) and play at random all of the mp3 files in the <code>RetroPie\/roms\/bgm<\/code> folder (that we just created).  Hit ctrl-o, enter, ctrl-x to save the file and exit<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pause the Music when Playing a Game<\/h2>\n\n\n\n<p>Edit the script that runs when a game starts to pause the music<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/opt\/retropie\/configs\/all\/runcommand-onstart.sh<\/code><\/pre>\n\n\n\n<p>Paste this into the editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkill -STOP mpg123<\/code><\/pre>\n\n\n\n<p>ctrl-o, enter, ctrl-x to save and exit<\/p>\n\n\n\n<p>Edit the script that runs when a game ends to restart the music<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/opt\/retropie\/configs\/all\/runcommand-onend.sh<\/code><\/pre>\n\n\n\n<p>paste this into the editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkill -CONT mpg123<\/code><\/pre>\n\n\n\n<p>ctrl-o, enter, ctrl-x to save and exit<\/p>\n\n\n\n<p>now make the scripts runnable<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo chmod a+x \/opt\/retropie\/configs\/all\/runcommand-onstart.sh  \n$ sudo chmod a+x \/opt\/retropie\/configs\/all\/runcommand-onend.sh<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Turn off the Music when on the Command Line<\/h2>\n\n\n\n<p>Edit your bash script<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/home\/pi\/.bashrc<\/code><\/pre>\n\n\n\n<p>Scroll to the end of the file, open up a line between <code>retropie_welcome <\/code>and <code># RETROPIE PROFILE END<\/code> and make the file look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>retropie_welcome\n&#91;&#91; $(tty) == \"\/dev\/tty1\" ]] &amp;&amp; pkill mpg123\n# RETROPIE PROFILE END\n<\/code><\/pre>\n\n\n\n<p>ctrl-o, enter, ctrl-x to save and exit<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add Music<\/h2>\n\n\n\n<p>You can SCP or use a USB drive as we discussed earlier to copy files up.  However, I&#8217;ve purposely put the music directory in the roms directory because if you connect via windows explorer the roms directory has already been mapped and this is probably the easiest way to copy music up.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"169\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-54.png?resize=960%2C169&#038;ssl=1\" alt=\"\" class=\"wp-image-966\" srcset=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-54.png?w=999&amp;ssl=1 999w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-54.png?resize=300%2C53&amp;ssl=1 300w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-54.png?resize=768%2C135&amp;ssl=1 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Much appreciation to <a href=\"https:\/\/www.reddit.com\/user\/MapleStoryPSN\/\">MapleStoryPSN<\/a>.  This is super easy to setup.  Let me know if you have a better way to setup background music.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nOne of the features I saw used in some of the images&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/bullyrooks.com\/index.php\/2021\/02\/10\/adding-background-music-to-emulationstation\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Adding Background Music to EmulationStation&rdquo;<\/span>&hellip;<\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[109],"tags":[121,124,112],"course":[108],"class_list":["post-965","post","type-post","status-publish","format-standard","hentry","category-gaming","tag-emulationstation","tag-music","tag-retropie","course-build-customize-retropie","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":955,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/09\/adding-themes-and-splashscreen\/","url_meta":{"origin":965,"position":0},"title":"Adding Themes and Splashscreen","author":"Bullyrook","date":"February 9, 2021","format":false,"excerpt":"We want to choose a theme and splashscreen to make our retropie unique. I'll show you how to do that here. Choosing a Theme The built in emulationstation themes are pretty good. You can view them here. Just make sure to choose a theme that supports video. If you don't\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-52.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-52.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-52.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-52.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":968,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/10\/starting-emulationstation-and-theme-setup\/","url_meta":{"origin":965,"position":1},"title":"Starting EmulationStation and Theme Setup","author":"Bullyrook","date":"February 10, 2021","format":false,"excerpt":"We should be all done except for a few things that we need to be in emulationstation for. Lets reboot the Pi to the emulationstation start screen. Starting EmulationStation You should have seen your splash screen on boot and hear your music startup shortly after emulationstation started. Congratulations! Picking a\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":952,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/09\/scraping-rom-metadata\/","url_meta":{"origin":965,"position":2},"title":"Scraping ROM Metadata","author":"Bullyrook","date":"February 9, 2021","format":false,"excerpt":"In order to help make EmulationStation useful and good looking we want to add metadata to the ROMs in the library. We can use skyscraper to do this. Configure Your Controller Reboot your Pi and wait for it to get to the EmulationStation screen. Lets configure the controller now (make\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":928,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/09\/overview-and-prerequisites-for-building-a-retropie\/","url_meta":{"origin":965,"position":3},"title":"Overview and Prerequisites For Building a RetroPie","author":"Bullyrook","date":"February 9, 2021","format":false,"excerpt":"Retropie is a project which allows you to quickly install, manage and play a variety of emulators for various video game consoles. Its an excellent way to get started with most of the installation and configuration taken care of for you. Overview Retropie is build on two components RetroArch and\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":943,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/09\/retropie-first-startup\/","url_meta":{"origin":965,"position":4},"title":"RetroPie First Startup","author":"Bullyrook","date":"February 9, 2021","format":false,"excerpt":"We'll need to do a little initial configuration before we start adding consoles and games. Turn it on Make sure that your power, hdmi, keyboard and sd card are all plugged in. Turn it on. You should see the retropie start up. First some linux startup, then a retropie start\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":932,"url":"https:\/\/bullyrooks.com\/index.php\/2021\/02\/09\/flashing-retropie\/","url_meta":{"origin":965,"position":5},"title":"Flashing Retropie","author":"Bullyrook","date":"February 9, 2021","format":false,"excerpt":"After you assemble the raspberry pi kit you'll need to flash the retropie image onto the SD card. Setup Imager Install raspberry pi imager and run the application. You should see a screen like this: From choose OS choose emulation and game OS Choose RetroPie Choose the version for the\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/bullyrooks.com\/index.php\/category\/technology\/gaming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/image-43.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/comments?post=965"}],"version-history":[{"count":5,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/965\/revisions"}],"predecessor-version":[{"id":975,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/965\/revisions\/975"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=965"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}