Skip to content

Cybrid - a DIY MIDI controller with grand piano action

AlexanderBunt

HZPiano Thank you! There will be many moments of learning during this project, I think. But that's a good thing!


AlexanderBunt

HZPiano And, in a well implemented (virtual) piano, this makes restriking the 'string' possible without it being dampened first.

Yeah I understand that part, but on a carillon, there are no dampeners. Do I still need three 'measure points', or just two?


HZPiano

AlexanderBunt Three sensors (with strategic placement in the key travel to allow the restrike without having to go all the way back to the top, and still have velocity information between the en-route and lower sensors) at least.

Or have optical/magnetic position sensors which, with nifty programming, can do a lot more nuanced things than "just" three sensors. But there, my insights are theoretical rather than practical, but some great people here know a lot more about that.

Cheers and best,

HZ


JayKominek

@AlexanderBunt Ah, doing a carillon is an interestingly different technical challenge.

Some of the key differences I see from doing a piano:

  1. Physically quite a bit larger per-note. Both the overall structure, and the individual keys. You have space to put things wherever you want, and to make keys that feel right you're going to end up with long, thick pieces of wood.
  2. You have fewer notes; presumably a max of 77, that being the largest real carillon?
  3. Your keys only do one interesting thing; they trigger the mechanism which strikes the bell. They don't then dampen it later. Right?
  4. Everything is made from scratch; you're not interested in pulling unused carillon consoles out and converting them?

But you still need to measure the instantaneous velocity as the key passes some triggering point?

I don't think using optical reflectance to measure distance is at all appropriate for you. That'll be a pain, and there's no reason you need to constrain yourself with physically small sensors.

My initial thoughts for you would be to use rotary encoders that can attach to existing shafts, like these https://www.cuidevices.com/catalog/motion/rotary-encoders and then measure the angular velocity at the shaft. You'll get clean values which directly correspond to physical motion you can understand. They're expensive, probably starting at $20/ea, likely more with limited availability of everything these days. But it might be possible to connect all the ones you'd need to a single sufficiently powerful microcontroller. That'd make your life quite a bit easier. But some design work, reviewing the interfaces available on those encoders, would be necessary.

Similarly, you could adapt some sort of fine-resolution rotary encoder like you already accidentally purchased to the task.

I'd shy away from potentiometers, if nothing else because you'd need to get a huge number of ADC channels and that is more of a pain in the ass than the casual observer realizes.

You could also apply optical reflectance sensors as they were originally intended to be used. Point one at the side of every key, and put a strip of alternating black and white lines on the key, such that as the key moves the sensor will swing between its minimum and maximum outputs. That'll get you a pulse train proportional to speed. You'd need a tiny bit of clean up on the signal and then it could go straight into a microcontroller. You could almost certainly get away with feeding 77 such signals into a single sufficiently powerful controller.


AlexanderBunt

JayKominek So enough to think about…

To be clear: I don't have to build the console by myself. I bought a practice console with no bells attached, so I only need to do the electronics… And also, I just have 52 keys I think. That's making things easier.

I like the last idea you got. I think there is enough space to do this. So for my concern: you mean putting a CNY70 for example at the side of a key, and then a strip of (for example 2 black and 2 white) stipes on the side of the key. Then measure the time between the sensor switching from black(far) to white(close).

I think there is also a sensor needed which registers that the key 'hits' the bell, to give the 'note on' signal. That combined with the velocity of the sensor at the side of the key will be a solution maybe. But then, you need a double of inputs (104)… and thats too much for a regular board.

And what do you think about pressure sensors, like the FSR402? My concern with these things are that they won't last long, cince there are many hits on them. But maybe this will work very nice; No need to worry about travel distance from the key here…

A last thing to keep in mind: the amount of keys that is pressed at the same time is not so big as in a piano or organ. Maybe like 5 keys at the same time max. But the reaction speed needs to be very quick.

