diff --git a/main.py b/mididrumhero.py similarity index 58% rename from main.py rename to mididrumhero.py index 9ce7f89..8b7a044 100644 --- a/main.py +++ b/mididrumhero.py @@ -5,38 +5,46 @@ import pygame.midi import time +print "\nMidiDrumHero by ejj28" +print "https://github.com/ejj28/mididrumhero\n" + + def millis(): return int(round(time.time() * 1000)) -midiNumbers = [] +try: -vController = pyvjoy.VJoyDevice(1) + vController = pyvjoy.VJoyDevice(1) -pygame.midi.init() + pygame.midi.init() -count = 0 -for i in range( pygame.midi.get_count() ): - r = pygame.midi.get_device_info(i) - if r[2]: - print str(count) + ": " + str(r[1]) - midiNumbers.append(i) - count += 1 -print "Please enter the ID of the MIDI device to use:" -userMidiSelection = int(raw_input()) + midiNumbers = [] -i = pygame.midi.Input(midiNumbers[userMidiSelection]) + print "Detected MIDI input devices:" -lastHitTime = [0,0,0,0,0] -states = [False, False, False, False, False] -notes = [48,38,43,45,36] -controllerMappings = [1,2,3,4,5] -isMapped = [False,False,False,False,False] -drumNames = ["red drum pad", "yellow drum pad", "blue drum pad", "green drum pad", "kick pedal"] + count = 0 + for i in range( pygame.midi.get_count() ): + r = pygame.midi.get_device_info(i) + if r[2]: + print str(count) + ": " + str(r[1]) + midiNumbers.append(i) + count += 1 + + print "Please enter the ID of the MIDI device to use:" + userMidiSelection = int(raw_input()) + + i = pygame.midi.Input(midiNumbers[userMidiSelection]) + + lastHitTime = [0,0,0,0,0] + states = [False, False, False, False, False] + notes = [48,38,43,45,36] + controllerMappings = [1,2,3,4,5] + isMapped = [False,False,False,False,False] + drumNames = ["red drum pad", "yellow drum pad", "blue drum pad", "green drum pad", "kick pedal"] -try: for t in range(len(controllerMappings)): print "Please hit the " + drumNames[t] while isMapped[t] == False: @@ -48,7 +56,7 @@ def millis(): isMapped[t] = True print "Mapped " + drumNames[t] + " to Midi note " + str(x[0][1]) break - print "MidiDrumHero is now translating your E-Kit to Clone Hero, press Ctrl-C to quit" + print "MidiDrumHero is now translating your E-Kit to Clone Hero" while True: