Go Back   Cockos Incorporated Forums > REAPER Forums > JSFX and ReaScript Discussion

Reply
 
Thread Tools Display Modes
Old 07-28-2014, 04:03 PM   #1
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default Join only adjacent/overlapping notes (help! I don't know what am I doing!)

Hello!

The join action in the MIDI piano roll editor, joins notes of the same pitch no matter how far they are. So, if one has many same pitch split notes, he/she cannot select them all and join them, because notes of the same pitch will get joined even if they are 4 bars apart! So, one must manually select small groups of notes and join them one by one.

I request a script that will join selected notes, ONLY if they are adjacent (the end position of the first one is the same as the start position of the second one) or if they are overlapping!

This script, along with a custom action will be a very good workaround for the problem expressed in this thread

-------
Edit:

I tried to make it myself by modifying the script that spk77 made for restricting polyphony.

I haven't got any idea on programming, but I thought that by looking at the script code, maybe I could understand what is going on and modify it.

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

function join_adjacent_notes() 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(), 40456); // run (MIDI editor) action "Join 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("Join adjacent/overlapping notes only", -1);
  );
);

join_adjacent_notes()
Well.. It did not work! If programming was so simple, then everybody would be a programmer! So.. could somebody make the script for me? spk77? :blush

And if not too difficult, could you explain me why this modification did not work? Furthermore, what should I read in order to learn program in eel? I am total newbie (in programming)...

Last edited by amagalma; 08-01-2014 at 02:14 AM.
amagalma is online now   Reply With Quote
Old 08-01-2014, 02:12 AM   #2
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Oh.. I got why it did not work! Because it compares the start and end of ANY notes while it should compare the start and end of notes of the same pitch only!
amagalma is online now   Reply With Quote
Old 08-10-2014, 05:12 PM   #3
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Code:
// Join adjacent and overlapping notes only (modification of script: Restrict polyphony - EEL script by spk77 10.7.2014)

function join_adjacent_notes() local(index, take, note_cnt, is_selected, is_muted, start_pos, end_pos, chan, pitch, vel, start_pos_next, pitch_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, pitch_next, 0);
      pitch = pitch_next ? end_pos >= start_pos_next ? MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40456); // run (MIDI editor) action "Join notes"
    );
    Undo_EndBlock("Join adjacent/overlapping notes only", -1);
  );
);

join_adjacent_notes()
Could somebody explain me why this still does not work?

Last edited by amagalma; 08-11-2014 at 02:23 AM.
amagalma is online now   Reply With Quote
Old 08-13-2014, 11:37 AM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Quote:
Originally Posted by amagalma View Post
Could somebody explain me why this still does not work?
This is the same thing as manually running the action "Join notes":
Code:
MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40456); // run (MIDI editor) action "Join notes"
So, it always joins "non-adjacent" notes also.


I've been trying to make a script for "Joining only adjacent/overlapping notes", but it seems to be very difficult to do (haven't got it working ).

The most difficult thing is that note indexes are changing, because some of the notes have to be deleted. And that thing happens in a loop -> wrong notes get deleted, wrong notes get resized etc.


pseudo code:
Code:
Get first selected note
loop through rest of notes
    if current note pitch == first selected note pitch && first selected note end >= start of current note
        set first selected note end to current note end
        delete current note

Get second selected note
loop through rest of notes
    if current note pitch == second selected note pitch && second selected note end >= start of current note
        set second selected note end to current note end
        delete current note

Get third selected note
loop through rest of notes
    if current note pitch == third selected note pitch && third selected note end >= start of current note
        set third selected note end to current note end
        delete current note

Get fourth selected note
.
.
.
etc.

Last edited by spk77; 08-13-2014 at 11:45 AM.
spk77 is offline   Reply With Quote
Old 08-13-2014, 11:32 PM   #5
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Thank you so much spk77 for your help! :-)

I was thinking the same thing last night! Pity that it doesn't work!

What if each note that needs to be deleted, instead of directly getting deleted, gets appended in an empty initially list? Then, after the loop has finished processing (leaving lots of overlapping notes), we delete all notes that are in that list.

Notestodelete[ ]
Notestodelete.append(current note) // (instead of delete current note)
Then delete all notes in the Notestodelete[] list

Last edited by amagalma; 08-13-2014 at 11:46 PM.
amagalma is online now   Reply With Quote
Old 08-14-2014, 01:59 AM   #6
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Quote:
Originally Posted by amagalma View Post
Thank you so much spk77 for your help! :-)