Would like to hear your ideas on these things!


MrGr

RIP (I asked estimate to about 10 different companies/technicians and all gave similar price range and similar explanations at my balking)

6k$ ?


RIP

MrGr Del Vento (I asked estimate to about 10 different companies/technicians and all gave similar price range and similar explanations at my balking)

6k$ ?

Are you asking me the price range? If so, yes, you got it right, that was in right the range.


RIP

AlexanderBunt And what do you think about pressure sensors, like the FSR402? My concern with these things are that they won't last long, cince there are many hits on them. But maybe this will work very nice; No need to worry about travel distance from the key here…

I would not use them for the same concern you stated but that's just me. After all also LED have a finished life, so even "our" sensors may degrade and die with time.

AlexanderBunt I like the last idea you got. I think there is enough space to do this. So for my concern: you mean putting a CNY70 for example at the side of a key, and then a strip of (for example 2 black and 2 white) stipes on the side of the key. Then measure the time between the sensor switching from black(far) to white(close).

I think there is also a sensor needed which registers that the key 'hits' the bell, to give the 'note on' signal. That combined with the velocity of the sensor at the side of the key will be a solution maybe. But then, you need a double of inputs (104)… and thats too much for a regular board.

It obviously depends on how much you want to design on your own versus as much you want to reuse from someone else. If you are not too much opposed in the latter, I believe your best bet is one of the things that Jay, stem_piano or I are doing (with the help of many others who AFAIK are not getting into the hw yet). Once you use these sensors to detect the position (of hammer or key in the piano's case) you can do many things with just one sensor per key. Note: this is different from what CG did with the comparators, which basically used the optical sensors as fancy touchless switches.

Also you may want to check for inspiration wrt what others do by lurking https://www.kvraudio.com/forum/viewforum.php?f=180 -- I don't think there is anything super-exciting for this purpose there, but that's with the lens of my interest, not yours.

Well, it's a pretty dull post, sorry that's the best I can do in between commits to my own repo 🙂


MrGr

The real question is:

Is Your Cybrid Safe From Supermaneuverable Air-Defense Fighter Aircraft?

(can we call this type of comedy "postmodern"? 🤣)


AlexanderBunt

RIP I've been thinking it over, and I think the best way for me to do this is to use one CNY70 sensor under each key. Cince I don't need to send a 'note-off' signal, the most realistic method is to let this one sensor capture the moment when the key is, lets say 1cm, above the bottom of the shaft (above hitting the bell) and then capture the moment when the key is ca. 0cm from the bottom of the shaft (and thus on the point of hitting the bell). Then calculate the time between this two points for the velocity, while sending a note-on signal when the key is at 0cm (hitting point).

So in short, use the method of CyberGene, with only two points of measurement, which will simplify the physical structure and also the code.

To be clear:

  1. Key is being pressed.
  2. Key passed first point (1cm from bottom): set time of first point.
  3. Key hits bottom(at 0cm): set time of second point.
  4. Calculate time between first and second point -> velocity.
  5. Send note-on with velocity to computer software.

I think this will give the most realistic result, because many times, the carillonneur will leave his hand on a key (leaving it in the middle) before pressing the key again, but mostly at a different speed as the time before. Also, when he makes a tremolo, he leaves the key just a tiny bit (thats why I said 1cm but it can be less) above the bottom of the shaft and pressing the key quickly a few times. So between each note he lifts the key maybe 1 or 2 cm when he plays a tremolo. And with different velocity of course.

Curious what you think about this.

And why JayKominek should I stay away from potentiometers? I don't see the point that it will use many ADC channels. As I see it, @CyberGene did also use potentiometers, but used just one ADC channel per key… Cince I have but 52 keys, this won't be a problem…

As I said, I would love to hear what you think about this.


RIP

AlexanderBunt So in short, use the method of CyberGene, with only two points of measurement, which will simplify the physical structure and also the code.

and

AlexanderBunt should I stay away from potentiometers?

Because they are extremely tedious to install and regulate?

The non-potentiometric only-two-measure-point code is extremely simple:

https://github.com/davidedelvento/Mybrid/blob/main/RaspberryPiPico/pico-piano.c#L355-L393

Also, with this approach you can have the distance adjustment in software as I do in https://github.com/davidedelvento/Mybrid/blob/main/RaspberryPiPico/pico-piano.c#L521-L560 so you can have a number of settings, perhaps for testing and/or for different kind of music. Good luck re-regulating all the potentiometers with a screwdriver….

Alternatively you can use a DAC instead, which will be similar to what @CyberGene did but in software. I have not thought too much about it, besides that you need one DAC channel per key or a fast multiplexed one. That might work well too.

AlexanderBunt Curious what you think about this.

I think that electronically and as far as code is concerned this sounds very close, if not identical, to what we are doing for pianos.


AlexanderBunt

RIP Okey, this sounds good. If it is possible to do two measure points without potentiometers, that would be better of course. I didn't know this was possible, so thanks for the advice!

I think that is what I will do then. Use one sensor per key, and adjust the measure points in code. I see you did this with a Raspberry Pi, but do you think it's also possible with for example a Teensy 3.5 of Arduino Mega (calculating speed etc.)?


CyberGene

What is the travel of a key in mm? From the pictures it seems it might have a long travel which means you can put the measurement points farther apart which in turn would make the need to have very quick measurement less important compared to a piano. In the Cybrid I have put both points within the last 1mm of the hammer travel (to allow for off-the-jack detection) and the hammer itself has a very high velocity (5 times greater than that of the key) and so I completely eliminated an ADC approach and relied instead on the trimpots because the entire solution provides a pretty quick measurement of those high velocities and that is also possible through just a single controller like the Teensy. I have not been following what Jay and Del Vento use in their projects since I moved on from this project to other things (it was rather a one-off project to make myself busy for a while and learn new things but I’m not actively interested in the Cybrid or the other similar projects anymore), however to my understanding their projects rely on multiple ADC-s that will solve the inherent problems of Cybrid: having to regulate all the 88 * 3 trimpots, as well as having to scan very quickly in order to measure precise durations. With on-site ADC-s you can measure each hammer velocity (or rather position) in isolation, without having to wait for the entire scan to finish, and also having absolute positions of hammers at frequent sample intervals allows for eliminating trimpots and instead using software to calibrate stuff and to model velocity detection, prediction, etc. All that being said, the complete calibration took me 2 hours and I didn’t have to touch it too often. Maybe touch a trimpot or two once a week. But what Del Vento and Jay are using is much more advanced.

Besides, they are still working on their projects and everything is fresh in their heads. As I said, I moved on to just learning new Scriabin pieces on the piano, so I don’t remember a lot in details about the Cybrid 😃 Also I waste a lot of time screwing around with sound synthesis on virtual analog synths and stuff like that these days…


AlexanderBunt

CyberGene The travel from full up to full down is around 80mm (8cm), but it depends on the console. But, the measurement distance should be not more then 1cm maximum (so first point at 10mm from the botton of the shaft and second point at the bottom of the shaft (ca. 0mm)), because many times the carillonneur keeps the key down while pressing it more times after eachother. But I don't know anything about the technic with the sensors at all, so I don't know what is the best (and most easy) solution. For example, I don't know what you guys mean with 'ADC'…

CyberGene With on-site ADC-s you can measure each hammer velocity (or rather position) in isolation

This seems to be a nice solution, but I don't know a thing about ADC's and measurement speeds. So is this still possible with a measurement range of max 10mm (I think maybe even less, at about 5mm…). And I don't know what's the best way to programm this kind of software… Maybe somebody can help me with that too.

I'm sorry if I sound a bit dumb on this forum, but I have no real experience with this stuff ;-) So I don't know what will work good that isn't too difficult.

From my perspective, it would be best to have one CNY70 sensor per key, at the bottom of the shaft. Then let the Teensy or Arduino calculate all the velocity's based on the time between the first and second point. But as I said, no knowledge about this, so I don't know what's possible.


CyberGene

A single Teensy has 25 analog pin inputs. Well, internally there are only 2 ADC-s, so they will be multiplexed as far as I remember but it doesn't hurt for you to test if you can directly wire multiple CNY70 to the analog inputs and try reading them in sequence. If that works quick enough, then you can use 2 Teensy boards for 50 keys (or three Teensy boards x 18 inputs each = 54 analog inputs) and then just record MIDI in your DAW from multiple MIDI inputs which is certainly possible on a Mac. If that works (because 10mm is a lot and would allow for the slight imprecision introduced through the slow sequential and multiplexed ADC), then your task is just wiring 52 CNY70-s and 52 resistors and you will be good to go.

P.S. My very first POC was using an Arduino with a single CNY70 and a resistor hooked to the analog input:

It wasn't MIDI-ed, just printing duration:

boolean firstActivated = false;
boolean secondActivated = false;

long firstActivatedAt;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int v = analogRead(A0);
  float volts = (v / 1024.0) * 5.0;
  long timestamp = micros();
  
  if (volts >= 4.0) {
    if (!secondActivated) {
      secondActivated = true;
      long duration = timestamp - firstActivatedAt;
      Serial.println(duration);
    }
  } else if (volts >= 2.0) {
    if (!firstActivated) {
      firstActivated = true;
      firstActivatedAt = timestamp;
      Serial.print("*");
    }
  } else {
    secondActivated = false;
    firstActivated = false;
  }
  
  
  
  
  
  //Serial.print("Value: ");
  //Serial.print(v);
  //Serial.print(" Volts: ");
  //Serial.println(volts);
  
  //delay(1);
}


