ReaJS script to turn Mono-Pressure into Poly-AT

This script was triggered by a discussion in this GX-80 thread:

I now add it in the “Shared Files” category, to make it easier to find for anyone interested. I apologize to those who have already read about it in the original thread.

The zip files also contains a txt with a few info/instructions about installation and use.
The txt file contains the following text:

midipressuretopoly is a little script which converts “Channel Pressure” data (i.e. monophonic aftertouch, which applies to all notes played) to Polyphonic After Touch messages (which contain info about which note they must be applied to). The note to which aftertouch is applied is the last note played.

This idea of pseudo-poly-AT was implemented for the first time (AFAIK) in Cherry Audio’s GX-80 VST plugin. It’s the sort of Columbus’ egg one would have liked to think about first…but I am glad anyway that someone did think about it. My script is a sort of tribute to Cherry Audio ingenuity (though the script probably lacks all the nuances of their implementation).

The script must be loaded into ReaJS (which is part of the ReaPlugs free package: REAPER | ReaPlugs) and the MIDI output from your controller has to pass through ReaJS before going to the VST plugin, which in turn should be able to use poly-AT.

To make ReaJS “see” the script, the file midipressuretopoly must be placed into the midi folder of ReaJS (for instance path_to_your_installed_vst_plugins\ReaPlugs\JS\Effects\midi). Then use the “load”
button in ReaJS to load the script with Load->midi->midipressuretopoly.

In short, that’s what the script does:

  • if a NOTE ON is received, the note is “latched”, a poly-AT=0 is sent for that note (as a reset), the NOTE ON message is forwarded to the midi output (i.e. to your instrument VST); before all that, however, if the “Reset Held Notes” option has been selected, the poly-AT is set to zero for the previously latched note which as a consequences looses the modulation;

  • if a NOTE OFF is received, a poly-AT=0 is sent for that note; moreover, if the released note is the one latched for poly-AT we reset the latched value (it is set to -1); the NOTE OFF is also forwarded to the midi output

  • if a CHANNEL PRESSURE message is received and the latched note is not =-1, a poly-AT message is sent for that note (with the value of the pressure taken from the received message) instead of the channel pressure message (which is not transmitted); this last point is of course, THE point of all of this.

I hope you will find this little script useful.
Gabriel

midipressuretopoly3.zip (2.2 KB)

8 Likes

A new version of my script is available and I have included it in the attached zip file, together with the old one.
The new version is called “midipressuretopolylag”. I have added smooth transitions of the poly-AT values both when going to zero (i.e. when a new note is pressed) and when going up from zero. The algorithm simulates the response of a one-pole RC low-pass filter. The smooth transitions are active if “Reset Held Notes” is on.

New parameters have been added to control the behavior of the script:
Attack and release time constans (in ms): the transitions can last up to ~2 seconds (500 ms time constant)
AT update period: during the transitions, a new poly-AT message is sent every AT-period samples. Increasing this parameter, decreases the amount of poly-AT messages sent for given attack and release times.

The zip file also contains two txt files, explaining the behavior of the two scripts.

The image shows the poly-AT messages generated (as a function of time in seconds) when C4, C5 and C6 are pressed one after the other. The first transition happens as normally expected. When the second key is pressed, the AT of the first goes to zero exponentially and the AT of the second goes up in the same way (flipped exponential). When the last note is released, we see first the AT going down, as finger pressure on the key diminishes…then a small exponential decay can be seen at the end when the note off message is generated.
C4_C5_C6_attack220ms_release500ms_update256samples

Cheers!
Gabriel

P.S. Many many thanks to @Ade who put the new script to some stress before release. Any remaining bug is my fault not his! :wink:

Update: A new zip file with updated txt files is available down below in this same thread. The scripts are the same in both zip files.

Update2: The latest versions of the scripts (including bug fixes and new features) will always be found at the bottom of the thread. Please ignore intermediate versions.

midipressure_to_polyAT.zip (6.4 KB)

5 Likes

Great!!
Thank you for putting this together!
:+1:t2::+1:t2:

Gabriel,

You could add a line on the readme file:

Do not copy this text file to the destination folder.

Seems like ReaJS get mad if either the script and the .txt are found.
You also can delete “(N.B. I do not own REAPER, I got this info from the web)”. The depicted procedure works perfectly in Reaper. :slightly_smiling_face:

BTW, great script.

Hi @cpaolo!