I was thinking the same thing last night! Pity that it doesn't work!

What if each note that needs to be deleted, instead of directly getting deleted, gets appended in an empty initially list? Then, after the loop has finished processing (leaving lots of overlapping notes), we delete all notes that are in that list.

Notestodelete[ ]
Notestodelete.append(current note) // (instead of delete current note)
Then delete all notes in the Notestodelete[] list
Something like that might work - have to test when I get back to home.
spk77 is offline   Reply With Quote
Old 08-15-2014, 02:51 AM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

I think it's working now (needs testing):




(added "chan == chan_next" to join only on the same channel)

Code:
// Join adjacent and overlapping notes by spk77 15.8.2014)

function join_adjacent_and_overlapping_notes()
(
  (take = MIDIEditor_GetTake(MIDIEditor_GetActive())) ? (
    //UpdateItemInProject(GetMediaItemTake_Item(take));
    Undo_BeginBlock();
    //MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40659); // Correct overlapping notes
    index = -1;
    while((index = MIDI_EnumSelNotes(take, index)) != -1) (
      MIDI_GetNote(take, index, is_selected, is_muted, start_pos, end_pos, chan, pitch, vol);
      index_inner = index;
      while((index_inner = MIDI_EnumSelNotes(take, index_inner)) != -1) (
        MIDI_GetNote(take, index_inner, 0, 0, start_pos_next, end_pos_next, chan_next, pitch_next, 0);
        chan == chan_next && pitch == pitch_next && end_pos >= start_pos_next  ? (
          MIDI_SetNote(take, index, is_selected, is_muted, start_pos, end_pos_next, chan, pitch, vol);
          index = -1;
          MIDI_DeleteNote(take, index_inner);
        );
      );
    );
    Undo_EndBlock("Join adjacent and overlapping notes", -1);
    //Undo_OnStateChange("Join adjacent and overlapping notes");
  );
);

join_adjacent_and_overlapping_notes();

Last edited by spk77; 08-15-2014 at 08:01 AM. Reason: commented out: MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40659); // Correct overlapping notes
spk77 is offline   Reply With Quote
Old 08-15-2014, 03:20 AM   #8
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Wow! You did it again!! Thank you so much spk77!!!

I just tested it and it works great!

It is a VERY useful action to me!
amagalma is online now   Reply With Quote
Old 08-15-2014, 03:36 AM   #9
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Quote:
Originally Posted by amagalma View Post
Wow! You did it again!! Thank you so much spk77!!!

I just tested it and it works great!

It is a VERY useful action to me!
I'm happy that it worked for you! There's a possible bug in Reaper's MIDI editor (related to updating/refreshing note lengths after drawing). If you see notes getting f.ex wrong lengths after running the script, try to: unselect all notes -> select all notes -> run the script again.
spk77 is offline   Reply With Quote
Old 08-15-2014, 04:43 AM   #10
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Without undoing?
amagalma is online now   Reply With Quote
Old 08-15-2014, 06:25 AM   #11
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Quote:
Originally Posted by amagalma View Post
Without undoing?
Yes, I think.
spk77 is offline   Reply With Quote
Old 08-15-2014, 07:06 AM   #12
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,319
Default

Nice job spk77..., I did however find two little bugs.

In this first LICEcap two notes overlap with only one selected and when the script is executed the note that is not selected is getting cropped.



In this cap both notes are selected however when undoing.., the second note is getting cropped.., if I undo a second time the notes return to their correct lengths.

Anton9 is offline   Reply With Quote
Old 08-15-2014, 08:00 AM   #13
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Quote:
Originally Posted by Anton9 View Post
Nice job spk77..., I did however find two little bugs.

In this first LICEcap two notes overlap with only one selected and when the script is executed the note that is not selected is getting cropped.
It happens because "Correct overlapping notes" action is executed:

(this line)
Code:
MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40659); // Correct overlapping notes
I think it's not necessary - the line can be removed from the script.



Quote:
Originally Posted by Anton9 View Post
In this cap both notes are selected however when undoing.., the second note is getting cropped.., if I undo a second time the notes return to their correct lengths.
This is also happening with "Join notes" - (native) action when undoing. I don't know why (undo state related bug?):


Last edited by spk77; 08-15-2014 at 08:07 AM.
spk77 is offline   Reply With Quote
Old 08-15-2014, 08:15 AM   #14
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,319
Default

I deleted that line and it works fine now.., I'll go ahead and file a bug report about that second issue. Thanks!
Anton9 is offline   Reply With Quote
Old 08-15-2014, 08:16 AM   #15
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

