Old 08-11-2017, 08:48 AM   #1
crackinkid
Human being with feelings
 
Join Date: Nov 2016
Posts: 21
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: Axis Mundi
Posts: 4,112
Default

That seems complicated. Why can't you just use the mouse modifier?
__________________
TwilightMysterySchool
foxAsteria is online now   Reply With Quote
Old 08-12-2017, 05:38 AM   #3
crackinkid
Human being with feelings
 
Join Date: Nov 2016
Posts: 21
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: 1,564
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()
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
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: 636
Default

Nice code Michael
Thank you
__________________
Hope Sacred Passion Life Night Ache Soft Light
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: 3,846
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!
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: 636
Default

I tested the script , It stretches all notes not the selected ones.
__________________
Hope Sacred Passion Life Night Ache Soft Light
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: 1,564
Default

Аh yep, didn't test it. I will add to ReaPack some versions later (too much alcohol inside now.
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 08-12-2017, 11:52 AM   #9
crackinkid
Human being with feelings
 
Join Date: Nov 2016
Posts: 21
Default

ooh, thats sweet

thnx mpl!
crackinkid is offline   Reply With Quote
Old 08-12-2017, 11:56 AM   #10
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 3,846
Default

Quote:
Originally Posted by mpl View Post
Аh yep, didn't test it. I will add to ReaPack some versions later (too much alcohol inside now.
LOL, enjoy and thank you mpl !
vanhaze is offline   Reply With Quote
Old 08-12-2017, 11:57 AM   #11
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Axis Mundi
Posts: 4,112
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.
__________________
TwilightMysterySchool
foxAsteria is online now   Reply With Quote
Old 08-12-2017, 05:26 PM   #12
Outboarder
Human being with feelings
 
Outboarder's Avatar
 
Join Date: Feb 2014
Posts: 636
Default

Quote:
Originally Posted by mpl View Post
Аh yep, didn't test it. I will add to ReaPack some versions later (too much alcohol inside now.
Alcohol and coding is a no no!
have a good time
__________________
Hope Sacred Passion Life Night Ache Soft Light
Outboarder is offline   Reply With Quote
Old 08-13-2017, 12:22 AM   #13
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,564
Default

ReaPack/MIDI editor/mpl_Stretch selected MIDI notes positions by x0.5
ReaPack/MIDI editor/mpl_Stretch selected MIDI notes positions by x2
ReaPack/MIDI editor/mpl_Stretch selected MIDI notes positions by custom x

Custom x can be like:
  • "2" means "y = x*2"
  • "*2" means "y = x*2"
  • "/3" means "y = x/3"
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 08-13-2017, 12:35 AM   #14
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 3,846
Default

Works great, thanks very much mpl !
vanhaze is offline   Reply With Quote
Old 08-13-2017, 06:06 AM   #15
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 363
Default

These will be useful, spasibo MPL.
NextLevel is offline   Reply With Quote
Old 08-14-2017, 06:53 AM   #16
Michael AD
Human being with feelings
 
Michael AD's Avatar
 
Join Date: Jul 2017
Location: Hackensack
Posts: 37
Default

Another easy solution is to make a button for the Midi Editor using the "Edit: Event Properties" action.
(Which you can also access with the default Ctrl+F2 keystroke.)
Michael AD 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 12:50 AM.


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