CyberGene

Thinking about this in retrospective, I based my entire Cybrid implementation (trimpots and comparators) on the assumption ADC is slow but I never actually measured how slow it is. In that ADC link from the forum I posted above, it seems the precision of the ADC depends on the duration of sampling but it is possible to sample the ADC on every ADCK which might be very short. I am wondering if just measuring the CNY70-s directly through the Teensy ADC, even with a low precision, might have actually be the better way to implement the Cybrid 🤣 Imagine if the effective result is not unlike what I achieved through the entire contraption that the trimpots, comparators and transceivers do 🤣 Anyway, back to Scriabin I guess...


AlexanderBunt

CyberGene 10mm is a lot

Less would be better or worse?


AlexanderBunt

CyberGene Imagine if the effective result is not unlike what I achieved through the entire contraption that the trimpots, comparators and transceivers do

Haha that would be nice to find it out just now😂


CyberGene

AlexanderBunt I think 10mm is within the range of the CNY70, although I'm not sure what its range is but intuitively I'd avoid measuring longer distances than 10-20mm.

But I mean something else. In order for a velocity detection only at hammers for a piano to work correctly and not miss strikes, one needs to measure only the last 1-2mm of the hammer strike. Because it's possible for you to press the key until it reaches the escapement point and then throw it. The escapement distance is 1-2mm of the hammer. However the key-hammer leverage is 1:5 meaning the hammer travels 5mm for every 1mm of key travel. This means the hammer is very fast and if you have to measure only 1mm of its travel, you have to be very quick.

Now, if that distance was 10mm, you have more tolerance to measure the start and end. And then, since you will be measuring Carillon keys which are not leveraged, they will be much slower than a piano hammer.

Which is why I think you have much less critical requirement for a Carillion project compared to a piano. And is why I think even direct ADC from the CNY70 multiplexed from all its analog pins might turn out to work for you. Then everything will be in the code.


« Previous Page Next Page »