Here's the note resizing bug - it seems it's a bug in Reaper:
(It works when I unselect notes -> select notes -> run the script again):

(from 12s -> unselecting and selecting the notes)
spk77 is offline   Reply With Quote
Old 08-15-2014, 08:25 AM   #16
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,319
Default

Yeah that resizing bug sucks.., it rears it's ugly head all the time when rendering plugins that affect MIDI such as arps. I've mentioned it a few times to the devs.., don't know why it has'nt been fixed or why more people have'nt noticed and complained about.

Last edited by Anton9; 08-15-2014 at 08:47 AM.
Anton9 is offline   Reply With Quote
Old 08-15-2014, 08:55 AM   #17
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,076
Default

Quote:
Originally Posted by spk77 View Post
This is also happening with "Join notes" - (native) action when undoing. I don't know why (undo state related bug?):


Quote:
Originally Posted by Anton9 View Post
Yeah that resizing bug sucks.., it rears it's ugly head all the time when rendering plugins that affect MIDI such as arps. I've mentioned it a few times to the devs.., don't know why it has'nt been fixed or why more people have'nt noticed and complained about.
I have noticed it many times too. But I have not found under what circumstances it can be reproduced (it is not always reproducible), so I have not posted a bug into the issue tracker. If you do, I'll go and confirm it
amagalma is online now   Reply With Quote
Old 03-03-2015, 11:51 AM   #18
Jason Brian Merrill
Human being with feelings
 
Jason Brian Merrill's Avatar
 
Join Date: Jun 2006
Location: Northeastern PA, USA
Posts: 20,416
Default

yeah, I cannot use this script... it makes everything super long...
__________________
Beliefs do not require respect. People do.
Jason Brian Merrill is online now   Reply With Quote
Old 12-03-2015, 08:49 PM   #19
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

Doesn't work for me either. Behaves unpredictably:

It's a shame, I need this functionality badly, since split MIDI items usually end up with tiny unwanted notes. Should be a native action. Is it impossible?
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-18-2016, 09:25 PM   #20
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

Here's a stab at an alternative. It's not compatible with overlapping notes either --It will make them extend endlessly--, so you should use "Correct Overlapping Notes" action first. Unfortunately that's active item only action. Maybe spk77s script has a related issue. Maybe it's just a bad situation.

You enter how many ticks you want to allow between the notes before ignoring them for joining. Hitting ENTER (blank field) will use 0 (adjacent).

You can use note on by entering 0 before the number. Use for example 0480 to join eighth notes or less with 960 tpqn. This seems to have more issues than using the end, even though it uses the same method. I don't know, this stuff is fussy. Not claiming "good code" or originality...

Maybe it can work as a bandaid until something better comes along. Just keep your eyes open while using it.

Code:
-- join notes with limited spacing.lua

function Fn_Set_Table()
  local t = {}
  local a = 0
  repeat
    a = a+1
    t[a] = {}
    local b = 0
    repeat
      b = b+1
      t[a][b] = {}
    until b >= 128
  until a >= 16
  return t
end

function Fn_Idx_Table(tk)
  local t_n = {}
  local a = -1
  local b = 1
  repeat
    a = reaper.MIDI_EnumSelNotes(tk, a)
    if a>-1 then t_n[b] = a end
    b = b+1
  until a < 0
  return t_n
end

function Fn_Notes_From_Big_Table(t)
  for i=1, 16 do
    for j=1, 128 do
      if #t[i][j] > 0 then
        local len = #t[i][j]
        for k=1, len/7 do
          reaper.MIDI_InsertNote(take, t[i][j][len-6],t[i][j][len-5],t[i][j][len-4],t[i][j][len-3],t[i][j][len-2],t[i][j][len-1],t[i][j][len], 1)
          len = len-7
        end
      end
    end
  end
end

function Fn_Table_Insert(a,b,c,d,e,f,g,t)
  table.insert(t, a)
  table.insert(t, b)
  table.insert(t, c)
  table.insert(t, d)
  table.insert(t, e)
  table.insert(t, f)
  table.insert(t, g)
end

