Old 07-09-2014, 02:08 PM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default Fix overlapping notes (restrict polyphony to one voice)

Hello!

Is there any script that would fix different overlapping notes? Let me explain:
imagine a scale : c,d,e,f,g,a,b,c. There could be three cases:
a) Some adjacent notes have a small gap between them
b) some end exactly when the next note starts and
c) some end a little bit later than the start of the next note (they overlap).

Is there any script that would turn notes of case c) into notes of case b)? So, it would trim the end of the notes so that they end when the next note begins?

There is a fix overlapping notes action in the MIDI Editor but it seems to do nothing! Is there any script that does it? And if not, would someone be kind enough to make it? I am sure it would be useful to all!

Thank you!

Last edited by amagalma; 07-09-2014 at 02:28 PM.
amagalma is offline   Reply With Quote
Old 07-09-2014, 03:43 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Hi,

in the MIDI editor, try: Edit -> Set note ends to start of next note.
(works on selected notes)
Is that what you're looking for ?
nofish is offline   Reply With Quote
Old 07-09-2014, 04:24 PM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks nofish,but it is not exactly what I want. That would make all notes of the scale to be of case b) in my first post. I want to convert only notes of case c) and leave case a) notes alone!
amagalma is offline   Reply With Quote
Old 07-09-2014, 04:28 PM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Look this FR, it explains it better.
amagalma is offline   Reply With Quote
Old 07-10-2014, 03:11 AM   #5
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Try this EEL script:

Code:
// Restrict polyphony (EEL script by spk77 10.7.2014)

function restrict_polyphony() local(index, take, note_cnt, is_selected, is_muted, start_pos, end_pos, chan, pitch, vel, start_pos_next)
(
  (take = MIDIEditor_GetTake(MIDIEditor_GetActive())) ? (
    MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40659); // run (MIDI editor) action "Correct overlapping notes"
    Undo_BeginBlock();
    index = -1;
    MIDI_CountEvts(take, note_cnt, 0, 0);
    while (((index = MIDI_EnumSelNotes(take, index)) != -1) && (index + 1 < note_cnt)) (
      MIDI_GetNote(take, index, is_selected, is_muted, start_pos, end_pos, chan, pitch, vel);
      MIDI_GetNote(take, index + 1, 0, 0, start_pos_next, 0, 0, 0, 0);
      end_pos > start_pos_next ? MIDI_SetNote(take, index, is_selected, is_muted, start_pos, start_pos_next, chan, pitch, vel);
    );
    Undo_EndBlock("Restrict polyphony", -1);
  );
);

restrict_polyphony()

Last edited by spk77; 07-10-2014 at 04:05 AM. Reason: run action "Correct overlapping notes" before adjusting note ends
spk77 is offline   Reply With Quote
Old 07-10-2014, 03:45 AM   #6
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thank you spk77!!!

I am slowly trying to make Reaper my default MIDI editor and stop relying on Cubase when MIDI comes into play! This action was one of the important ones I were missing in Reaper!

I am in the process of making my custom MIDI toolbars with all the things I need.

Another more complicated script I need is one that toggles a chord from "closed" to "open" position. I am going to open a new thread about it.
amagalma is offline   Reply With Quote
Old 07-10-2014, 04:03 AM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by amagalma View Post
Thank you spk77!!!

I am slowly trying to make Reaper my default MIDI editor and stop relying on Cubase when MIDI comes into play! This action was one of the important ones I were missing in Reaper!

I am in the process of making my custom MIDI toolbars with all the things I need.

Another more complicated script I need is one that toggles a chord from "closed" to "open" position. I am going to open a new thread about it.
I had to modify the script - now it runs the action "Correct overlapping notes" before changing the note lengths (there was some weird updating/refreshing problem). I hope it works now .
spk77 is offline   Reply With Quote
Old 07-10-2014, 04:41 AM   #8
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I downloaded it again. Thank you very much!
amagalma is offline   Reply With Quote
Old 07-10-2014, 08:11 AM   #9
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by amagalma View Post
Thanks nofish,but it is not exactly what I want. That would make all notes of the scale to be of case b) in my first post. I want to convert only notes of case c) and leave case a) notes alone!
Ah yes, you're right, missed that.

Good that someone more clever than me now chimed in here.
nofish is offline   Reply With Quote
Old 04-20-2015, 08:09 AM   #10
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

A small question / request...

Can the script in post #5 maybe be made to work on all editable items instead of as currently only the active take ?

That would come in very handy here for applying this script to several items at once instead of doing it one by one.

Thank you.
nofish is offline   Reply With Quote
Old 04-20-2015, 08:57 AM   #11
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by nofish View Post
A small question / request...

Can the script in post #5 maybe be made to work on all editable items instead of as currently only the active take ?

That would come in very handy here for applying this script to several items at once instead of doing it one by one.

Thank you.
No

We have:
Code:
EEL: MediaItem_Take MIDIEditor_GetTake(HWND midieditor)

