Skip to content

Instantly share code, notes, and snippets.

@dasmikko
Last active January 10, 2020 19:21
Show Gist options
  • Save dasmikko/ee570606bf5cb9af923037882b41feea to your computer and use it in GitHub Desktop.
Save dasmikko/ee570606bf5cb9af923037882b41feea to your computer and use it in GitHub Desktop.
FreePie Midi Drums to vJoy
# This FreePie script is for using Midi Drums with Clone Hero
# Install vJoy.
# Install FreePIE.
# Connect midi drums
# Copy/paste or open this code in/into FreePIE. Save it as a script, then press run. If it all works, you should be able to monitor the joystick outuput with vJoy's monitor program.
# Please note: These midi notes are setup for the Alesis Crimsom 2 Mesh kit, and notes may vary from drum module to module
# feel free to change the input midi nodes on the lists
# You can setup multiple midi notes to a single joystick buttons. Like have the hihat and tom 1 map to the yellow drum
import time
# Setup the different midi nodes and joystick buttons
redMidiNotes = [38]
redJoyStickButton = 0
yellowMidiNotes = [50]
yellowJoyStickButton = 1
blueMidiNotes = [47]
blueJoyStickButton = 2
orangeMidiNotes = [57]
orangeJoyStickButton = 3
greenMidiNotes = [43]
greenJoyStickButton = 4
kickMidiNotes = [36]
kickJoyStickButton = 5
# Setup note delay (currently 2ms)
time.sleep(.02)
# Reset all the buttons
vJoy[0].setButton(redJoyStickButton, False)
vJoy[0].setButton(yellowJoyStickButton, False)
vJoy[0].setButton(blueJoyStickButton, False)
vJoy[0].setButton(orangeJoyStickButton, False)
vJoy[0].setButton(greenJoyStickButton, False)
vJoy[0].setButton(kickJoyStickButton, False)
def update():
diagnostics.watch(midi[0].data.channel)
diagnostics.watch(midi[0].data.status)
diagnostics.watch(midi[0].data.buffer[0])
diagnostics.watch(midi[0].data.buffer[1])
# Red
if (midi[0].data.buffer[0] in redMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(redJoyStickButton, True)
# Yellow
if (midi[0].data.buffer[0] in yellowMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(yellowJoyStickButton, True)
# Blue
if (midi[0].data.buffer[0] in blueMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(blueJoyStickButton, True)
# Orange
if (midi[0].data.buffer[0] in orangeMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(orangeJoyStickButton, True)
# Green
if (midi[0].data.buffer[0] in greenMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(greenJoyStickButton, True)
# Kick
if (midi[0].data.buffer[0] in kickMidiNotes) and (midi[0].data.buffer[1] > 0):
vJoy[0].setButton(kickJoyStickButton, True)
if starting:
midi[0].update += update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment