Topic: 80s electric piano up-cycling with Pianoteq!

Hi everyone,

I hope that I can inspire a few people here with my recent up-cycling project: My wife has a very old Yamaha CLP 300 (built in the 80s!) that was still in perfect working condition but sounded quite a bit outdated. Because it was instant-on and has speakers built-in and good enough for quickly finding a chord it found a place in my studio next to a Kawai MP9II and a Fatar SL990.

Because the keyboard on the CLP is also actually rather good, I was reluctant to throw it away. So I decided it's time to take take what I like and replace what I don't like. The plan was to eliminate the huge Yamaha mainboard and keep the power supply, amplifier, speakers and all of the user interface. This would require understanding the circuits that remained in the piano - mostly the amplifier, PSU, control panel, keyboard and pedals - and to replace much of the required actual functionality with custom circuits and a mini computer running Pianoteq.

In order to allow the keyboard to shine, I was aiming at creating a high resolution and high dynamic range key scanner. This requires scanning the keyboard diode matrix much more frequently than for ordinary keyboards and also taking the electric design to the limit in terms of parasitic effects in the cables. I ended up designing a key scanning circuit that drives the diode matrix through 1k pull-up resistors towards 3.3V for enough current to minimise parasitic effects and to scan it with high speed CMOS shift registers and power line drivers able to sink enough current. The entire thing is controlled by a Teensy 3.6 micro controller board also responsible for connecting to the user control panel and using the former analog volume control as a midi controller.

The teensy easily interfaces with USB Midi which connects to an Odroid XU4q (fanless) running a custom-built Armbian with custom realtime kernel and all sorts of non-standard optimisations for best performance. Pianoteq runs as a system-service with realtime priority and explicit CPU affinity to only use the four high speed cores the Odroid offers. The other four cores run at the lowest possible clock speed and serve the kernel and OS needs.

Pianoteq obviously runs headless and is controlled using the Teensy's MIDI output. So the functionality of the original button panel is fully retained together with extra functionality like having 4 patches for each patch button, selected by repeated button pushes and indicated by the corresponding LED flashing differently.

The original plan was building an Audio interface for the Odroid's I2S output that would connect to the preserved CLP300 amplifier. During testing I however found that using a very simple and cheap USB interface already gave me the performance and sound that I needed. A simple adapter circuit with a relay switch connects it to the amplifier and splits off a balanced line driver for balanced stereo line output. Headphone amplification and silent switching is handled by the original amp.

Pianoteq runs wonderfully on this setup. I can achieve sub 2 ms latency and 96 voices at 48k easily. The keyboard action is also great and perfectly tuned to what Pianoteq expects.

I would love to share some pictures and additional details. But it seems like you cannot upload pictures here. I wouldn't want to rely on some image hoster that removes the images at some and leaves the links point to nirvana. Any best practices in the forum regarding images?

Cheers,

Andreas

Re: 80s electric piano up-cycling with Pianoteq!

Cool project. Nice audio solution (cheap USB DAC to amplifier).

Would be interested in hearing more details about how you setup the Odroid XU4 to work with Pianoteq. Especially assigning the 4 high performance cores to Pianoteq and 4 low performance cores to the OS. Also what Pianoteq Performance Index number are you getting?

Last edited by Groove On (10-04-2018 23:51)

Re: 80s electric piano up-cycling with Pianoteq!

Groove On wrote:

Would be interested in hearing more details about how you setup the Odroid XU4 to work with Pianoteq. Especially assigning the 4 high performance cores to Pianoteq and 4 low performance cores to the OS.

Tuning the OS was one of the bigger parts of the project. I'm not done with that too - I still would like to reduce the boot up time from 20 seconds to under 10.

I started with a vanilla Armbian installation and then tuned it. First I tried using all 8 cores, then 7 cores by setting the cpu affinity mask when launching pianoteq (see 'man taskset' for details). Because Pianoteq apparently tries to share the processing load symmetrically, the slower cores seemed to limit the total performance. So explicitly mapping Pianoteq to the fast cores improved the reliability.

