Old 12-25-2017, 12:21 PM   #1561
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,836
Default

Without it, script will make "ReaScript: Run" undo point. Even when an action, like Xenakios/SWS: Select next tracks, does not make undo point.

Only partial solution, in this case.
FnA is offline   Reply With Quote
Old 12-25-2017, 02:04 PM   #1562
Archie
Human being with feelings
 
Join Date: Oct 2017
Posts: 15
Default

Quote:
Originally Posted by FnA View Post
Without it, script will make "ReaScript: Run" undo point. Even when an action, like Xenakios/SWS: Select next tracks, does not make undo point.

Only partial solution, in this case.
now he was happy, he understood everything.
Thank you very much for your help !!!
Archie is offline   Reply With Quote
Old 12-26-2017, 08:41 AM   #1563
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,836
Default

You're welcome. Maybe there is another way. I don't know.
FnA is offline   Reply With Quote
Old 01-05-2018, 12:18 PM   #1564
strachupl
Human being with feelings
 
strachupl's Avatar
 
Join Date: Jan 2013
Posts: 210
Default

Yes! t seems I searched wrong words in action list. Thank you for quick help vanhaze

Solved.
__________________
The truth is not in the middle but exactly where it is.

Last edited by strachupl; 01-05-2018 at 12:27 PM.
strachupl is offline   Reply With Quote
Old 01-05-2018, 12:21 PM   #1565
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 4,019
Default

??

"Item navigation: Move cursor to start of items"

Or am i misunderstanding you ?
vanhaze is online now   Reply With Quote
Old 01-12-2018, 07:46 PM   #1566
J Reverb
Human being with feelings
 
J Reverb's Avatar
 
Join Date: Jul 2009
Posts: 466
Default

Can someone please help to put this script into the correct form in Lua as I have no idea how and would like to study the code based on what I have cobbled together in a hideous frankenstein fashion, yup it's a car crash.

Really looking forward to seeing how this SHOULD be done properly in Lua

Many many thanks.

Code:
--Split item, snap right item to nearest grid division, set previous items end to same grid division
--Then extend the right items edge backwards over the left item applying a crossfade
-- 

local item=reaper.GetSelectedMediaItem(0, 0) -- get first selected item
local time_editcursor=reaper.GetCursorPosition() -- get time of edit cursor
local pos =  reaper.BR_GetClosestGridDivision(time_editcursor)
if item ~= nil then
reaper.SplitMediaItem(item, time_editcursor) -- split the item at the time where edit cursor is
reaper.SetMediaItemSelected(item, 0) -- leave next item selected by setting item selection to 0 
end
local item=reaper.GetSelectedMediaItem(0, 0)
if item ~= nil then
reaper.SetMediaItemSelected(item, 1)
reaper.SetMediaItemPosition( item, pos, 0 ) --snaps item to nearest grid point
end
reaper.UpdateArrange()

reaper.Main_OnCommand(40416,0) --selects previous item ??? go on you can do it !!!
reaper.Main_OnCommand(40416,0) --selects previous item ??? dont know why this has to be done twice ? help lol
reaper.Main_OnCommand(41639,0) --sets item length to start of next item the first split(right)
reaper.Main_OnCommand(40417,0) --selects next item first split(right)
reaper.Main_OnCommand(40225,0) --Item edit: Grow left edge of items x fade backwards into previous item x 10 needs to be a user definable number or use the last crossfade settings ideally no pop up box
__________________
I've been imitated so well I've heard people copy my mistakes. - Jimi Hendrix
J Reverb is offline   Reply With Quote
Old 01-13-2018, 01:32 AM   #1567
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,608
Default

Quote:
Originally Posted by J Reverb View Post
Can someone please help to put this script into the correct form in Lua
To get correct form you probably should say correct what you want to do.