Thank you for checking the installation procedure on Reaper! I will update the txt file.
I will also add a warning not to put the txt in the script folder. On my system, I had no problems with that but I see that the txt file is listed together with the other scripts under “Load” in ReaJS, so I suppose something nasty could happen by selecting it instead of the real script.

Gabriel

P.S. I am glad you appreciated the script. :wink:

1 Like

Here is a new zip file. People who have already downloaded the script do not need to download it again…I have just updated the txt files according to Paolo’s suggestion.

Gabriel

Update: The latest versions of the scripts (including bug fixes and new features) will always be found at the bottom of the thread. Please ignore intermediate versions.

midipressure_to_polyAT_1.zip (6.4 KB)

1 Like

So here I am again, after a bit of debugging. There were a few bugs in midipressuretopolylag, so that sometimes it did not behave as expected.

Here is a picture showing the notes (horizontal lines drawn at the corresponding note midi value) and the poly-AT messages generated by the script. Now it seems that all transitions are managed well. The picture is generated by a python script which I have also included in the zip file (“parse_midi” folder). The script needs the numpy, mido and mathplotlib packages and takes a midifile as input.

midipressuretopolylag_expo

I have taken advantage of this time of coding/debugging to add a few features:

  1. midipressuretopolylag now can generate also linear transitions (instead of exponentials), as shown in this picture:

midipressuretopolylagdel_linear

I am note sure about the usefulness of linear transitions…but who knows? I have added a selector to choose the desired shape of the transitions.

  1. I have included a new script (midipressuretopolylagdel…ok, next step will be having just one script with a much shorter name!) which can introduce a delay before the poly-AT of the previous note is released. This is shown in the next two pictures, for exponential and linear transitions:

midipressuretopolylagdel

midipressuretopolylagdel_lineardelay

The arrows show the beginning and the end of the delay time. I find the addition of the delay quite useful: the poly-AT of the old note now is kept for a while under the new note, allowing for smoother transitions.

Finally, I have been told that the installation procedure, as written in the docs, does not always work on Reaper and I would like some feedback, if possible. The docs are now in a dedicated folder. I would also be glad to receive feedback about the script and the possible remaining bugs.

Gabriel

Here’s the zip file:

midipressure_to_polyAT_2.zip (147.0 KB)

4 Likes

New version of the zip file…now included in the docs there is a pdf manual!

Gabriel

midipressure_to_polyAT_3.zip (406.8 KB)

2 Likes

I really like the release function - very creative use of what might otherwise be seen as a hardware limitation!
:+1:

2 Likes

Bug fixed: when just one key was pressed, after all keys had been released, the attack phase was started anyway, which of course has little use, since the Channel Pressure should be zero at the beginning of the note (it is the first key pressed!). This produced very long attack times when using linear transitions, so that one had to wait a few seconds (the length of the attack) before poly-AT messages were actually sent according to the pressure on the key. Now the first note played, after all keys have been released, does not go through an attack phase anymore.

midipressure_to_polyAT_4.zip (406.8 KB)

I’ve installed the script, but I don’t know how to try/test it. I have an Axiom 61 with after touch, but I don’t own Cherry Audio GX-80. Should I be able to use this script with the Axiom? Is there another VST that I could use to try out this script? Surge XT?
Thank you - David

Hi David!

As far as I know, the Axiom 61 can generate channel (i.e. monophonic) aftertouch messages. So you can definitely use it with the script to control any VST plugin which recognizes polyphonic aftertouch messages (for sure SurgeXT, Diva, Sines, Dreamsynth, Synthmaster2).

Gabriel

Thanks! So I must not be using it correctly - or with the right patch, because I wasn’t able to ‘hear’ any change from playing a chord and varying the pressure between the various notes pressed. It just seemed to, for example, trigger the modulation of the entire chord - not a note within the chord. An I understanding the function correctly?

In fact, you need a patch which is set up to exploit polyphonic aftertouch. For instance, SurgeXT has a pad called “Harmonic Sweep”. To add polyphonic aftertouch sensitivity to this patch, one has to click the “Poly AT” button in the “List” (almost at the bottom of the window). Make sure that the button background becomes light blue. Then click on the light blue “Cutoff” sliders, in the filter section, and slide them to the right, so that they are halfway between the black slider (at least it is black with the skin that I use) and the maximum level.

Now you should hear the last played note becoming more “brilliant” as you increase the pressure on the key. You can click again on the “Poly AT” button to change other parameters: the setting will be kept until you load another patch (you have to save the patch if you want it to remember your polyAT setting).

Gabriel

Edit: Added a picture

1 Like