get the take that is currently being edited in this MIDI editor
spk77 is offline   Reply With Quote
Old 04-20-2015, 12:58 PM   #12
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Dear people,

I maybe pretty stupid but why this script if we have a note legato function in Reaper's Midi Editor ??
vanhaze is offline   Reply With Quote
Old 04-20-2015, 01:07 PM   #13
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Vanhaze
For midi export for exemple, or for clarity :P
There can be a lot of reasons ^^
X-Raym is offline   Reply With Quote
Old 04-20-2015, 01:40 PM   #14
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

@ vanhaze

check post #2 (me thinking the same - if you mean that function) and post #3 where amalgama explains the difference.
nofish is offline   Reply With Quote
Old 04-20-2015, 01:42 PM   #15
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by spk77 View Post
No

We have:
Code:
EEL: MediaItem_Take MIDIEditor_GetTake(HWND midieditor)

get the take that is currently being edited in this MIDI editor
Thanks spk77.

So - there's currently no way via scripting to get all editable takes (items) and process them ?
Wouldn't that be a good candidate for an API request, what do others think ?
nofish is offline   Reply With Quote
Old 04-23-2015, 05:59 PM   #16
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Quote:
Originally Posted by nofish View Post
Wouldn't that be a good candidate for an API request, what do others think ?
Hi. I think if it was easy most people would include it. Pretty sure spk77 and others have mentioned it in API xmas list and some other places.

Quote:
Originally Posted by nofish View Post
So - there's currently no way via scripting to get all editable takes (items) and process them ?
There's a line in the chunk string that has a number that corresponds to editable and a string that shows up when the item is visible.

It seems to me that there's a few problems with that. EEL currently has a maximum size limit for strings. The chunk for a big item with lots of events can exceed it and the line you want is after the events. Some people use thousands of small items. You would have to look at each one. Another thing is it doesn't always seem to get updated in the project when you might expect it to: As soon as you click the tracklist. So something similar to "Get Selected Item" type functions would probably be better.

You may already be aware that most of these kind of scripts don't work through the MIDI editor. It's just common to use them together. Selecting notes and so on. So you could call this script* on other items takes. You just need to use some alternate identification system, a selection scheme perhaps. Of course, the script has to be written to take that into account.

*edit. Not THIS one, I guess, because it includes-
MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40659); // run (MIDI editor) action "Correct overlapping notes"

So, do we need functions to activate an item too? Maybe that action works on all editable items.

Nope. Also it seems like the overlapping allowed in the ME is somewhat distinct from what is allowed in the item. When you close it a correction occurs, etc.

Last edited by FnA; 04-26-2015 at 01:13 PM.
FnA is offline   Reply With Quote
Old 04-24-2015, 09:40 AM   #17
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by spk77 View Post
// Restrict polyphony (EEL script by spk77 10.7.2014)
Awesome! Thanks spk77!
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 03-31-2017, 02:57 AM   #18
G-Sun
Human being with feelings
 
G-Sun's Avatar
 
Join Date: May 2010
Location: Norway
Posts: 7,318
Default

Thank you spk77
(had a little time finding it with keywords though )
__________________
Reaper x64, win 11
Composer, text-writer, producer
Bandcamp
G-Sun is offline   Reply With Quote
Old 03-31-2017, 10:24 AM   #19
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
Default

Quote:
Originally Posted by spk77 View Post
Try this EEL script:
spk77.... is the posted one the edited version? also is there not a lua version?
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva
hopi is offline   Reply With Quote
Old 10-22-2018, 10:43 AM   #20
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 3,012
Default

spk77's great script removes ovelapping by shortening the end of preceding notes. Is there an action or script that is capable of removing polyphony/overlapping by shortening the beginning of following notes instead of the end of the preceding ones?

.
__________________
Check out AVConvert (free, super-fast media file manipulation via the right-click context-menu in Windows Explorer) and my free VST plugins.
My Reaper tutorials and studio related videos on youtube.
SonicAxiom is offline   Reply With Quote
Old 03-18-2019, 06:40 PM   #21
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 3,012
Default

hope spk77 is doing fine! Hasn't been around for a while ...

Could anybody modify his script to achieve what I'm asking for in my previous post?

.
__________________
Check out AVConvert (free, super-fast media file manipulation via the right-click context-menu in Windows Explorer) and my free VST plugins.
My Reaper tutorials and studio related videos on youtube.
SonicAxiom is offline   Reply With Quote
Old 03-19-2019, 04:57 PM   #22
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

What if you reverse selected events before and after the spk77 script?
FnA is offline   Reply With Quote
Old 03-19-2019, 05:15 PM   #23
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 3,012
Default

Quote:
Originally Posted by FnA View Post
What if you reverse selected events before and after the spk77 script?
so simple but genious! Cool hack, man, thanks!
I made a custom action for it

.
__________________
Check out AVConvert (free, super-fast media file manipulation via the right-click context-menu in Windows Explorer) and my free VST plugins.
My Reaper tutorials and studio related videos on youtube.
SonicAxiom is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.