Setting the OS to use all other cores is then simply a matter of giving the Pianoteq threads an extremely high priority and taking it out of the OS processing task group management. All other processes will then automatically be mapped to the remaining cores that I set to run at 600 MHz manually, while the high performance cores run at 2GHz. Another future optimisation will include shutting down three of the slower cores altogether to remove scheduling overhead and reduce the thermal footprint.

Very important for stable low latency was using realtime interrupt scheduling and setting the USB audio interface interrupt at the highest priority.

Also what Pianoteq Performance Index number are you getting?

It's been a while since I've seen it and I believe it was 38-ish.

Re: 80s electric piano up-cycling with Pianoteq!

wow, i can't understand all the details, but sounds amazing.

i do find it funny, in a friendly way, that a genius like you couldn't figure out how to post images here.

use the BBCode help.

you can host your images here:  https://imgbb.com/

steve200

Re: 80s electric piano up-cycling with Pianoteq!

andreastell wrote:

... the remaining cores ... I set to run at 600 MHz, while the high performance cores run at 2GHz ... reduce the thermal footprint.

You might be able to get a stable machine (meaning no throttling) if you drop the CPU speed a few GHz. There’s more information in this very long thread about cooling a fanless Odroid XU4.

The short of it is that the XU4 CPU is overclocked at 2.0Ghz. At that speed, under a constant high-load, the CPU will almost immediately generate enough heat to throttle down to 800Mhz. But simply dropping the stock CPU speed to 1.9 GHz produces significantly less heat, so it is less sensitive to throttling.

They were able to get a fanless XU4 stable at 1.5Ghz with the CPU under a constant load. The XUQ with the blue heat sink was able to dissipate the heat as fast as it was generated - so no throttling at 1.5Ghz. Considering that their stress tests are insane compared to anything Pianoteq will throw at it - a stable non-throttling Pianoteq XU4 box might doable at around 1.7 or 1.8Ghz. Maybe even 1.9Ghz.

FWIW - the XU4 CPU is officially rated to run stable at 1.2 GHz without any cooling solution.

Last edited by Groove On (12-04-2018 18:46)

Re: 80s electric piano up-cycling with Pianoteq!

Groove On wrote:

You might be able to get a stable machine (meaning no throttling) if you drop the CPU speed a few GHz.

Oh, my setup is totally stable. The custom kernel throttles very conservatively and I am using a high surface area passive heatsink. In fact, mostly taking the slower cores out of the equation allows me to run at 2GHz without throttling.

I only mentioned additional optimisations because I want the system to run as cool as possible.

The short of it is that the XU4 CPU is overclocked at 2.0Ghz. At that speed, under a constant high-load the CPU will almost immediately generate enough heat to throttle down to 800Mhz. But simply dropping the CPU speed to 1.9 GHz produces significantly less heat, so it is less sensitive to throttling.

1.9 GHz is in fact my first throttling step. So the system will go there automatically if it reaches 90°C, which it so far never has.

Thanks for the pointer to the thread! It's very useful to see how others have dealt with the cooling issue.

Andreas

Re: 80s electric piano up-cycling with Pianoteq!

steve200 wrote:

i do find it funny, in a friendly way, that a genius like you couldn't figure out how to post images here.

use the BBCode help.

you can host your images here:  https://imgbb.com/

Heh, I was more asking for a hosting service that provides long term storage. I was aware of BBCode.

But it seems that imgbb does not delete images after a certain time if you associate them with a user account. So that's good news! Thanks for the link!

Andreas

Re: 80s electric piano up-cycling with Pianoteq!

So finally a few images with further detail:

The final result looks like the original CLP300 and preserved all the user control features:

https://image.ibb.co/cqeyux/IMG_0253.jpg

Inside a few things have changed. You can see the power supply board on the left and my own board arrangement on the right replacing the original mainboard. The dampening wool has been added behind the case speakers to reduce cavity resonances and acoustic short circuits in the low frequencies.

