Giter Site home page Giter Site logo

piano-mode's Introduction

Piano-Mode

Piano-Mode is a minor mode for Emacs that turns your keyboard into a “piano” keyboard. It is modeled after the same behavior commonly included in music trackers or digital audio workstations. Each “note on” (piano key press) event is sent to the function specified by the piano-key-down-function variable, and each “note off” is sent to the function specified by piano-key-up-function. See the included piano-mode-cl-collider.el for an example of functions that could be set for these variables.

Example Configuration

Using use-package to load piano-mode and the piano-mode-cl-collider functionality:

(use-package piano-mode
  :custom
  (piano-key-down-function 'piano-cl-collider-play-note)
  (piano-key-up-function 'piano-cl-collider-release-note)
  :bind (("C-c k" . piano-mode)
         :map piano-mode-map
         ("\\" . piano-cl-collider-change-instrument)
         ("|" . piano-cl-collider-change-parameters))
  :config
  (require 'piano-mode-cl-collider))

Caveats

Since (to the best of my knowledge) Emacs does not provide any way to differentiate between a user’s keystrokes and OS-generated key repeat events, and doesn’t expose key release events to Elisp at all, this mode uses the time between events to determine whether a key is still “pressed”. Obviously, this is a very hacky solution, so expect glitchy behavior to occur sometimes. You may want to tune the piano-key-repeat-delay and piano-key-repeat-rate variables based on your OS settings.

Right now, this will only work if you’re using a QWERTY keyboard layout, but you can edit piano-ascii-to-note-translation-table to match your keyboard layout. (Pull requests for alternate layouts are welcome!)

Future

  • “mono mode”
  • record mode
  • better heuristic for note auto-release; take into account whether the key is “repeating” or not.

piano-mode's People

Contributors

defaultxr avatar thechampagne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

thechampagne

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.