GithubHelp home page GithubHelp logo

ast / keyboard Goto Github PK

View Code? Open in Web Editor NEW
44.0 17.0 11.0 54 KB

Teensy (Arduino clone) 88 key velocity sensitive midi keyboard

License: MIT License

Arduino 0.78% Objective-C 0.17% Eagle 99.05%

keyboard's Introduction

Update 2017-10-14

I can't believe it's already been four years since I published this!

This repo has generated considerable interest and I regularly receive email about it. However, I do not longer actively work on this project. I'm not able to help you with your keyboard project.

I have stopped using the Teensy for my keyboard and switched to the ucapps project. Might publish something about that in the future.

Other keyboard project that I know about

These might be helpful.

Arduino clone midi keyboard

A Teensy (Arduino clone) powered velocity sensitive USB MIDI keyboard with sustain pedal. Works with diode matrix keybeds. I used one from Fatar (also known as Studiologic).

Using the teensy USB MIDI library it works as a class compliant USB MIDI device.

I have only included the source and a very basic schematic here. Feel free to contact me if you have any questions.

Circuit

As you can see on the keyboard matrix schematic, the 88 keys are arranged in to two diode matrices. There are actually 176 switches in the matrix. The reason for this is that there are two switches under each key. When a key is pressed, one of the switches closes slightly before the other one. By measuring the time of flight between the switches we can derive the velocity.

I've included a rudimentary schematic how I use 3 74ls138 demultiplexers to address the rows. With this arrangement I use 8 + 5 pins to scan the keybed.

TODO / Bugs

This is a bit of a hack but it works quite well for now.

If you have any insights to these questions please let me know!

  • Is a scanning frequency of 1000Hz too low? I've heard somewhere commercial keyboard use 2000Hz. Perhaps someone can measure one with a scope?
  • Right now the velocity response is linear and quite low resolution. What is a good velocity response curve?
  • Is it a bad idea to join the two matrices? Perhaps it's a better idea to use a separate micro controller for each matrix and let them talk together using i2c? This approach would be more modular and allow for stacking a lot of keys (in an organ i.e..)
  • I'm using the Teensy USB MIDI library. I'm not sure how this interferes with the timing of the scanning interrupt routine.

Resources

keyboard's People

Contributors

ast avatar

Stargazers

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

Watchers

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

keyboard's Issues

Pin out on diagram

Hey.. I was checking out the code and the schematic that u have.. I realized that there are 5 wires coming from the shift registers plus the power wires.. the code only shows that 2 wires are connected.. explain please

Velocity curve

I recently finished a teensy-based keyboard similar to yours, and your code was quite helpful. Since you mentioned issues with the velocity curve, I thought I would share my findings which gave very natural results with a bit of tweaking.

The keyboard matrix I had was different, and I also used a shift register and different wiring, so the code is different, but here's the important part:

velocity = 127 - log(interval/shortestInterval) / log(2) * velocityAttenuation;

Where shortestInterval is the time interval between the two switches when hitting a key as fast as I could, and velocityAttenuation is by how much to reduce the velocity when the time interval is doubled. The division by log(2) is just to get a log base two since arduino doesn't provide that function natively.

In my case the shortest interval is set to 2000 microseconds, hitting the keys with that interval gives me a MIDI velocity close to 127. I set velocityAttenuation to 20, so if I hit the keys a bit less hard and get an interval of around 4000 microseconds, then the MIDI velocity is around 107 (127 - 20). 8000 microseconds gives a velocity of 87, 16000 gives 67, etc. You can see the full code here: https://github.com/floretan/p150

Thank you for giving me a great head start, I hope this can be helpful to you too!

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.