https://image.ibb.co/fotPZx/IMG_0256.jpg

Now for comparison the original 80s mainboard with discrete Logic ICs and proprietary Yamaha CPUs next to my replacement. I've covered the area of the original mainboard with a hard-foam board that carries the different components now.

https://image.ibb.co/mzfA7H/IMG_0280.jpg

Up close, you can see the PSU and speaker amplifier to the left and the odroid on the far right. In between are the three custom boards I have added. The biggest board in the centre is the key scanning circuit. It acquires the state of the keyboard at a rate of 30kHz which is 30 times faster than most commercial key scanners. That means the key velocities can be determined much more accurately and the fastest keystroke is also much faster allowing for a better dynamic range of the keystrokes. I am tracking note-on and note-off velocities as well. The Teensy on the top right converts the timing information to MIDI with high resolution velocity and sends it to the Odroid using a USB link. The velocity data is actually calculated based on the true key velocity without any form of additional modifications. This is exactly what Pianoteq requires to calculate the physical model, so no additional calibration is needed for a great translation of the action.

https://image.ibb.co/jFi8ux/IMG_0257.jpg

A better view of the boards with some of the cables removed. The top left board interfaces with the damper and sustain pedals and sends the data to the teensy. It also takes the audio signal from the usb-cable interface and prepares it for the amplifier. The relay on the board turns audio output on when Pianoteq is fully loaded. In the middle of the board there is an audio line driver that is supposed to deliver balanced line out to the connectors on the back of the case. This section is not yet fully working and the line out connections are still missing. On the back panel there is an ethernet connection that links to the odroid, so that it can be accessed from outside without opening the case.

https://image.ibb.co/dr1uZx/IMG_0260.jpg

Re: 80s electric piano up-cycling with Pianoteq!

Wow I came here from the other post, I bought a XU4q for Pianoteq but never took the time to set it up. May I ask how long does it take to boot up?

EDIT: I also have bought a Teensy 3.5 and a 3.6... everything is in a box somewhere
My plan was to use little magnets and hall effect sensors which I also have

Last edited by marcos daniel (02-09-2019 16:44)

Re: 80s electric piano up-cycling with Pianoteq!

marcos daniel wrote:

Wow I came here from the other post, I bought a XU4q for Pianoteq but never took the time to set it up. May I ask how long does it take to boot up?

As I wrote above somewhere, it takes about 20 seconds from power-on to being playable. The longest time is spent in loading the kernel modules. It should be possible to change the kernel configuration to remove all irrelevant bits and pieces and include the important things statically and reduce the boot time significantly. I have not had the time to really approach this, as there are some issues with compiling kernels for the Odroid. Compilation may fail and it's hard to track down the options that cause it. So creating a working kernel configuration that also includes the realtime preempt patch takes a significant amount of trial & error.

EDIT: I also have bought a Teensy 3.5 and a 3.6... everything is in a box somewhere
My plan was to use little magnets and hall effect sensors which I also have

What are you planning to use the sensors for?

Andreas

Re: 80s electric piano up-cycling with Pianoteq!

I planned to use the sensors instead of switches to track key's movement

Re: 80s electric piano up-cycling with Pianoteq!

marcos daniel wrote:

I planned to use the sensors instead of switches to track key's movement

That doesn't sound feasible. Apart from the much slower reaction time of a Hall sensor and the much less precise switching position, you would not be able to use a diode matrix for scanning. Instead, you would have to scan all the key sensors directly. I don't think there's a microcontroller with this many inputs. And multiplexing is probably much too slow.

So what are you trying to achieve? Switches work very well if done correctly. What kind of advantage do you think you get from using Hall sensors?

Andreas

Re: 80s electric piano up-cycling with Pianoteq!

In paper it seemed feasible, I only tested with 5 or 6 keys and it worked well. Hall sensor are quite fast if you use an 1KOhm pull down resistor. I have abandonded my project because of lack of time.