Code Monkey home page Code Monkey logo

offkeyboard's Introduction

offkeyboard

This project allows operating a computer using a guitar, or bass guitar, or other instrument. Notes on the instrument can be mapped to key presses, key combos, or mouse movements/clicks. Check out this tweet for a demo.

This software was used in the creation of these epic YouTube videos:

I Played Minecraft Using ONLY A Bass

The project works by running fundamental-frequency estimation on microphone input, and mapping these to keyboard/mouse inputs. State is kept to ensure each played note is pressed only once (rather than the full note duration), to allow certain keys to be "held down" as long as the note is played, to allow chorded keys/key combos to be entered, to detect when a note is stopped, etc.

Configuration

Modify the note-mappings in config.py to configure what note maps to what keyboard or mouse action. For more complicated configuration, you might need to modify the code in keymaps.py.

Installation

  1. Ensure you have Python 3 available on your system

  2. Run the following shell commands (macOS):

brew install portaudio
pipenv shell
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
pipenv install
  1. Run offkeyboard:
python offkeyboard/__init__.py

As long as the script is active, playing notes defined in the configuration will send the associated keyboard/mouse events to the OS.

Press CTRL+C to exit.

Mouse Support

It's difficult to send simulated mouse events on modern macOS. To send mouse events, we need to install a kernel extension and communicate with it.

For this, I used the (very cool!) foohid library. This will typically require disabling SIP, so continue at your own risk.

I'm intentionally leaving out detailed instructions for this bit for now, as disabling SIP and installing random kernel drivers is a security risk.

License

MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.