MIDI Input Patch for MFH 3 (for electronic drums and such)

Discuss mods and get help with mods ONLY
This topic is 15 years and 5 months old. Instead of replying, please begin a new topic, or search for another related topic that may be more suitable.
User avatar
ver
Member
Posts: 11
Joined: December 31st, 2008
Reputation: 0

MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby ver » Fri Jan 09, 2009 8:09 am

This is a patch for "Frets on Fire : My Fingers Hurt 3.0" to allow the player to use a MIDI device as input without removing any existing support for other input devices.

This patch needs the pyrtmidi python extension available at http://trac2.assembla.com/pkaudio/wiki/pyrtmidi

You can find the patch here: http://gangrenegang.com/~kimmy/fof-mfh-3.0-midi-input.patch

To patch the code, I use the 'patch' utility:

patch -p 1 < fof-mfh-3.0-midi-input.patch

If you patch your MFH3 source and DON'T have this extension, OR you have no MIDI devices, nothing bad will happen. But without the rtmidi extension, MIDI just won't work with this FOF:MFH3 patch.

To know if the MIDI input works for certain, patch your game and run it in a terminal (or 'cmd'). If you see "x MIDI inputs found." or "No MIDI input ports found", it's working. If you see the latter, that means it can't find any usable MIDI inputs. Plug something in, and make sure you have the drivers loaded for it.

This patch will attempt to use ALL MIDI inputs as valid inputs. Then, to associate the input to a pad (for drums) or any other instrument for that matter (midi guitars?), just go to the options and configure them normally. Hit the pad you want to use for the appropriate pad, and it'll identify it as "Midi #x-y" where 'x' is the input used (or 'port') and 'y' is the pad on the device itself. In other words, if you 'move' the drum set, you'll need to setup your pads again. This is because in the world of MIDI the drums don't identify themselves uniquely, just what they are, so I'm afraid that's just how it is. On the other hand; if you have, say, 8 pads and two pedals, you could move them around and allow two players to share one set. (That's right, this will work!) Groovy.

As for any bugs I've used the patch quite a lot and haven't found any issues at all (it's a very simple patch), but you may. If you find one please post about it.

rtmidi SHOULD work on Mac OS X, Linux with ALSA, IRIX, or Windows. If your platform isn't listed there (I'm looking at you guys, BSD,) direct your patches to the rtmidi project, since this one doesn't do anything platform specific.

Also, if you're in Linux and you are seeing "No MIDI input ports found" make sure you have the appropriate sequencer modules loaded:

    snd_timer
    snd_seq
    snd_seq_device
    snd_seq_midi
    snd_seq_midi_event

If anybody cares to use this patch, please throw any questions at this thread, I'll keep my eye on it.

.. also, I have no idea if this patch will apply cleanly to stock FoF or any other mods, but really it doesn't matter, since they only work with guitars as far as I know anyway. ... Okay, if you have a MIDI guitar (which I've never heard of), let me know how it went.
Pro Hentai Critic
User avatar
MoN01
Member
Posts: 1306
Joined: February 2nd, 2008
Location: Genshiken
Reputation: 1
Contact:

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby MoN01 » Fri Jan 09, 2009 8:17 am

Wow, awesome, if that works I can finally use my Wii World Tour Drums in FoFix. I will try that right away. Thank you very much.
Image
User avatar
ver
Member
Posts: 11
Joined: December 31st, 2008
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby ver » Fri Jan 09, 2009 10:12 am

Hmm, maybe, but this patch is more for owners of Roland drums, Yamaha, ION, and such.

Basically if it has a plug on it that looks like an oversized keyboard plug it's normal MIDI. If it's USB MIDI then I'm really not sure what sorta extra work is required, I mean are there MIDI drivers for those Wii WT drums?
Blue Heaven!
User avatar
death_au
Member
Posts: 3991
Joined: December 12th, 2007
Location: Australia
Reputation: 7
Contact:

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby death_au » Sat Jan 10, 2009 5:31 pm

MoN01 wrote:Wow, awesome, if that works I can finally use my Wii World Tour Drums in FoFix. I will try that right away. Thank you very much.

Sorry, but no. The MIDI port on the back is input only. You can't get MIDI output from the WT Drum itself. Progress is being made to get the WT instruments recognized. Carl Kenner's working on it for the next version of GlovePIE. Keep an eye on this thread: viewtopic.php?f=3&t=29037
[/offtopic]
This sounds really awesome, except I don't have any MIDI instruments to test with :sad:
I hope there's people who can test it and confirm it works, so that it may eventually be added to the official version of FoFiX


MFH added this to the latest FoFiX alphas (from r734 for those of you playing at home)
Issue 451 on Google Code
FoFiX Dev/Mod Squad
User avatar
jstump91
Member
Posts: 837
Joined: September 21st, 2008
Location: Baltimore, MD (US)
Reputation: 0
Contact:

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby jstump91 » Sun Jan 11, 2009 9:42 am

