element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Hypothetically add Velocity to MIDI keyboard with single analog input?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 8 replies
  • Answers 2 answers
  • Subscribers 391 subscribers
  • Views 1121 views
  • Users 0 members are here
Related

Hypothetically add Velocity to MIDI keyboard with single analog input?

ernek
ernek over 7 years ago

I’m very new to electronics (still working on the Arduino Starter kit projects). My goal is to build a midi keyboard with velocity sensitivity. In every consumer design I’ve seen, this is done with two switches—with a slightly different travel distance—for every key by measuring the time between their closings.

All of these switches are read as distinct inputs with the help of multiplexing. It seemed to me that it might be redundant that both switches in each pair needs to be distinguished by individual key. I thought about this for a while, and thought about a way where the first switches would only tell the controller that a new key has been pressed, without revealing which one.

This might be done by wiring all of the first switches in parallel; each with its own resistor in series. The number of switches activated (likely <10) could be mapped to the current flowing to a single analog input. When this number rises by 1, a key has been pressed. The velocity and pitch could then be determined by the second switch.

I have no idea if this is feasible, or even if it would save more resources than a normal full diode matrix with double the amount of switches...?

  • Sign in to reply
  • Cancel

Top Replies

  • dougw
    dougw over 7 years ago +2 verified
    This is possible, but some issues will need to be addressed. If the switches bounce, which is typical of mechanical switches, it will play havoc with recognizing a discrete state. he key to decent performance…
  • shabaz
    shabaz over 7 years ago in reply to dougw +2
    Hi Doug, With the switches effectively OR'd together (which is what I believe Ernie is suggesting by paralleling them), then it will not be possible to know the velocity of any key other than the first…
  • ernek
    ernek over 7 years ago in reply to shabaz +2
    Sorry if my wording was tangled up in my description. All of the primary sensors are hooked up in a parallel circuit, each with their own resistor of the same value. As the first key or additional keys…
Parents
  • shabaz
    0 shabaz over 7 years ago

    How would it work with chords? I'm not a musician, but don't musicians hold down keys for sustain, and then press more keys?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 7 years ago in reply to shabaz

    Chords work fine as long as the multiplexer is fast enough to see everything. All notes that get played get passed along in real time. Sustain is handled differently depending on the system. For example on an electronic organ you can make it hold the note as long as you keep it depressed, or you can make it decay like a piano. Suppose you have your inputs set up as drum pads but you want the output to sound like a horn - you may need to do a drum roll which would get interpreted as a sustained note, which is fine because a horn can only play one note at a time and it can't do a drum roll.

    A real piano has a pedal to allow or kill sustain - a similar function can be implemented on a MIDI system.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • shabaz
    0 shabaz over 7 years ago in reply to dougw

    Hi Doug,

     

    With the switches effectively OR'd together (which is what I believe Ernie is suggesting by paralleling them), then it will not be possible to know the velocity of any key other than the first key that is pressed, because subsequent switched won't be able to close that OR'd switch circuit because it is already closed while the first key is held down.

    For a normal chord maybe it won't matter if the musician wishes the keyboard to assume that all keys are intended to be simultaneously struck with the same velocity, but I just don't know (since I'm not a musician) if there is a requirement to have sustain while pressing additional keys. If there is, then OR'ing won't allow velocity determination for those subsequent keys. I could be talking rubbish! : ) I'm not very knowledgeable in music.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 7 years ago in reply to shabaz

    Good point Shabaz. That is sort of true, but it is possible to have a unique voltage result from any unique combination of keys. The number of keys that can be managed depends on the accuracy of your A/D. For example suppose you have a 12 bit A/D and 12 buttons. If each button corresponds to a bit in the A/D, the most significant button causes a 50% change in voltage and on down the line until the least significant button only causes 1/4096 change in voltage. Each button always causes a unique change in voltage that is different from all others.

    It does get tricky when just using resistors to implement (you need a spreadsheet to figure out all 4096 combinations) - it would be a lot easier to deal with constant current sinks or sources.

    I think MIDI sustain would normally apply equally to all keys pressed at the same time, (because it is convenient) but variability here might lend uniqueness to a musician or a performance.

    Multiple simultaneous velocity is definitely a challenge with this scheme.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • dougw
    0 dougw over 7 years ago in reply to shabaz

    Good point Shabaz. That is sort of true, but it is possible to have a unique voltage result from any unique combination of keys. The number of keys that can be managed depends on the accuracy of your A/D. For example suppose you have a 12 bit A/D and 12 buttons. If each button corresponds to a bit in the A/D, the most significant button causes a 50% change in voltage and on down the line until the least significant button only causes 1/4096 change in voltage. Each button always causes a unique change in voltage that is different from all others.

    It does get tricky when just using resistors to implement (you need a spreadsheet to figure out all 4096 combinations) - it would be a lot easier to deal with constant current sinks or sources.

    I think MIDI sustain would normally apply equally to all keys pressed at the same time, (because it is convenient) but variability here might lend uniqueness to a musician or a performance.

    Multiple simultaneous velocity is definitely a challenge with this scheme.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube