1
\$\begingroup\$

I'm building an electric xylophone, or at least trying to, which is velocity sensitive. I approach this by using piezo-sensors. The sampling of the notes will be done on a raspberry pi. So far, I have connected an 8-channel ADC (MCP3008) to the raspberry pi and connected multiplexers (4051) to the ADC. This would allow for up to 64 analog inputs. However, with some experimentation I found that reading all 64 inputs sequentially would take about 8ms on the raspberry pi in python.

Velocity sensitive in this context means that if I hit the bar (piece of wood with piezo underneath) harder, the sound will be louder. The midi protocol calls this velocity and determines it by a value between 0 and 127, so that is also the precision I need from the analog input (7 bits).

The goals is to have a 4 1/3 octave instrument (52 keys), read the piezo-data, find the peak when hitting the piezo and extract midi-signals from that. Some extra inputs would be used for volume control and things like that. With some research and extensive personal experience I found that an audible delay would start at around 10ms. Since there will be some delay between the sampler and my ear (due to DC) I estimate the delay for the piezo-to-midi should be around 5ms total.

I figured that using two MCP3008's would cut the time by half if I use one thread per ADC. I'm afraid that 4ms is still too much to find the peak though. The solution I'm looking for doesn't necessarily have to be extremely cheap and doesn't necessarily have to run on a raspberry pi (sending the signals from an arduino over usb to the pi for example is fine too).

Some personal background to show experience and skill I can apply to the project: Bachelors degree in computer science, working on a masters, so programming in whatever language should not be a problem. Superficial and mostly self-taught skills in electronics, but of course willing to learn. Over 10 years of musical experience with drums and a variety of other instruments.

What are my options to build this setup with the different cost options? If any more information is wanted I will gladly provide it.

Edit: added information about sought-after delay, meaning of velocity sensitivity in this context and contextual personal background.

\$\endgroup\$

closed as too broad by Dmitry Grigoryev, PeterJ, Voltage Spike, Daniel Grillo, Adam Haun Dec 19 '17 at 22:38

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ how about a micro controller at each sensor ... or this analog.com/en/products/analog-to-digital-converters/… \$\endgroup\$ – jsotola Dec 15 '17 at 7:10
  • 1
    \$\begingroup\$ And just "by the way," I think I see some assembly code in your future and not a pure use of library code (written by others for no specific purpose at all) and python. Just a note to the wise. \$\endgroup\$ – jonk Dec 15 '17 at 7:12
  • 2
    \$\begingroup\$ could the velocity sensors be in the mallets? ... then the bars would only need simple touch detection .... the mallet would transmit force data and the bars would transmit which note was struck \$\endgroup\$ – jsotola Dec 15 '17 at 7:13
  • 1
    \$\begingroup\$ I added some information about the delay I want to achieve, what I want to achieve velocity-wise and what my background is in this context to help with assumptions. \$\endgroup\$ – Rien Heuver Dec 15 '17 at 8:51
  • 4
    \$\begingroup\$ First try C. It is a lot faster then Python. I built a LED row/column display I found with Python it would flicker but in C was fine. I even had to add delays. \$\endgroup\$ – Oldfart Dec 15 '17 at 10:35
1
\$\begingroup\$

How about an array of Arduinos? It won't be the smallest solution, but it should still be reasonably cheap and easy to develop.

Depending on the model you pick, each board will have between 6 to 16 ADC channel. These will be connected to an individual xylophone key. You then write code for the Arduinos to handle their own keys. Since this is the only thing the Arduino has to do, it should be feasible even with the limited CPU power.

You can then put these on a common SPI or I²C bus, talking to either another Arduino, or a Raspberry Pi, that will convert the individual messages to a MIDI stream.

\$\endgroup\$
  • \$\begingroup\$ First question that pops to mind: what if I use one arduino and multiplex it's inputs? The fact that the arduino does nothing but what I tell it to do (read inputs), be enough to handle all the piezos on one arduino you think? And also, do I need full arduinos or would the atmegachip suffice? I don't have much knowledge of spi or i2c, so I haven't figured that part out yet, nor whether just the atmegachips is good enough. Since it saves space and money. Oh, perhaps not needless to say: thanks a lot for your input and help! \$\endgroup\$ – Rien Heuver Dec 16 '17 at 12:01
0
\$\begingroup\$

You could have 2 switches on each key. One that closes on a small Press and one that closes When the key is pressed all the way Down. Then you can use the timing between the 2 switches closing and you know the velocity. I think its pretty common to do it this Way. 🙂

\$\endgroup\$
  • \$\begingroup\$ This doesn't work: en.wikipedia.org/wiki/Xylophone \$\endgroup\$ – pipe Dec 15 '17 at 13:44
  • \$\begingroup\$ That would indeed not work on any form of percussion I'm afraid, thanks for the input though! \$\endgroup\$ – Rien Heuver Dec 16 '17 at 12:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.