As of r751, FoFiX enables support for rtmidi by default if it is available. I rebuilt rtmidi with a patch that removes the segfault bug, so be sure to either use my latest build, or, if you compile it yourself, apply my patch. Both the patch and my builds are in my mediafire at http://www.mediafire.com/stump .
jstump91, a.k.a. john.stumpo, a.k.a. stump
jstump.com | stump's blog | FoFiX development | My own code
Can't find a Windows build of the Python module you need? Try my mediafire!
Don't say "Python can't do [insert task here]." Python can do anything with the right modules - said modules may just not have been written yet.
"Python - why settle for snake oil when you can have the whole snake?" --Mark Jackson
Did you search before you posted? Did you read the rules for the subforum you are posting in?
Awesome Drum Charter
User avatar
anthman852
Member
Posts: 2144
Joined: February 24th, 2008
Location: Ann Arbor, Michigan
Reputation: 1

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby anthman852 » Sun Jan 11, 2009 1:58 pm

MoN01 wrote:Wow, awesome, if that works I can finally use my Wii World Tour Drums in FoFix. I will try that right away. Thank you very much.

the wii world tour drums use a wiimote, not midi i think. Therefore you won't need this, just a GlovePIE script.
zaqzaq
Member
Posts: 3
Joined: January 9th, 2009
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby zaqzaq » Mon Jan 12, 2009 8:28 pm

I tried FoFix with electronic (midi) drums and midi-ox /bome´s midi translator combination. It was nice to use every windows-based
software with midi drums, but FoFix didn´t react to midi input. I thought that python doesn´t understand midi. I searched answers from here and found your thread. It looks like solution could be here.
I´d really like to test your stuff, but I have no idea what is "patch utility" and how I get pyrtmidi python extension to FoFix. And what means "running game in a terminal (or 'cmd')?

Would you explain more specific, please. Maybe I never gonna get it, but thanks anyway for your effort.
Blue Heaven!
User avatar
death_au
Member
Posts: 3991
Joined: December 12th, 2007
Location: Australia
Reputation: 7
Contact:

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby death_au » Mon Jan 12, 2009 11:24 pm

If you download FoFiX 3.100 beta 1, this module should be included, so (in theory) it should just work "out of the box" so to speak.
It would be great to get people with real MIDI instruments testing it. Whether it works or not, please let us know about your experiences.
zaqzaq
Member
Posts: 3
Joined: January 9th, 2009
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby zaqzaq » Tue Jan 13, 2009 8:08 am

Ok. FoFiX 3.100 1 beta version. Now tested with electronic midi drumset.

Everything worked fine with pc-keyboard. After keyboard test I tried to assign my drumset´s
pads to the game. Something nice happened. Game responded to midi input
from drumset´s kick drum. Next I tried to configure snare. Fofix didn´t like that,
it disappeared totally from the screen. It wasn´t typical crash. The proggie simply disappeared
but pc worked well after that. It didn´t stuck.

Second try. I played a song in quickplay mode. Game´s bass drum reacted only visually to midi drumset´s
bass drum hits. Yellow bar in fretboard was in flames, but there wasn´t audio. Game´s Bass drum didn´t
response to keyboard commands anymore.

I tried again to configure other drum pads to the game. No success. Game disappears immediately
when I choose "Drum keys" from options menu. Its still playable with keyboard, but there is no audio
or visual response in bass drum.

After the last crash I checked fretsonfire.log. Maybe log´s last line tells you something:
AttributeError: Input instance has no attribute 'decodeMidiButton'
There was also in log:
(D) 0 joysticks found.
(D) 3 MIDI inputs found.

I use my soundcards external module to connect drumset to pc. It has genuine midi connector,
so I dont need USB to connect. Soundcard is SB Audigy 2 ZS.
...the pain
User avatar
myfingershurt
Member
Posts: 1796
Joined: April 9th, 2007
Location: Northern Nevada, USA
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby myfingershurt » Tue Jan 13, 2009 10:36 am

Thanks for testing this; your bug report showed me a missing function, which is now present in the latest SVN revision. If you are an alpha tester, you can try it out and let us know if that fixed the MIDI input for you.

---- EDIT ----

Here's an updated library.zip (compressed in a RAR file, as the library.zip has very low compression) that should correct the MIDI situation for FoFiX 3.100 Beta 1 (replace the data\library.zip with the new one). Let me know if this fixes your MIDI input issues.

http://www.mediafire.com/?myzt1komzht
User avatar
Gaia
Member
Posts: 29
Joined: June 26th, 2007
Location: Germany
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby Gaia » Tue Jan 13, 2009 4:21 pm

