A Method to Layer Piano and Sustained Instruments (Pads, strings)

I see. What’s so weird is that I noticed two different plugins responded differently to CC64.

The piano vst that I use, for example, turns on the sustain at 64 and above. However, the strings patch I use in Kontakt will not sustain until I hit 127, and will continue sustaining until it gets back to 0.

At any rate, the method you suggested was nearly perfect! I was blown away that I hadn’t been doing this all along. And it seriously cuts down on polyphony and taxes my computer much less.

I only had a couple issues. First, because the sustain on my strings patch only triggers after 127 has been reached, the strings will not sound if the damper pedal is pressed all the way. This means that I have to play the chord before I hit the sustain pedal. In a sense, it operates somewhat like a sostenuto pedal. So I have to have impeccably choreographed timing between my foot and hands (which I’m still working on, haha).

The second issue is that once all the notes that I want sustained are in the “sustain buffer,” they can no longer be controlled by my expression pedal. The held notes are stuck at whatever dynamic/volume they were at at the time the pedal was pressed. I would love to be able to control their dynamics even while sustained.

Because my string patch interacts with the sustain pedal in such an odd way, I thought that remapping some CC controller ranges might help, but I can’t wrap my head around how to do it. A midi script might be necessary.

In a sense, I want the following to happen.

Step 1: Pedal at 0
No sustaining strings

Step 2: Pedal 1 - 126
As pedal is pressed between these values, the strings will not sustain… and in fact, cannot sustain for some reason with the patch that I’m using.

Step 3: Pedal 127
Once the sustain pedal is all the way down, the sustain buffer opens and all notes currently sounding are sustained.

Step 4: Pedal 127 to 1
Once the pedal released to less than 127, the buffer closes and no new notes can be sustained. I’m open to the strings still sounding in a non-sustained fashion, or even not sounding at all.

Step 5: Pedal at 0
All sustained notes being held are released.

Any thoughts on how this can be achieved? Even if there are no ideas on how to do this, I’m super happy to have gotten this close.

On a separate note, is there some place I can go to learn how to write scripts?

Thanks again, Dave… and everyone who has given me some ideas on how to do this!

Thank you Torsten!

Any luck in finding anything? Where could I go to find some coding and/or how to implement it in Cantabile?

Most of the scripting to accomplish what you’re after will happen in Kontakt. Here’s a series of articles that can help you get started:

1 Like

Hi Cordaro,

It looks like it is responding as a hold switch as opposed to a damper. This is probably a function of the Kontakt script for that patch. I’ll have to look into this for any possible logic solution but what I described is definitely not what you need. Sorry if it produced a rabbit hole for you …

FWIW I have been able to use a binding to route the expression pedal to it even though it is blocked on the input route by the filter like this (using cheesemachine as example)

Even though the input route is blocked by the filter you can still use bindings to send CC data to the plugin. It acts as an alternate CC route for one parameter at a a time.

I’ll get back yo you on the other issue ASAP

Dave

1 Like

The plugin I use for custom wizardry is ReaJS, part of the free ReaPlugs bundle.

There’s a bit of a learning curve involved - ReaJS processes MIDI data in chunks of audio buffers, and its programming language (JSFX) is a bit of a funky beast. But you can get interesting things done with it.

Haven’t gotten to tackling your issue yet - not sure when I have some time for that…

Cheers,

Torsten

OK, I took a shot at this and whipped up a little ReaJS script to “deduplicate” notes.

You’ll need to set up your song like this:

So the route from your keyboard to the strings goes through ReaJS.

Paste the contents of the script below into a plain text file (but without .txt extension) in the Reaper effects/midi directory (depends if you have Reaper installed or not; you may have to set the location of your effects directory in reajs.ini) called “midi_deduplicator”. Then load this script in ReaJS - it should become active right away and need no configuration.

Now any note repetitions played with the sustain pedal down (> 63) will be ignored; the script should also catch notes held before the sustain pedal was pressed and released afterwards.

Give it a try and let me know if something doesn’t work quite like it should - I’ve given it a bit of a shake, but not too thoroughly… But it does clean up a string layer nicely :slight_smile:

Cheers,

Torsten

Here is the script (also attached as a zip file for convenience):
midi_deduplicator.zip (841 Bytes)

desc:MIDI Deduplicator
//tags: MIDI processing


in_pin:none
out_pin:none


@slider

@init
@init
notes = 128;
i = 0;
loop(128, notes[i]=0; i += 1;);

pedal_down = 0;

NOTE_OFF = 8;
NOTE_ON = 9;
CONTROL_CHANGE = 11;