function Fn_Join_Notes(take)
  local t = Fn_Set_Table()
  local t_idx = Fn_Idx_Table(take)
  local a = #t_idx
  while a > 0 do
    local idx = t_idx[a]
    local retval, sel, muted, startpos, endpos, chan, pitch, vel = reaper.MIDI_GetNote(take, idx)
    local c,p = chan+1, pitch+1
    local len_CP = #t[c][p]
    if len_CP == 0 then
      Fn_Table_Insert(sel, muted, startpos, endpos, chan, pitch, vel, t[c][p])
    else
      local y = 0; if on then y = startpos else y = endpos end
      if y + x >= t[c][p][len_CP-4] then
        t[c][p][len_CP-4] = startpos
      else
        Fn_Table_Insert(sel, muted, startpos, endpos, chan, pitch, vel, t[c][p])
      end
    end
    reaper.MIDI_DeleteNote(take, idx)
    a = a-1
  end 
  reaper.MIDI_Sort(take)
  Fn_Notes_From_Big_Table(t)
  reaper.MIDI_Sort(take)
end

----------------------------------------------------------

gui, s = reaper.GetUserInputs("Max Space (0xxx = Use Start)", 1, "Ticks: (Blank = 0)", "")
if gui == true then
  s_len = #s
  if string.find(s,"0",1, true) == 1 and s_len>1 then
    on = true; s = string.sub(s, 2, s_len); 
  elseif s == "" then s = "0" end
  x = tonumber(s)
  if x then
    mega = reaper.MIDIEditor_GetActive()
    if mega then take = reaper.MIDIEditor_GetTake(mega) end
    if take then
      reaper.Undo_BeginBlock2(0)
      Fn_Join_Notes(take)
      reaper.Undo_EndBlock2(0, "Join MIDI notes", -1)
    end
  end
end

Last edited by FnA; 03-20-2016 at 09:12 PM. Reason: better?
FnA is offline   Reply With Quote
Old 03-18-2016, 10:48 PM   #21
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

Thanks for that, FnA. I'll try it out. I went ahead and made an FR though. This process should not be nearly so grueling.

http://forum.cockos.com/showthread.p...65#post1655965
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-20-2016, 02:42 PM   #22
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

Changed it a little.

woops, didn't copy/paste the whole thing, got it now.

Last edited by FnA; 03-20-2016 at 02:54 PM.
FnA is offline   Reply With Quote
Old 03-20-2016, 07:10 PM   #23
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

Yea, FnA, as long as I don't have overlapping notes, it works great! I can't really think of a situation where I've needed overlapping notes, so I'll just keep that option on.

How hard would it be to have a version which just assumes 0 ticks instead of asking? I don't see myself ever needing to enter a different value.

Thanks, dude.
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-20-2016, 08:04 PM   #24
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

edit. If linked here in single post please see entire thread:
https://forum.cockos.com/showthread.php?t=143366
to get a better understanding of difficulties encountered with overlapping notes when running ReaScripts.

--------------------------------------------------------------

This should do that. The max_join_space variable near the top sets it to whatever.

Feel a little dirty following spk77 in here. No one has helped me more learning scripting (both directly and indirectly), and I use more of his scripts than of anyone elses. But he is a busy guy, I guess.

I found that it mattered what order to put the new notes into the item (take) but am not sure I have it all good now. It might be possible to put error handling in to cover the overlapping note, or maybe just cut those which are affected by selected notes to be joined, but I don't think they can survive having a new note put on top of them. Could be wrong. It's good enough for me personally now I think.

Code:
-- join notes with maximum spacing - adjustable.lua

max_join_space = 0 -- Edit this if you like. Distance is in ticks.

function Fn_Set_Table()
  local t = {}
  local a = 0
  repeat
    a = a+1
    t[a] = {}
    local b = 0
    repeat
      b = b+1
      t[a][b] = {}
    until b >= 128
  until a >= 16
  return t
end

function Fn_Idx_Table(tk)
  local t_n = {}
  local a = -1
  local b = 1
  repeat
    a = reaper.MIDI_EnumSelNotes(tk, a)
    if a>-1 then t_n[b] = a end
    b = b+1
  until a < 0
  return t_n
end

function Fn_Notes_From_Big_Table(t)
  for i=1, 16 do
    for j=1, 128 do
      if #t[i][j] > 0 then
        local len = #t[i][j]
        for k=1, len/7 do
          reaper.MIDI_InsertNote(take, t[i][j][len-6],t[i][j][len-5],t[i][j][len-4],t[i][j][len-3],t[i][j][len-2],t[i][j][len-1],t[i][j][len], 1)
          len = len-7
        end
      end
    end
  end
end

function Fn_Table_Insert(a,b,c,d,e,f,g,t)
  table.insert(t, a)
  table.insert(t, b)
  table.insert(t, c)
  table.insert(t, d)
  table.insert(t, e)
  table.insert(t, f)
  table.insert(t, g)