i'm using a midi drumset too. with the new library.zip i could set up my drum pads without any problems.
when I go on test keys and hit a pad then the color of the pad stays.
so it seems like the game is recognizing that I hit a pad but it does not notice that it's just a short hit because it stays pressed.
when I start playing a song it's the same, if I hit a pad, the color stays forever even if I hit the pad again.
...the pain
User avatar
myfingershurt
Member
Posts: 1796
Joined: April 9th, 2007
Location: Northern Nevada, USA
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby myfingershurt » Tue Jan 13, 2009 8:00 pm

Hmm... the MIDI Note Off event is not getting through for some reason. If I think of something to try on this, I'll post another library.zip for testing.
FoFiX Dev/Mod Squad
User avatar
jstump91
Member
Posts: 837
Joined: September 21st, 2008
Location: Baltimore, MD (US)
Reputation: 0
Contact:

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby jstump91 » Tue Jan 13, 2009 11:39 pm

myfingershurt wrote:Hmm... the MIDI Note Off event is not getting through for some reason. If I think of something to try on this, I'll post another library.zip for testing.


I think under some circumstances a Note On event with zero velocity can be substituted for a Note Off. Maybe that's something to try looking out for.
jstump91, a.k.a. john.stumpo, a.k.a. stump
jstump.com | stump's blog | FoFiX development | My own code
Can't find a Windows build of the Python module you need? Try my mediafire!
Don't say "Python can't do [insert task here]." Python can do anything with the right modules - said modules may just not have been written yet.
"Python - why settle for snake oil when you can have the whole snake?" --Mark Jackson
Did you search before you posted? Did you read the rules for the subforum you are posting in?
User avatar
ver
Member
Posts: 11
Joined: December 31st, 2008
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby ver » Thu Jan 15, 2009 4:06 pm

Hmmm, I think I have an explanation for this.

In the patch I do this check:

Code: Select all

   for i in ports:
     midimsg = midi[i].getMessage()
     if len(midimsg) > 0:
       id = self.encodeMidiButton(x, midimsg[1])
       if midimsg[0] == 153:
         if not self.broadcastEvent(self.priorityKeyListeners, "keyPressed", id, u'\x00'):
           self.broadcastEvent(self.keyListeners, "keyPressed", id, u'\x00')
       else:
         if not self.broadcastEvent(self.priorityKeyListeners, "keyReleased", id):
           self.broadcastEvent(self.keyListeners, "keyReleased", id)


Now, I have no idea what 153 really is, but from my tests it's "MIDI ON", and anything else should be "MIDI OFF". I'm using IONs though, so it might be necessary to put a check for an OFF midimsg instead of just assuming it is an OFF, and then ignoring the rest. I'm thinking the brain is sending extra data which is flipping the pad to an off state before the note even registers, and I sort of expect that from mutable cymbals and such, but it makes sense that some pads would do it too.

If you change it to this:

Code: Select all

    for i in ports:
      midimsg = midi[i].getMessage()
      if len(midimsg) > 0:
        id = self.encodeMidiButton(x, midimsg[1])
        if midimsg[0] == 153 or ( midimsg[0] == 137 and midimsg[2] == 0 ):
          if not self.broadcastEvent(self.priorityKeyListeners, "keyPressed", id, u'\x00'):
            self.broadcastEvent(self.keyListeners, "keyPressed", id, u'\x00')
        if midimsg[0] == 137 and midimsg[2] > 0:
          if not self.broadcastEvent(self.priorityKeyListeners, "keyReleased", id):
            self.broadcastEvent(self.keyListeners, "keyReleased", id)


..it'll only execute keyReleased on an actual release code (137 on my kit), or on a 'zero velocity' hit. At least, I THINK it will... I'm not really a python scripter, I try to stick to C/C++ :/
...the pain
User avatar
myfingershurt
Member
Posts: 1796
Joined: April 9th, 2007
Location: Northern Nevada, USA
Reputation: 0

Re: MIDI Input Patch for MFH 3 (for electronic drums and such)

Postby myfingershurt » Thu Jan 15, 2009 6:20 pm

Actually, I don't think that will work for anyone but you (or someone else with the exact same mappings).

http://www.dogsbodynet.com/fileformats/midi.html#EVENTS

MIDI event numbers for NOTE ON and NOTE OFF events fall within a range, and they change for each of the 16 channels.

I will attempt to write some Python code to properly handle the incoming MIDI events for everyone.

---- EDIT ----

Wrote new multi-channel MIDI input handling / event broadcasting code for issue 451:

Spoiler:Here's a new library.zip (inside the .RAR file so it's smaller) for those of you with 3.100 beta 1 that would like to test with MIDI instruments. It should now properly broadcast Note On and Note Off events from any of the 16 available MIDI channels:

edit:
Oops - forgot the velocity = 0 note on = note off event thing.
Committed as r786.

New library.zip download link (inside the RAR):
http://www.mediafire.com/?mudnzmye0w3

Last edited by myfingershurt on Thu Jan 15, 2009 6:46 pm, edited 1 time in total.

Return to “FOF Mod Discussion and Support”

Who is online

Users browsing this forum: No registered users and 8 guests