Old 11-08-2018, 11:17 AM   #1
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 88
Default Ruler that follow mouse

I need a ruler that follow the mouse, for split/cut item edits.
Is this possible to script, or theme?
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 11-11-2018, 01:56 PM   #2
ThomasE
Human being with feelings
 
Join Date: Aug 2009
Location: Sweden
Posts: 38
Default

This Lua script makes the edit cursor follow the mouse. Could that work? Select "Terminate instance" when you run the script again to be able to toggle on/off.

Code:
function main()
  reaper.BR_GetMouseCursorContext()
  local pos = reaper.BR_GetMouseCursorContext_Position()
  if pos > -1 then
    reaper.SetEditCurPos2(0, pos, false, false)
  end
  reaper.defer(main)
end

function exit()
  local is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
  reaper.SetToggleCommandState(sectionID, cmdID, 0)
  reaper.RefreshToolbar2(sectionID, cmdID)
end

local is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
reaper.SetToggleCommandState(sectionID, cmdID, 1)
reaper.RefreshToolbar2(sectionID, cmdID)

reaper.atexit(exit) 

main()
ThomasE is offline   Reply With Quote
Old 11-12-2018, 01:19 PM   #3
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 88
Default

Quote:
Originally Posted by ThomasE View Post
This Lua script makes the edit cursor follow the mouse. Could that work? Select "Terminate instance" when you run the script again to be able to toggle on/off.

Code:
function main()
  reaper.BR_GetMouseCursorContext()
  local pos = reaper.BR_GetMouseCursorContext_Position()
  if pos > -1 then
    reaper.SetEditCurPos2(0, pos, false, false)
  end
  reaper.defer(main)
end

function exit()
  local is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
  reaper.SetToggleCommandState(sectionID, cmdID, 0)
  reaper.RefreshToolbar2(sectionID, cmdID)
end

local is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
reaper.SetToggleCommandState(sectionID, cmdID, 1)
reaper.RefreshToolbar2(sectionID, cmdID)

reaper.atexit(exit) 

main()
Thank you Thomas! Brilliant! Works like a charm, closest thing to editing in Samp.
ToggleArm next action, split item, followed with this script is exactly what i needed.
Tack igen!
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 11-12-2018, 02:40 PM   #4
ThomasE
Human being with feelings
 
Join Date: Aug 2009
Location: Sweden
Posts: 38
Default

Quote:
Originally Posted by Jonas Ekstrom View Post
Thank you Thomas! Brilliant! Works like a charm, closest thing to editing in Samp.
ToggleArm next action, split item, followed with this script is exactly what i needed.
Tack igen!
Strålande!
ThomasE is offline   Reply With Quote
Old 11-13-2018, 12:08 AM   #5
Sumalc
Human being with feelings
 
Join Date: Oct 2009
Location: France
Posts: 497
Default

very cool, thank you Thomas.
Sumalc is offline   Reply With Quote
Old 11-14-2018, 06:29 AM   #6
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,215
Default

if you want to just split item at mouse cursor, there's an action for this (40746)

Or, you place the action "split item" in a toolbar and you're right clicking the icon to "load" the action into mouse click
Reno.thestraws is offline   Reply With Quote
Old 11-14-2018, 08:36 AM   #7
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: USA
Posts: 768
Default

Quote:
Originally Posted by Reno.thestraws View Post
Or, you place the action "split item" in a toolbar and you're right clicking the icon to "load" the action into mouse click
You can do that from custom action using Arm action, something like,

Action: Arm next action
Item: Split item under mouse cursor
...
Edgemeal is offline   Reply With Quote
Old 11-14-2018, 10:00 AM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 452
Default

Thanks ThomasE... this is going right into my toolbox!

Cheers!
__________________
Cheers,
Andrew K
Reaper 5.95/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is offline   Reply With Quote
Old 11-14-2018, 10:46 AM   #9
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

I think the point of his request is to see where is the cut going to be (like cubase where there is a line following cursor). I think I could make something like that but does not move edit cursor around but have a line that follows mouse cursor all the time (again cubase/studio one like) so you can use split item at mouse cursor with it.I've had this idea script before but if its defered updating edit cursor position all the time hits cpu hard
Sexan is offline   Reply With Quote
Old 11-14-2018, 03:34 PM   #10
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 452
Default

Quote:
Originally Posted by Sexan View Post
I think the point of his request is to see where is the cut going to be (like cubase where there is a line following cursor). I think I could make something like that but does not move edit cursor around but have a line that follows mouse cursor all the time (again cubase/studio one like) so you can use split item at mouse cursor with it.I've had this idea script before but if its defered updating edit cursor position all the time hits cpu hard
Yeah... I think having a Reaper option of Crosshairs instead of the mouse would be a good one.
__________________
Cheers,
Andrew K
Reaper 5.95/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is offline   Reply With Quote
Old 11-14-2018, 03:59 PM   #11
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by Sexan View Post
I think the point of his request is to see where is the cut going to be (like cubase where there is a line following cursor). I think I could make something like that but does not move edit cursor around but have a line that follows mouse cursor all the time (again cubase/studio one like) so you can use split item at mouse cursor with it.I've had this idea script before but if its defered updating edit cursor position all the time hits cpu hard
Can you make this perhaps?
https://forum.cockos.com/showpost.ph...20&postcount=3
nofish is offline   Reply With Quote
Old 11-14-2018, 05:04 PM   #12
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

