Old 08-11-2017, 08:48 AM   #1
crackinkid
Human being with feelings
 
Join Date: Nov 2016
Posts: 79
Default Stretch Midi Notes Custom Action?

Hi guys,

I wanna create a shortcut to stretch selected midi notes 2x and 1/2 in the same way the mouse modifier (opt) streches notes. So the notes position is altered with the time stretch and not only the note length shortend or streched. I couldn't find any custom action or script for that :O
Any ideas on how to do that, would be greatly appreciated.
crackinkid is offline   Reply With Quote
Old 08-11-2017, 08:13 PM   #2
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

That seems complicated. Why can't you just use the mouse modifier?
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-12-2017, 05:38 AM   #3
crackinkid
Human being with feelings
 
Join Date: Nov 2016
Posts: 79
Default

yeah you're right i could ^^. but in terms of workflow it would be easier and faster for me to have a shortcut for that.
crackinkid is offline   Reply With Quote
Old 08-12-2017, 05:57 AM   #4
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Quote:
Originally Posted by foxAsteria View Post
That seems complicated.
Not really:
Code:
  x = 2
  
  for key in pairs(reaper) do _G[key]=reaper[key]  end
  function StretchSelectedNotes()
    local midieditor =  MIDIEditor_GetActive()
    if not midieditor then return end
    local take =  MIDIEditor_GetTake( midieditor )
    if not take or not TakeIsMIDI(take) then return end
    local t = {}
    local str = ""
    for i = 1, ({MIDI_CountEvts( take )  })[2] do
      t[#t+1] = ({reaper.MIDI_GetNote( take, i-1 ) })
      if i == 1 then strtppq = t[1][4] end
      reaper.MIDI_SetNote( take, i-1, t[i][2],--sel
                                        t[i][3],--mutedInOptional, 
                                        (t[i][4]-strtppq)*x+strtppq,--startppqposInOptional, 
                                        (t[i][4]-strtppq)*x+strtppq+(t[i][5]-t[i][4])*x,--endppqposInOptional, 
                                        t[i][6],--chanInOptional, 
                                        t[i][7],--pitchInOptional, 
                                        t[i][8],--velInOptional, 
                                        true)--noSortInOptional )
    end     
    reaper.MIDI_Sort( take )   
  end  
  StretchSelectedNotes()
mpl is offline   Reply With Quote
Old 08-12-2017, 06:08 AM   #5
Outboarder
Human being with feelings
 
Outboarder's Avatar
 
Join Date: Feb 2014
Posts: 834
Default

Nice code Michael
Thank you
__________________
Outboarder Scripts
Outboarder is offline   Reply With Quote
Old 08-12-2017, 06:24 AM   #6
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Quote:
Originally Posted by mpl View Post
Not really:
Code:
  x = 2
  
  for key in pairs(reaper) do _G[key]=reaper[key]  end
  function StretchSelectedNotes()
    local midieditor =  MIDIEditor_GetActive()
    if not midieditor then return end
    local take =  MIDIEditor_GetTake( midieditor )
    if not take or not TakeIsMIDI(take) then return end
    local t = {}
    local str = ""
    for i = 1, ({MIDI_CountEvts( take )  })[2] do
      t[#t+1] = ({reaper.MIDI_GetNote( take, i-1 ) })
      if i == 1 then strtppq = t[1][4] end
      reaper.MIDI_SetNote( take, i-1, t[i][2],--sel
                                        t[i][3],--mutedInOptional, 
                                        (t[i][4]-strtppq)*x+strtppq,--startppqposInOptional, 
                                        (t[i][4]-strtppq)*x+strtppq+(t[i][5]-t[i][4])*x,--endppqposInOptional, 
                                        t[i][6],--chanInOptional, 
                                        t[i][7],--pitchInOptional, 
                                        t[i][8],--velInOptional, 
                                        true)--noSortInOptional )
    end     
    reaper.MIDI_Sort( take )   
  end  
  StretchSelectedNotes()
Hi mpl, great !
Could you pls add this to ReaPack ?

Thx in advance!
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-12-2017, 07:31 AM   #7
Outboarder
Human being with feelings
 
Outboarder's Avatar
 
Join Date: Feb 2014
Posts: 834
Default

I tested the script , It stretches all notes not the selected ones.
__________________
Outboarder Scripts
Outboarder is offline   Reply With Quote
Old 08-12-2017, 08:55 AM   #8
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Аh yep, didn't test it. I will add to ReaPack some versions later (too much alcohol inside now.
mpl is offline   Reply With Quote
Old 08-12-2017, 11:57 AM   #9
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Quote:
Originally Posted by mpl View Post
Not really:
Code:
  x = 2...
 incomprehensible syntactical gobbeldegook
  ...
Lol, mpl, do you have any idea how complicated that shit looks to us common folk? You coders make me feel like a damned monkey who knows a little bit of sign language.
__________________
foxyyymusic
foxAsteria 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 04:32 PM.


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