|
|
|
06-17-2018, 12:29 PM
|
#1
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Need script to move cursor number of tics
I'm thinking this should be easy but not sure.
I'd like to be able to move the edit cursor left or right a certain number of ticks per quarter not. This could pertain to both the arrange and midi editor, but most important, the midi editor.
I looked in the ReaPack but couldn't find anything.
Any effort would be much appreciated.
|
|
|
06-17-2018, 01:01 PM
|
#2
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
It would be easy to write such a script, but if you prefer a native solution, you can use Nudge to move the edit cursor by tiny note lengths (minimum 1/256 notes, or 15 ticks, if using 960 PPQ) or milliseconds.
EDIT: Here is a little script that should work in the MIDI editor, and uses the active take's PPQ:
(The arrange view is a bit more difficult, since REAPER does not have a single, fixed PPQ per project.)
Code:
userOK, userNudge = reaper.GetUserInputs("Nudge edit cursor", 1, "Number of ticks:", "0")
if not userOK then return end
userNudge = tonumber(userNudge)
editor = reaper.MIDIEditor_GetActive()
take = reaper.MIDIEditor_GetTake(editor)
cursorTime = reaper.GetCursorPositionEx(0)
cursorTicks = math.floor(0.5 + reaper.MIDI_GetPPQPosFromProjTime(take, cursorTime))
newTime = reaper.MIDI_GetProjTimeFromPPQPos(take, cursorTicks+userNudge)
reaper.ApplyNudge(0, -- Project.
1, -- Set (not nudge) value.
6, -- Set what? Edit cursor.
1, -- Units? Seconds.
newTime,
false, -- Reverse?
0 -- Copies?
)
Last edited by juliansader; 06-17-2018 at 01:19 PM.
|
|
|
06-17-2018, 01:50 PM
|
#3
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Quote:
Originally Posted by juliansader
It would be easy to write such a script, but if you prefer a native solution, you can use Nudge to move the edit cursor by tiny note lengths (minimum 1/256 notes, or 15 ticks, if using 960 PPQ) or milliseconds.
EDIT: Here is a little script that should work in the MIDI editor, and uses the active take's PPQ:
(The arrange view is a bit more difficult, since REAPER does not have a single, fixed PPQ per project.)
|
Thanks for the script and quick response Julian, what I'm needing to do right now is move left 3 or 2 ticks.
I see ("Nudge edit cursor", 1, "Number of ticks:", "0"), I assume this is where I enter the number of ticks, and if so, what do the two numbers give me? By that I mean what does "Nudge edit cursor" stand for, I assume "Number of ticks:" is the number of ticks?
Also, do I use "-" (minus) ahead of the numbers to indicate left?
Also, what type of script is this lua, eel?
Last edited by Tod; 06-17-2018 at 01:59 PM.
|
|
|
06-17-2018, 02:35 PM
|
#4
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
You do not need to edit anything in the script itself. When you run the script, it will pop up a dialog box in which you can enter the number of ticks to move.
* Negative values will work fine.
* The script will snap the cursor to the nearest tick if you enter integer values. (I can change this, if you prefer.)
Would you prefer a script without a dialog box and with hard-coded nudge values?
It is a lua script, so you can save it with a .lua extension and any filename.
Last edited by juliansader; 06-17-2018 at 02:40 PM.
|
|
|
06-17-2018, 03:35 PM
|
#5
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Okay, got that, actually I would like to be able to put in the values without any pop up boxes. In other words edit the script to put in the values.
What I'm using this for is keyswitches. I have a steel guitar I created in Kontakt that uses keyswitches to determine what the pitch bend is going to be when the slide bar is moved up or down, as well as the knee and the pedals. There are 5 keyswitch notes going from C1 to E1 that determine what controller is used, from CC1 to CC4. One of the keyswitches (C1) is neutral. The velocity of the keyswitch determines the amount of pitch the note will swing between velocities 0 to 64.
What I'm using the script for is to move the cursor 3 ticks to the left of the start of steel note, where it will place a keyswitch from C0 to E1. It takes an offset of 2 to 3 ticks to tell Kontakt that it is a keyswitch, if the keyswitch is to close to the played note, it wont register.
Kind of hard to explain, hope that helps.
And thanks Julian for all your wonderful scripts.
|
|
|
06-17-2018, 03:50 PM
|
#6
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Just to let you know Julian, I'm headed out, going to one of my daughters, she's having a get together for us dads.
|
|
|
06-18-2018, 04:07 AM
|
#7
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Here are two versions of the script that don't pop up a dialog box:
The first is for the MIDI editor, and will adapt the PPQ to whatever take is active in the editor. To change the number of ticks, simply edit the "ticksToMove" number.
Code:
-- Nudge edit cursor by ticks.lua: MIDI editor version
ticksToMove = -3
-------------------------------------------
editor = reaper.MIDIEditor_GetActive()
take = reaper.MIDIEditor_GetTake(editor)
cursorTime = reaper.GetCursorPositionEx(0)
cursorTicks = reaper.MIDI_GetPPQPosFromProjTime(take, cursorTime)
newTime = reaper.MIDI_GetProjTimeFromPPQPos(take, cursorTicks+ticksToMove)
reaper.Undo_BeginBlock2(0)
reaper.ApplyNudge(0, -- Project.
1, -- Set (not nudge) value.
6, -- Set what? Edit cursor.
1, -- Units? Seconds.
newTime,
false, -- Reverse?
0 -- Copies?
)
reaper.Undo_EndBlock2(0, "Nudge edit cursor", -1)
The second is for the arrange view (but also works in the MIDI editor), and will use the default PPQ as set in Preferences. It requires the SWS extension.
Code:
-- Nudge edit cursor by ticks.lua: Arrange version
ticksToMove = -3
------------------------------------------------------------
PPQ = reaper.SNM_GetIntConfigVar("miditicksperbeat", 960)
cursorTime = reaper.GetCursorPositionEx(0)
cursorQN = reaper.TimeMap_timeToQN_abs(0, cursorTime)
newQN = cursorQN + (ticksToMove/PPQ)
newTime = reaper.TimeMap_QNToTime_abs(0, newQN)
reaper.Undo_BeginBlock2(0)
reaper.ApplyNudge(0, -- Project.
1, -- Set (not nudge) value.
6, -- Set what? Edit cursor.
1, -- Units? Seconds.
newTime,
false, -- Reverse?
0 -- Copies?
)
reaper.Undo_EndBlock2(0, "Nudge edit cursor", -1)
|
|
|
06-18-2018, 08:46 AM
|
#8
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Thanks much Julian, I got them loaded and they work great.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:11 PM.
|