Quote:
Originally Posted by nofish View Post
Absolutely
Sexan is offline   Reply With Quote
Old 11-15-2018, 01:14 AM   #13
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 88
Default

Quote:
Originally Posted by Sexan View Post
I think the point of his request is to see where is the cut going to be (like cubase where there is a line following cursor). I think I could make something like that but does not move edit cursor around but have a line that follows mouse cursor all the time (again cubase/studio one like) so you can use split item at mouse cursor with it.I've had this idea script before but if its defered updating edit cursor position all the time hits cpu hard
Exactly this! A line would be great, I've noticed that moving the edit cursor around is a little bit laggy, not much though, it definitely works for now.
But a line that follows mouse would be great too.

One of the things I like with having the edit ruler follow mouse is I can easily play/stop and quickly find the right place for the cut. It's just how I did it in Samplitude.
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 11-15-2018, 07:11 AM   #14
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

Quote:
Originally Posted by nofish View Post
fishy is this cool or you need all the info like in that script (note position,length etc) and bigger text?
Sexan is offline   Reply With Quote
Old 11-15-2018, 07:45 AM   #15
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

I wasn't sure if you were kidding or not tbh.
Wanted this since I first saw it (five years ago lol).
My old thread:
https://forum.cockos.com/showthread.php?t=132920

Great work! Thanks so much.

This is already stunning, but since you ask...
Position would be nice too (so I don't have to look up at the ruler), Note length unnecessary (as I see that anyway when drawing notes), also note number wouldn't be necessary for me, note name only (e.g. C2, C3 etc.) is fine. Text size seems fine here too.

Thanks again.

Last edited by nofish; 12-06-2018 at 09:57 AM.
nofish is offline   Reply With Quote
Old 11-15-2018, 07:52 AM   #16
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

position in time/beat/qn ?

Edit : beats?

I've rounded to two decimals since it has 29

Code:
local oct_tbl = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}

function round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

function main()
local x,y = reaper.GetMousePosition()
local window, segment, details = reaper.BR_GetMouseCursorContext()
  if segment == "notes" and window == "midi_editor" then
    local retval, inlineEditor, noteRow, ccLane, ccLaneVal, ccLaneId = reaper.BR_GetMouseCursorContext_MIDI()
    local pos =  reaper.BR_GetMouseCursorContext_Position()
    local retval, measures, cml, fullbeats, cdenom = reaper.TimeMap2_timeToBeats( 0, pos )
    local beats = retval + 1    
    local oct =  math.floor(noteRow / 12) -- get OCTAVE (1,2,3,4....)
    local cur_oct = oct * 12 -- GET OCAVE RANGE (12,24,36...)
    local cur_oct_note = ((cur_oct - noteRow ) * -1) + 1 -- GET OCTAVE NOTE (1,2,3,4...)
    
    for i = 1,#oct_tbl do
      if i == cur_oct_note then
        local note = oct_tbl[i] .. oct - 1 .. " - " .. measures + 1 .. "." .. round(beats, 2)
        if last_x ~= x or last_y ~= y then -- DO NOT UPDATE ALL THE TIME, JUST IF MOUSE POSITION CHANGED 
          reaper.TrackCtl_SetToolTip( note, x, y - 25, true ) -- MOVE IT 25 PIXELS ABOVE CURSOR
          last_x, last_y = x, y
        end
      end
    end
  end
reaper.defer(main)  
end
main()
It will be on ReaPack soon

Last edited by Sexan; 11-15-2018 at 08:12 AM.
Sexan is offline   Reply With Quote
Old 11-15-2018, 08:12 AM   #17
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Not wanting to go over the top but I actually quite like the 16th time format.

https://forum.cockos.com/showpost.ph...08&postcount=7

But if that's too much hassle (or seems to uncommon) yes, time/beat/qn is fine too.

edit:
You can disregard, crosspost with yours above.
nofish is offline   Reply With Quote
Old 11-15-2018, 08:13 AM   #18
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

Ok, let me just change to that (code above is in measure/beats).

btw tick is QN ?

edit: Confused with all the time values haha is this above ok it follows transport values, is that what you want (or something is missing)? (I'm not a midi guy )

Last edited by Sexan; 11-15-2018 at 08:20 AM.
Sexan is offline   Reply With Quote
Old 12-06-2018, 05:55 AM   #19
Eliseat
Human being with feelings
 
Join Date: Mar 2018
Location: Cologne
Posts: 620
Default

Sexan,

do you still work on the vertical line drawing or is it kind of obsolete? I just wonder because this thread seemed to be all about that and ended up with the MIDI editor mouse over infos.

greetings
ELi

Last edited by Eliseat; 12-06-2018 at 06:51 AM.
Eliseat is offline   Reply With Quote
Old 12-06-2018, 06:18 AM   #20
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by Eliseat View Post
Sexan,

do you still work on the vertical line drawing or is it kind of obsolete? I just wonder because this thread seemed to be all about that and ended up with the MIDI editor mouse over infos. :cunfused:

greetings
ELi
Noted. It wasn't good style posting my request here, sorry.
nofish 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 11:15 PM.


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