end

function Fn_Join_Notes(take)
  local t = Fn_Set_Table()
  local t_idx = Fn_Idx_Table(take)
  local a = #t_idx
  while a > 0 do
    local idx = t_idx[a]
    local retval, sel, muted, startpos, endpos, chan, pitch, vel = reaper.MIDI_GetNote(take, idx)
    local c,p = chan+1, pitch+1
    local len_CP = #t[c][p]
    if len_CP == 0 then
      Fn_Table_Insert(sel, muted, startpos, endpos, chan, pitch, vel, t[c][p])
    else
      if endpos + max_join_space >= t[c][p][len_CP-4] then
        t[c][p][len_CP-4] = startpos
      else
        Fn_Table_Insert(sel, muted, startpos, endpos, chan, pitch, vel, t[c][p])
      end
    end
    reaper.MIDI_DeleteNote(take, idx)
    a = a-1
  end 
  reaper.MIDI_Sort(take)
  Fn_Notes_From_Big_Table(t)
  reaper.MIDI_Sort(take)
end

----------------------------------------------------------

mega = reaper.MIDIEditor_GetActive()
if mega then take = reaper.MIDIEditor_GetTake(mega) end
if take then
  reaper.Undo_BeginBlock2(0)
  Fn_Join_Notes(take)
  reaper.Undo_EndBlock2(0, "Join MIDI notes", -1)
end

Last edited by FnA; 12-08-2017 at 09:10 PM.
FnA is offline   Reply With Quote
Old 03-20-2016, 08:42 PM   #25
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

You rock! I'm sure spk77 would be proud of you. After all, his script wasn't working and he doesn't seem to be following this thread.

If we could get round the problem of needing the ME open and the overlapping notes bit, maybe we wouldn't need a native action after all...

I really wish I could get into scripting myself. I keep trying, but I just feel out of my depth every time I try to wrap my head around it. You say this script is simple, but to me it looks incomprehensibly complex. I needed lots of help with the most basic stuff I was attempting. Started doing an online programming course, but quickly got lost.

Thanks again.
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-20-2016, 08:57 PM   #26
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

The MIDI editor is not necessary. Those two scripts are designed for selected notes, therefore it's likely they will be of use in MIDI editor action list. I just realized that the script would produce an error if no editor was open, I will edit it, but yeah those are for the ME basically.

Was not TOO easy. Had to try a few things. Don't have a handle on what is expected here. Well, things are tricky even with native actions, as you know.

What parameters do you think might be desired otherwise?
FnA is offline   Reply With Quote
Old 03-20-2016, 09:14 PM   #27
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

I don't know about anyone else, but I would personally use the script in 2 cases:
1. In the MIDI Editor, on selected notes.
2. In the Arrange, while gluing items. I tried to add your script to my glue action, but of course it doesn't do anything. But I think a lot of people don't like the way splitting items also splits notes and this is a decent workaround, to just glue items and join join at the same time.

So yea, if there's a way to use it in the Arrange on all notes inside the selected items without breaking it in the ME, that would be pretty ideal for me.
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-20-2016, 09:43 PM   #28
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

Be busy for a few days. Post more if you think of it. Helps preventing useless work.

-All adjacent notes should be not much different. Could slow down in big item I guess.
-Only notes at time position of split or item start/end seems possible. Maybe other specific times.

*Script is working by deleting selected notes and reinserting different ones.

Last edited by FnA; 03-20-2016 at 09:52 PM. Reason: *
FnA is offline   Reply With Quote
Old 03-20-2016, 10:02 PM   #29
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

FnA don't worry about it too much if you don't feel like it. It's really not a big deal for me to just double click the item and run another action after. You've already helped a lot.
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 03-21-2016, 08:41 AM   #30
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

OK! Good. I think I would have a hard time making something satisfying. There would be a lot of information to loop through if many/big items were involved. Job for a pro, I say. Better amateur maybe.
FnA is offline   Reply With Quote
Old 07-07-2016, 02:46 AM   #31
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,337
Default

Quote:
Originally Posted by foxAsteria View Post
Yea, FnA, as long as I don't have overlapping notes, it works great! I can't really think of a situation where I've needed overlapping notes, so I'll just keep that option on.
Regarding overlapping notes: I have tried to write a "Join notes" script that would work with overlapping as well as adjacent notes, but I ran into several ReaScript API bugs:

