Skip to content

Commit

Permalink
Initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
ejj28 committed Feb 27, 2020
1 parent 63018db commit 632b0b4
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 0 deletions.
190 changes: 190 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@

# Created by https://www.gitignore.io/api/linux,macos,python,windows,visualstudiocode
# Edit at https://www.gitignore.io/?templates=linux,macos,python,windows,visualstudiocode

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/linux,macos,python,windows,visualstudiocode
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "C:\\Python27\\python.exe"
}
75 changes: 75 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# MidiDrumHero
# https://github.com/ejj28

import pyvjoy
import pygame.midi
import time

def millis():
return int(round(time.time() * 1000))

midiNumbers = []




vController = pyvjoy.VJoyDevice(1)

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())

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:
if i.poll():
midi_events = i.read(10)
for x in midi_events:
if x[0][2] > 10:
notes[t] = x[0][1]
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"


while True:
if i.poll():
midi_events = i.read(10)
for x in midi_events:

for b in range(len(notes)):
if x[0][1] == notes[b] and x[0][2] > 10 and states[b] == False:
#print "ON, " + str(x[0][1])
#print x
vController.set_button(controllerMappings[b], 1)
lastHitTime[b] = millis()
states[b] = True

for y in range(len(states)):
if states[y] == True and millis() >= lastHitTime[y] + 50:
vController.set_button(controllerMappings[y], 0)
states[y] = False


except KeyboardInterrupt:
pygame.midi.quit()

Binary file added pyvjoy/utils/x64/vJoyInterface.dll
Binary file not shown.

0 comments on commit 632b0b4

Please sign in to comment.