Another BGM for ES script
-
Hello everyone,
Once upon a time, I made a BGM script for my retropie build and only ever showed it to the RetroPie discord (over a year ago). Recently I felt like revising the whole thing after learning that someone actually attempted to use it, and it was probably still broken then. It's not as full-featured as some of the other scripts that I have seen, but if you fancy some simple smooth pygame fading with a dash of systemctl to daemonize, it'll fit the bill. There is a short demonstration video linked in the README as well.
EmulationStation BGM
It depends on some python packages, so those may need to be installed before it will work:- asyncio
- configparser
- pygame
If you do try it out, I would appreciate some feedback, even if it's a simple "yeah, it works" or a "breaks when I do X"
-
@jurassicplayer
Thank you so much for sharing it.
What is your opinion about retroarch?, now support bgm, for example, in Menu Sounds and activate the Mixer first, then set Enable BGM sound on the bottom option to On. -
@kactius
Right, I finally had some time to re-evaluate some of my terrible decisions and remake my original install script that doubled as a RetroPie menu.Something that might not be readily apparent, but the reset_song option is supposed to be for restarting the song from the beginning upon returning to the ES screen (ex. returning from a session of playing) rather than continuing from the last position. Since I felt that it would be a nice touch if my music didn't keep resetting when a preview video came up, I added a sort of "exclusion" list that stops the song from resetting for programs like omxplayer and mplayer.
Everything uses dialog which is...usually alright for most things...except for everything that I used it for. I might need to put instructions for dialog somewhere because it's not the most intuitive of UIs. For the bars, pressing down lowers the value, pressing up raises the value, left and right move between the 1s, 10s, 100s, 1000s places. For the file selector, select folders/files by pressing the space bar (dunno if that has an alternative with a controller)...and then press OK.
I updated the project and the install script to have a menu you can use from within RetroPie that is mostly just to change configuration options and the simple things in life that I wanted to use systemd for: start/stop and start on boot.
Note to self:
- Using systemd, which requires elevated privileges to manage services, is a horrendously dumb idea when you have no keyboard and only a controller.
- OP posts can't be edited. Realize poor decisions(^) before irreversibly posting them.
- Double check what version of python is actually available on the Pi before writing something targeted towards the latest version of Python ._.
- Probably not really useful to list out python module requirements that are included in the standard python install.
-
I tried it out and the script works but I had issues with the install. I followed your instructions in the Readme but the Start on Boot did not work for me. Also, I get an error with the Change Music Folder and that also did not work. I had to manually fix these:
- I used my rc.local to start the script instead.
- I manually edited the .ini file for the music folder. (roms/music)
Outside of those issues, it worked out well for me.
One thing I am curious about - I am running the KMS audio driver (vc4hdmi.conf) to do some testing and it is not able to mix multiple playback streams. This is a limitation at the moment, and I'm not sure if it will ever be resolved because the audio is being processed by the arm CPU instead. So what this means is that I get no audio in emulators because the pygame mixer is in use. If the mixer is un-initialized than I can get audio from the emulators, but that also means it has to be re-initialized when the emulator stops...I don't know if there is another way around this but maybe thats something to implement as an option.
Anyways, nice script and I've been running for a few hours now.
-
@bluestang
The Start on Boot option relied on matching "emulationstation #auto" in /opt/retropie/configs/all/autostart.sh, which is supposedly the default. I'm assuming yours looks a little different for some reason or another, but now it should just insert the required line at the very top of the file rather than try to match any specific pattern. Hopefully that means the install issue is fixed.As for the music folder selector (and initial song selector for that matter), I'm thinking of taking a leaf out of the feel of retroarch's file selector and replicating that later, since dialog's default really leaves a lot to be desired for a controller only setup.
More importantly, I've never touched the KMS audio driver stuff before, but based off of what you've told me, I've implemented a fix that I believe shouldn't really cause too much of an impact to anything else (in terms of smooth transitions). If you could give it a test, that would be fabulous. If it works correctly, I probably will implement it as an option or just auto-detect it during install.
- Just download the latest version of the esbgm.py script,
- change line 22
v4_flag = False
tov4_flag = True
, and give it a quick whirl.
More notes to self:
- Committing experimental stuff to the master branch probably not the best way to provide experimental builds.
-
Yea my autostart.sh looks like this - "emulationstation --no-splash #auto". Once I changed the script to look for that the script worked as intended and it put the right command line in the autostart.sh
I'm using a custom image that has custom splash screens. You might want to implement something that takes into account custom cmd line options for those of us running custom images.
Retried the new script w/ the new flag. It doesn't work on the first try, but subsequent attempts it works*. Remember, as of now the KMS audio driver can only playback one output stream at a time. So my guess is that the driver has to be released completely before the next application can take it over and use.
*Once you return back to EmulationStation there is complete silence which is odd because I also tried the new script out with the BCM audio enabled and it plays just fine off/on with the v4_flag = True. This also explains why on subsequent tries the audio works - the driver is free to play the emulator.
I am also getting random freezes and I can't seem to pin down what is causing it. I did not experience the freezes with the BCM audio but my previous config with the KMS audio did also not have any freezes either.
-
@jurassicplayer
Quick update - No need for the v4_flag anymore because I've gotten the KMS audio driver to work with Pulse Audio. The software is doing the mixing just fine and everything is working pretty darn good.Overall I like your script and I've been running it for several hours without any issues anymore.
Job well done!
-
@bluestang
Great, glad it's working.
I removed the vc4 workaround stuff since it's not needed, and changed the init_delay to use seconds rather than milliseconds, since it's totally more useful with seconds (if people use video splashscreens).The installer script was also updated to have a brand new file/directory selector for the initial song and music directory options, making them actually usable without having to pull out the keyboard.
Also fixed an issue with spaces in file paths and fixed some smaller niggling things (stopping used to spit out "Terminated blah blah...").The only thing I'm planning at the moment is to maybe dynamically come up with some nice volume step values based off of fade_duration and max_volume to make just that little more "user-friendly" and remove that config option.
-
-
-
-
-
-
-
-
@jurassicplayer Hi, it worked fantastic!! Congrats and thanks!! The only issue I found so far has to do with some mp3 files which are played much slower than they should, Maybe I would need to try different mp3 formats but you did an excellent job. None of the other scripts worked for me because of the video previews I use in roms, your script is the only one that fits my build. I only need to figure out how to correct the slow mp3 files issue, in fact if you could implement a method to change music depending on what system is being played as in some Recalbox Themes, it would be perfect, Cheers
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.