Homepage › Forums › RetroPie Project › Everything else related to the RetroPie Project › Adding Music To RetroPie (A Work in Progress)
- This topic has 6 replies, 2 voices, and was last updated 8 years, 6 months ago by
labelwhore.
-
AuthorPosts
-
02/07/2016 at 10:58 #116400
labelwhore
ParticipantBefore We Get Started…
Please bear with me, this is all very, very alpha. There may be bugs. I will write up a wiki when this is closer to completion.First, some things you should know about my setup, should you want to copy exactly what I did.
I have my music on an external hard drive I formatted in windows. It’s in a ton of directories and subdirectories in a top level folder named Music. This is how I set that up.
sudo mkdir /hdd
I mount the drive with a line like this in
/etc/rc.local
mount -t vfat -o async /dev/sda1 /hdd
Setting Up mpd and mpc
————————————————–Run this first to install mpd and mpc:
sudo apt-get install mpd mpc
Next, we need a symlink to our music directory (In my case it’s /hdd/Music, but yours may be different.) Be carefull, you’ll need to use your path in several steps throughout this guide.
ln -s /hdd/Music /home/pi/Music
Then I followed this guide up to “mpc update”. http://crunchbang.org/forums/viewtopic.php?pid=182574 Don’t follow that guide though, follow this one. We need to deviate from that guide slightly. For example, we need to change the port number to something other than 6600 because advmame seems to be using mpc on port 6600. Because of this, all my scrpits include “-p 6700” as part of the command issues to mpc. This way I didn’t have to recompile mpd.
Moving on…
Here are the setup steps I took. Although, I didn’t take great notes during this part. There may be a step missing.
sudo service mpd stop sudo update-rc.d mpd disable
Ignore the warnings.
Download and uzip this file and put it’s entire contents (except for the pixel theme folder) in /home/pi (you should now have the folder /home/pi/.mpd)
LINK_TO_FORUM_ATTACHMENT: radio-1.zipYou may need to run the following command:
chown pi:pi -R /home/pi/.mpd
mpd Config File Changes (These are all in the .zip)
————————————————–Now you need to edit
~/.mpd/mpd.conf
(or not, either way, verify these settings exist)change the music directory to match yours. (In my case “/hdd/Music”.)
music_directory "/hdd/Music"
change the playlist directory
playlist_directory "/home/pi/.mpd/playlists"
change the db file location
db_file "/home/pi/.mpd/tag_cache"
change the logfile location
log_file "/home/pi/.mpd/mpd.log"
change the pid file location
pid_file "/home/pi/.mpd/pid"
change the state file location
state_file "/home/pi/.mpd/state"
change the sticker file location
sticker_file "/home/pi/.mpd/sticker.sql"
change the user to pi
#user "pi"
change the port to 6700 this is very important, my scrpts will not work on another port
port "6700"
scroll down towards the middle of the file and make sure that mpd is set up to use alsa (it should be).
audio_output { type "alsa" name "My ALSA Device" # device "hw:0,0" # optional # mixer_type "hardware" # optional # #mixer_device "default" # optional # mixer_control "PCM" # optional # mixer_index "0" # optional }
Save and close the file.
Now run the following two commands:
mpd mpc -p 6700 update
Using mpc
————————————————–Now that mpd is setup, we can control it with mpc.
Here’s a guide to using mpc, it’s really easy. http://linux.die.net/man/1/mpcNOTE: I created some scripts to do this! They’re in the .zip.
Now that you have mpd and mpc installed and configured, you need to create playlists. This is what I need to figure out how to automate. I used the findadd command.For example (you don’t actually need to run this):
mpc -p 6700 findadd Genre electronic && mpc -p 6700 shuffle && mpc -p 6700 save electornic
This adds all mp3s in your music folder that are tagged with the genre “electronic” to the playlist, then savesthe playlist to a playlist named electornic.m3u in the .mpd/playlists folder
Next, I created some scripts to manage playlsists, remember volume settings, and to start playback and stop playback. I put them in the roms folder, but I included them in the attachment in a folder called OtherScipts.
You could create a section in
etc/emulationstation/es_systems.cfg
like this:<system> <name>radio</name> <fullname>Radio</fullname> <path>/home/pi/.mpd/OtherScripts</path> <extension>.sh .SH</extension> <command>bash %ROM%</command> <platform/> <theme>radio</theme> </system>
I also added a couple lines to rc.local to start playback and to play a specfic .mp3 when retropie boots up. Although I currectly have the playlist choice hardcoded within the script, I plan to change this later.
# Start Playlist su pi -c 'bash /home/pi/.mpd/startup_playback.sh &'
I have included the startup sound for this script in the .zip file in the /startsounds/ directory. I plan to make more start sounds, and hopefully an interface to easily switch them. Copy the startsounds directory form the .zip to your music directory. So in my case
/hdd/Music/startsounds/kwrp.mp3
Last but not Least
————————————————–
Once you have all of the emulators.cfg files edited, and everything else set up correctly, run this command from the terminal. This script will edit all of your emulators.cfg files. (Don’t worry, it will back up the current version first.):
bash "/home/pi/.mpd/setup.sh"
now reboot
sudo reboot
02/07/2016 at 11:09 #116404labelwhore
ParticipantKnown Issues:
- Some scripts default to /hdd/Music, so for now it’s best to set that up exactly as I have.
02/08/2016 at 18:14 #116507labelwhore
ParticipantFirst, forgive me for treating this forum like a blog. However, I think this addition is worthy of a slight bend in normal forum etiquette. I’ll try to keep things tidy, at least. When this is simpler to install, and “fully baked”, I’ll make a wiki entry instead.
Copied from the request forum to keep the important stuff in one place.
*please forgive spelling errors, this website eats my letters when I post from home.
So a little update as to my progress…
So far, things on my end are going really well. I have a sort of install script that does some of the tedious work for you, like editing all of the emulators.cfg files that need it. I started testing the results of that last night. Out of the emulators I tested, all of the file modifications went flawlessly. Also, once the new emulator options generated by my script are chosen, the music fades in and out as it should when an emulator starts. I saw one emulator that possibly needs a work around, (which I have already done for advmame, with success) and I haven’t tested all of them yet. One each, per system that works with my mod, would meet my requirements.
Done(ish):
Playback script that plays startup sound, and starts music playback at boot time
Fade out and back in when an emulator is started
Playlist management from emulator menu via shell scripts (customizability oh yeah!)
Automated playlist and script creation (handy for large music collections)
Background music for infocom! (I love the bonus that came from doing no work)
Beautiful theme for pixel themeset (thank you google images!)
Handwritten gamelist with “gameart” for some of the scripts
complete gamelist xml with “gameart” and include in .zip
(Somewhat) scripted installationTo Do:
Improve Installation script – in progress
create themes for simple and carbon
add descriptions for themes other than pixel
testing
Wiki entry
Git this thing GitHub lol
testing
Module for RetroPie Setup menu
Possible integration into a new build of Emulation Station
(^^ Thank Zigurana for looking into that, not me.)
MORE TESTING!!!
oh yeah, bug fixingCurrent Known issues:
1. MPC can control the volume of advmame (and most likely advmess, possibly other emulators). I believe this advmame (and advmess) may be using mpg (or a vaiation of it) for sound. After all, it’s extremely felxible and lightweight, so why not? Because of this I had to do two things, first, I had to run mpg on port 6700. (It might be better to recompile a new version of mpg that defaults to port 6700 for this. I have not looked into doing this.) The other piece of the workaround was that I had to bring the volume level back up to normal after the fadeout script ran when advmame started. So the new command line for advmame looks like this (workaround italicized):
runcommand > volume fadeout scrpit > normalize mpc volume > launch advmame > volume fadein script2. This should be easy to fix, but I just discovered it in testing last night. Over time, if several games are launched and exited, volume will decrease. As a workaround, increase the volume from the radio section in ES, via my scripts. I simply need to fix either my start playback script or the fadeout script. I’m not sure yet which is the culprit.
3. This is very minor, as using my scripts naturally works around the problem. Vice has a conflict with mpg. MPG must be shut down when starting vice, or you may get no game sound. In my testing, music still played from mpg, vice made an sub-second audible glitch, then gameplay continued without game sound. Choose one of the fade options from the runcommand menu for normal opration with vice emulators.
I just so happen to have this week off work, and not much to fill it with. I’ll keep this thread updated with my progress, as I hit major milestones. I hope to automate the config file editing piece next so that all you have to do is tell my setup script where your music is located and it’ll do the rest.
I did the whole thing with shell scripts, which I’ve never written before in my life. Don’t laugh at the code, but feel free to tear it apart and make it better. :P
02/10/2016 at 16:51 #116682labelwhore
ParticipantUpdated todo list.
I’ve got some more time to work on this today. So it’s possible this could end up on github as early as tomorrow, or even late this evening.
02/11/2016 at 18:56 #116775labelwhore
ParticipantI’ve been busy. :)
This is on github now. To install it, save the following script as retropie-radio.sh in
/home/pi/RetroPie-Setup/scriptmodules/ports
. Then you can install it from binary or source (actually same thing either way with this) from the retropie-setup menu. It’ll be listed under individual emulators towards the bottom of the list. (Idk how to get in in the experimental section.)#!/usr/bin/env bash # This file is part of The RetroPie Project # # The RetroPie Project is the legal property of its developers, whose names are # too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source. # # See the LICENSE.md file at the top-level directory of this distribution and # at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md # rp_module_menus="4+" rp_module_id="radio" rp_module_desc="Radio" function depends_radio() { git clone https://github.com/Labelwhore/retropie-radio.git /home/pi/.mpd wait sudo chown pi:pi -R /home/pi/.mpd wait su pi -c 'bash ~/.mpd/install/setup.sh' } function sources_radio() { git clone https://github.com/Labelwhore/retropie-radio.git /home/pi/.mpd } function build_radio() { } function install_radio() { sudo chown pi:pi -R /home/pi/.mpd wait su pi -c 'bash ~/.mpd/install/setup.sh' } function configure_radio() { setESSystem 'Radio' 'radio' '~/.mpd/OtherScripts' '.sh .SH' 'bash %ROM%' 'music' 'radio' }
02/12/2016 at 02:25 #116826herbfargus
MemberAdd this at the top to make it go in the experimental menu:
rp_module_menus="4+"
For example:
https://github.com/RetroPie/RetroPie-Setup/blob/master/scriptmodules/ports/kodi.sh
02/12/2016 at 06:18 #116836labelwhore
Participantawesome, thanks!
-
AuthorPosts
- The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.