ReaScript: MIDI_GetNote returns endppqpos different from visual appearance in editor

Using MIDI_SetNote with noSort=true to move notes onto same pitch causes extended notes

ReaScript: MIDI_DeleteNote ADDS note to another pitch

The first bug can be circumvented by working with the raw MIDI note-on and note-off events instead of note lengths, but the other two wreak havoc.

At present, ReaScript is unfortunately not compatible with overlapping notes.
juliansader is offline   Reply With Quote
Old 07-07-2016, 01:12 PM   #32
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,111
Default

@juliansader You should report it on the bug forum as well if you think it's a bug. Maybe it can be fixed.
__________________
TwilightMysterySchool
foxAsteria is offline   Reply With Quote
Old 07-07-2016, 10:46 PM   #33
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,337
Default

Quote:
Originally Posted by foxAsteria View Post
@juliansader You should report it on the bug forum as well if you think it's a bug. Maybe it can be fixed.
Already done! The three links that I gave above are the links to my bug reports.
juliansader is offline   Reply With Quote
Old 07-21-2016, 01:35 AM   #34
crocobit
Human being with feelings
 
Join Date: Feb 2012
Posts: 12
Default

The two scripts (spk77 and FnA) are not working.

Are they incompatible with newer versions of Reaper.

These scripts would be a nice addition to ReaPacks.

Love your scripts.

Thanks all
crocobit is offline   Reply With Quote
Old 07-21-2016, 05:36 AM   #35
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,337
Default

Quote:
Originally Posted by crocobit View Post
The two scripts (spk77 and FnA) are not working.
Could you give some more details about the problem?

FnA's script should work in most circumstances, but as I mentioned above, unless those ReaScript bugs are fixed, the scripts are doomed to fail every now and then - particularly if there are overlapping notes somewhere in the take.
juliansader is offline   Reply With Quote
Old 07-21-2016, 02:06 PM   #36
crocobit
Human being with feelings
 
Join Date: Feb 2012
Posts: 12
Default

All right.
Is working now.

Thank you juliansader

I like very much your LFO tool
crocobit is offline   Reply With Quote
Old 12-07-2017, 09:33 AM   #37
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,309
Default

+1 for this in Reapack !

@FnA
Do you still plan to create a reapack repo ?
X-Raym is offline   Reply With Quote
Old 12-07-2017, 05:40 PM   #38
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

Will you help? Again?

It was maybe on the list, but not at the top of the pile. I don't know how much different it would be than contributing to ReaTeam, which took more time to figure out than I want to admit to.

Mixed feelings about this script. From an impartial view, I think it probably should be in ReaTeam, because the behavior is obviously useful, probably more so than the native Join action's. But it could be improved, most likely, with the SetAllEvents function, which is pretty much superior in every MIDI script, but especially in note scripts. I have not learned how to do that yet. I get the concept, but the specific syntax and other details would require a lot of trial and error to figure out. I'm sure I could do it, but might never get out what I put in. If only there was a guide.

Also, I didn't bring this concept to the forum table. Amagalma has progressed to know more about scripts than me at this point. I didn't bring the first solution either. spk77 did. His script worked when it first came out, but then something went bad with Reaper updates I guess.

MIDI note scripts seem especially difficult, not really because the concept is hard to grasp, it just is hard to keep things from getting chopped up. Even the MIDI editor itself, and maybe some arrange procedures, are hard to deal with concerning overlapping notes. It seems that complaints are inevitable. Things can be useful even if not perfect, but it can turn into a lot of work. I can't take it further at this point. I'm not sure if even SetAllEvents can handle every overlapping note situation.
FnA is offline   Reply With Quote
Old 12-08-2017, 05:02 AM   #39
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,309
Default

@FnA
Well, I make few tests and your scripts seems to work in most situation, I didn't obvious bugs As you said, it is better to have a script that work in 99% of the times than no script at all. I'm sure there is way to overcome the possible bugs, by using SWS MIDI functions, or by first deleting all selected notes and then reinsert only those who are necessary, or by using the SetAllEvents function... There is things to try. But for now, we can assume that your version of this action can help people as it is !
We could still writte new versions later if needed :P

Do you want me to put the script in ReaTeam pack for you ?
X-Raym is offline   Reply With Quote
Old 12-08-2017, 04:44 PM   #40
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,762
Default

I guess I can do it. Thanks for the offer.

Is it possible to get whatever take an Inline MIDI Editor action was run from? Or "last focused" Inline Editor take?
FnA 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:18 PM.


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