@block

  while (
    input = midirecv(mpos, msg1, msg23);
    input  ? (
      statusHi = (msg1/16)|0;
      statusLo = (msg1-(statusHi*16))|0;

      data2 = (msg23/256)|0;
      data1 = (msg23-(data2*256))|0;
     
// .... for Note Ons
      statusHi == NOTE_ON && data2 > 0 && data1 >= slider1 ? (
          pedal_down ? (
          // pedal is down --> deduplicate
        notes[data1] == 0 ? (
            // no previous note --> play and register
          notes[data1] = 1;
          midisend(mpos,msg1, msg23);
        ); // else: previous note active or released --> ignore
      ) : (
          // pedal is up --> simply register notes played
        notes[data1] = 1;
        midisend(mpos,msg1, msg23);
      );
      ): 
// .... for Note Off
    statusHi == NOTE_OFF || (statusHi == NOTE_ON && data2 == 0 ) ? ( 
        pedal_down? (
          // pedal is down --> deduplicate
        notes[data1] == 1 ? ( // active note to kill
            notes[data1] = 2; // remember that note was released with pedal on
          midisend(mpos,msg1,msg23);
        ); // no "else" necessary; all other note off ignored
      ):( // pedal up
          // simply register note off and send
        notes[data1] = 0;
        midisend(mpos,msg1,msg23);
      );
    ) :
// .... for CC 64
      statusHi == CONTROL_CHANGE && data1 == 64 ? (
        data2 > 63 ? (
          pedal_down = 1;
      ) : (
          pedal_down = 0;
          i = 0;
          loop(128, notes[i]==2? notes[i]= 0; i += 1;);
      );
          midisend(mpos,msg1,msg23);      
    ) : (
// .... anything else    
          midisend(mpos, msg1, msg23);
      );
    );
    input;
  );
3 Likes

BTW: the easiest way to find your ReaJS script directory is like this:

Insert ReaJS in a song and open its editor:
image

Now click “load” and load any effect script from the “midi” category:

Hit the “Edit” button and the editor will open - you’ll find the correct directory for your midi scripts at the top of the window:

Cheers,

Torsten

5 Likes

That’s excellent @Torsten, thank you!! I often hit this multiple notes thing when using M-Tron Pro, which also accumulates duplicate notes on separate voices. Not any more - this handy tool is going right in a rack for easy re-use!! :slight_smile:

1 Like

@Torsten

Brilliant Torsten!! You never cease to amaze. :mage:

1 Like

Wow! Thank you so much! This worked super well!

The only complication I have is that in the event that I do want to play the same note twice in a row on the piano, the accompanying string layer will cut off. For example, for the following chords, where the capital letter is the melody line:

Piano : (ceG) --> (bdG)
Strings: (ceG) --> (bd_)

Here, the G cuts off even though I released and pressed the pedal.

It’s more of a timing issue. If I do it very slowly and deliberately, I’ll get lucky and it’ll sound.

But either way, this is super super helpful. I think what I’ll do is have a separate sustain pedal that controls this type of deduplicating sustain. Therefore, whenever I do need the notes to repeat, I’ll just switch to the regular sustain pedal.

Thanks again for this Torsten!

Hi Cordaro

can you show where in this sequence you press the pedal and when you release it? I have an idea about potential timing issues - but that only applies in a very small milliseconds range. But there might be some other gremlin in the script - happy to hunt it :wink:

Cheers,

Torsten

1 Like

Hi Cordaro,

just tested this for a while - deactivated the piano layer to hear better, and tried to reproduce your scenario. Couln’t really reproduce it - played your chords both arpeggio and en bloc, with pedal releases in between; none of the notes got cut off. Not sure if there’s something about your configuration that messes with the sequence of notes and pedals in the MIDI stream?

Cheers,

Torsten

Thank you for checking on that for me!

So, here’s what keeps happening:

  1. NOTE ON - I press down a note.
  2. SUSTAIN ON - I press the sustain.
  3. NOTE OFF - I release that same note, but the sustain pedal is still pressed and the note is still sounding.
  4. NOTE ON - I press the same note again. As designed, it doesn’t retrigger. Perfect so far!
  5. SUSTAIN OFF - As soon as I release the sustain, the note turns off, even though I am still pressing it.

My hope is that the note would continue sounding for as long as it is pressed. Any thoughts on this?

Thanks again!

Hi Cordaro,

well, this is actually how the script is designed:

  • when you release the note in step 3, this note is now signaled to the instrument as released (a note-off has been sent to the plugin) - the only thing that keeps it sounding is the sustain pedal.

  • Now when you press the same note again, it is ignored by the script, because a previous note is already being held by sustain - the note-on-event is (correctly) not sent to the plugin.

  • Prolonging the previously held note is not possible, since it has already been released (the note-off has been sent to the plugin).

  • once you release the sustain pedal, your plugin will automatically release all sustained notes - and it doesn’t know about your second strike that you are holding, because we have correctly ignored that one.

There is no real way around this behavior - the only way to continue the note beyond the pedal release would be to re-trigger it, which is exactly what we don’t want.

