MiSTer_BGM
MiSTer_BGM copied to clipboard
Support for midi files and MT32-Pi
I was wondering if we can add support for MIDI files and make BGM stream them on the MT32-Pi.
Hi mate. I'm really sorry, I actually thought I'd replied to this. I like the idea a lot.
The mt32-pi is probably not going to happen, I don't own one anymore and I think it'd be quite complex to do (I'm happy to be proven wrong though and would be totally happy to add support). Plain midi files definitely sounds doable but needs some thought, I don't think there's a simple midi playing utility that ships with the mister image. Maybe with fluidsynth?
I'm a bit busy with work at the moment but I'll try look into it.
And I just saw on discord you worked out how to do everything already. If you want to comment and give me your notes you worked out on playing midi files on the command line and playing them through the mt32-pi I'd be happy to put together a patch to include midi file support.
Hello @wizzomafizzo , Perfect timing. @ebraminio and I did some work over the weekend. So, we have something that works and needs to get integrated into BGM. Please find attach the binary of mt32-pi-ctl (source code here https://github.com/gmcn42/mt32-pi-control) mt32-pi-ctl.zip and MIDIMeister can be found on https://github.com/bbond007/MIDIMeister/raw/main/MIDIMeister Also I found a nice MIDI file (WILLYMT.MID) which you can find from here: https://www.midimusicadventures.com/qs/midi-zips/soundtracks/willymt.zip
To start MIDI use this
#play MIDI on MT32 as background music
killall aplaymidi
killall MIDIMeister
/usr/bin/MIDIMeister &
/usr/bin/mt32-pi-ctl -p 128:0 -r
/usr/bin/mt32-pi-ctl -p 128:0 -m
/usr/bin/aplaymidi -p 128:0 /media/fat/MIDI/MT32/WILLYMT.MID &
To stop MIDI (when you go in other cores)
#Stop MIDI when not in MENU kill aplaymidi /usr/bin/mt32-pi-ctl -p 128:0 -r kill MIDIMeister
I will put a video on Discord. Let's get started :)
Thank you both for getting this so far. I think the pull request is almost but not quite there.
- It would be better if bgm checks if it's running or not and will launch the midi daemon if necessary. Before every time it plays a midi would be fine. It would be good not to have to manually add it to the startup script and I believe the /sbin/uartmode script kills an existing daemon if it's running (before and after? not sure) when a compatible core is launched
- I'd prefer that playing through fluidsynth was the default behaviour. Have the mt32-pi as a configurable option. Is there some way we can check if an mt32-pi is plugged in? If so, then we can default to using it. Having a UDP server as an option would great too
What do you reckon? I can look into this when I've got some time free.
Let's do it. It all sound great. Unfortunately there is no way to detect if an MT32-Pi is connected as there is no feedback from the ALSA MIDI client AFAIK. So far, we have it working expect when you come back from a core (specially the AO486) things will not resume. That might be related to the multiple calls of the midi daemon.
As vast possibility of different configurations as user preference or available hardware, e.g. fluidsynth or timidity daemon with different sound fonts or a mt32d
daemon or MIDIMeister
for connecting to hardware synthesizer with different possible options, I think it will be better to just indicate the possible options in README.md rather than intervening with the user setup, leaving just the common part in bgm itself.
That's a great point, totally agree. Can you even run fluidsynth in the first place without some manual setup? Don't think so.
That said, it still sounds like we need to manually launch the daemon if necessary before playing since it sounds like uartmode does actually kill it after a core is exited. Will midimeister run ok with the MENU option even if a core isn't running? Perhaps that could be a way to use preconfigured values without adding much complexity to the script.
Thank you! :)
Can you even run fluidsynth in the first place without some manual setup? Don't think so.
Yes. midilink
, preinstalled, can run fluidsynth ok but I couldn't run it independently as it needs some configuration.
Will midimeister run ok with the MENU option even if a core isn't running?
Sure, it isn't dependent to any core, now that I have midimeister in user-startup.sh, my MiSTer just plays random MIDIs in the specified folder on startup with no issue. I just think we only should add a section to the README.md that in order to play midi files correctly with bgm one should make sure aplaymidi --port=128:0 file.mid
works correctly also independently, i.e. their setup is already ok, and if not, here are the suggestions depending on your setup.