Quote:
snap right item to nearest grid division
snap what? position, length? stretch to match grid? preserve looping?
Quote:
set previous items end to same grid division
same as what? since you have one grid per project. 'Set items end' means quantise item lengths to grid? extend or move or stretch? previous on timeline or on same track?
Quote:
extend the right items edge backwards over the left item applying a crossfade
items? they are right to each other
even if you do this with right-hand item you`ve got after split at edit cursor, you just get zero right item length. reverse? extend reversed item? preserve source start event(give offset to it)?
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 01-14-2018, 04:17 AM   #1568
J Reverb
Human being with feelings
 
J Reverb's Avatar
 
Join Date: Jul 2009
Posts: 466
Default

Hi mpl,

Yeah sorry for over complicating things.

It's basically SWS/AW: Split selected items at edit cursor w/crossfade on left
but the item start and previous items length snaps to the nearest grid division

Hope that makes sense ?

Thanks for your input btw.

J.
__________________
I've been imitated so well I've heard people copy my mistakes. - Jimi Hendrix
J Reverb is offline   Reply With Quote
Old 01-19-2018, 09:06 PM   #1569
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,836
Default

Maybe not so much over complicating things. More that additional questions will arise. Like: I didn't know what to do with multiple takes, so just did the same to all of them. I chose SnapToGrid because Breeder's function came out before swing grid, and doesn't work with it. It will use visible grid lines. The commented out lines are an effort to allow use of the grid line which is closest regardless of whether it is visible or not. So, no claim of completeness or infallibility, but something to check out...

Code:
-- jreverb split.lua

reaper.Undo_BeginBlock2(0)
fadelen = reaper.SNM_GetDoubleConfigVar("defsplitxfadelen", 0.01)--from prefs/Reaper.ini
curpos = reaper.GetCursorPosition()

--pgm = reaper.SNM_GetIntConfigVar("projgridmin", 666)--? save min pixels between grid lines.
--reaper.SNM_SetIntConfigVar("projgridmin", 0)--? use actual rather than visible grid, if applicable.
snap = reaper.GetToggleCommandState(1157, 0)-- snapping toggle action state
if snap == 0 then -- SnapToGrid doesn't work with snapping off
  reaper.Main_OnCommand(1157,0)
  grid = reaper.SnapToGrid(0, curpos)
  reaper.Main_OnCommand(1157,0)
else
  grid = reaper.SnapToGrid(0, curpos)
end
--reaper.SNM_SetIntConfigVar("projgridmin", pgm)--? restore min pixels between grid lines.

item = reaper.GetSelectedMediaItem(0,0)
if item then
  itempos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
  if itempos < (grid - fadelen) then
  
    newitem = reaper.SplitMediaItem(item, curpos)
    if newitem then
      reaper.SetMediaItemPosition(newitem, grid - fadelen, false)
      reaper.SetMediaItemLength(newitem, reaper.GetMediaItemInfo_Value(newitem, "D_LENGTH") + fadelen, false)
      
      function Fn_Do_Take(take)
        offset = reaper.GetMediaItemTakeInfo_Value(take, "D_STARTOFFS")
        rate = reaper.GetMediaItemTakeInfo_Value(take, "D_PLAYRATE")
        reaper.SetMediaItemTakeInfo_Value(take, "D_STARTOFFS", offset - (fadelen*rate))
      end
      ct = reaper.CountTakes(newitem)
      if ct > 0 then
        for i = 0, ct-1 do --? do all takes equally?
          Fn_Do_Take(reaper.GetMediaItemTake(newitem, i))
        end
      end
      reaper.SetMediaItemInfo_Value(newitem, "D_FADEINLEN_AUTO", fadelen)
      
      reaper.SetMediaItemLength(item, grid - itempos, false)
      reaper.SetMediaItemInfo_Value(item, "D_FADEOUTLEN_AUTO", fadelen)
    end
  end
end

reaper.UpdateArrange()
reaper.Undo_EndBlock2(0, "jreverb split", -1)

Last edited by FnA; 01-20-2018 at 05:36 PM.
FnA is offline   Reply With Quote
Old Yesterday, 05:38 AM   #1570
J Reverb
Human being with feelings
 
J Reverb's Avatar
 
Join Date: Jul 2009
Posts: 466
Default

Thanks FnA

This gives me a fair bit to chew on.
reaper.SNM_GetDoubleConfigVar("defsplitxfadelen", 0.01)
That's really nifty.
Also taking swing grid into account is something that would have
gone straight over my head
I really think it would be a great idea to have a sticky for scripting newbies with fully commented code basics such as how to loop through items etc. etc.
I know x-raym has made an amazing effort to do this amongst others.

Really appreciate the help and insight.

Thanks again,

J.
__________________
I've been imitated so well I've heard people copy my mistakes. - Jimi Hendrix
J Reverb is offline   Reply With Quote
Old Yesterday, 08:39 AM   #1571
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 1,836
Default

I hear you. But the best I can say is look for existing scripts that do something similar for an example. Or just ask about some specific detail.
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 05:27 PM.


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