The only way to avoid this would be to completely re-work the way the sustain pedal is handled and realize a MIDI-sustain within the script instead of at the instrument level (i.e. hold all note-offs until the pedal AND all relevant notes are released) - this would be a significantly more complex script; I’ll probably not go to that extreme…

Cheers,

Torsten

No worries! I’m super grateful for what it can do as is! I’ve learned a ton here. My work around will be to just use two pedals, one for the deduplicator and the other as a regular sustain.

I’d love to learn JSFX. I’ll be going on tour next week. I think I’ll start looking into it while on the road.

I just got the green light from the band to purchase the software! So I’ll be making a few more tweaks to my setup and test it for stability, and if all is well, I’m taking the plunge, just in time for our next set of shows.

1 Like

Hi Cordaro,

I had some more time to look at this challenge and came up with a another idea that might work. It involves a rack I made that does the needed actions. Below I show roughly the same example song as before but you see another rack added called ‘Note Latcher’. The piano is routed without any filters to the main speaker outs and the Strings are routed to the Note Latcher rack and then to the string plugin.

In operation you play normally while the damper pedal is not pressed. When you press the damper pedal down what ever condition the string plugin is in is held. You can continue sounding piano notes (you’d be playing into an open damper because the pedal is still pressed ) over the held notes of the Note Latcher as long as the pedal is pressed. When you release the pedal the notes that were held for the string plugin by the Note Latcher rack are released and do their release envelope. The piano acts independently from all this so it doesn’t cancel any notes on the held string notes here when tested. The CC 64 on message gets out of the rack to the string plugin before the state switches and blocks all MIDI so the plugin keeps waiting for the off which is allowed through as soon as the state changes back when the pedal is released. Like all experiments it might not behave the same for you and has not been tested rigorously yet.

If you want to try it, here you go, just so you know it’s made for a standard damper switch and not a variable half pedaling type.

Note Latcher.cantabileRack (10.6 KB)

For the rack geeks this is how it works … There are 2 rack states Normal and Hold. On the routing tab for each state it is pretty straight forward. The NORMAL state allows the notes and CC data to pass through to the rack unchanged to the string plugin

In state 2 the pass through route is disabled preventing notes from re-sounding to the string plugin. Since all that was done was an interruption of MIDI data flow on that route to the plugin it is held captive by the last commands before the route was cut off.

On the bindings each rack state is manipulated by the damper pedal in a momentary press style of action because of the source using a straight Controller as opposed to a Edge Triggered Switch. So, state 1 is the unpressed condition of the damper pedal and synchronizes with the enabled pass through route.

when you press the damper down the first binding above calls the second binding that is synchronized with the blocked route condition. When you release the pedal the binding fires and calls state 1 back up for some more notes to happen.

So when I start out playing state 1 remains in effect till I press the pedal down and it instantly goes to state 2 where it remains until I release the pedal and it instantly goes back to state 1 and allows notes and data to get to the plugin again.

So. it’s not really a note latcher rack as much as a conditional route inhibitor I just liked the name better … geeking complete :sleeping::sleeping:

Dave

4 Likes

Yet another follow up on this subject. The previous post had a method that worked OK but when tested rigorously had some problems. In particular fast switching of the damper pedal would confuse my intended logic and get it reversed. So I don’t recommend this approach but since I was sitting there fooling with it on a full rig I found a very good alternative that is more responsive and does not suffer from the drawbacks of the rack. So, here is what I found that worked best for me. The same test example is shown below with the strings and the piano layered to a common controller keyboard.

this time I set the Control window route Condition for the strings plugin route to allow notes and CC to pass while CC 64 = 0. Any other value shuts the route down until CC64 = 0 again.

To hold the notes (since blocking the route also blocks the CC64 it needs to know it should hold) I made a binding at song level to the plugin directly to handle the CC 64 hold messages that is independent of the route that has the notes and added a CC11 direct binding so the swell still worked even with held notes.

In practice method this worked the best of all the solutions I tried. It was very playable after a short adjustment period. It didn’t get “turned around” like my rack idea making it stable and reliable. Since it uses route blocking it also will not sound held notes when the damper is released and only releases the held notes. In use you play the layered instruments with the pedal up. When you press the pedal down it holds the notes that were being held when the pedal was pressed via the binding. You can then play the sustained piano notes over top of the held string notes til you release the pedal. At that point the held notes of the strings are released and the sustained notes of the piano as well. Another interesting extra performance feature is that if you press the damper before playing any notes the piano only will play though the damper. In terms of how to play using this method you have to be precise in your pedal work so you always have the notes pressed that you want at the instant you press the pedal and released when you release the pedal. After playing with it a half hour or so it got very playable. Very good for B3 with piano over top as well

Dave

Gonna try this one. Thanks Dave. :grinning:

You bet Corky, hope it works for you …:grinning:

1 Like

Oh yeah! Duh. Good idea,