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: 98
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: 70
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: 98
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: 70
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: 743
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: 10,474
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
__________________
http://www.residenceemilia.com
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: ASU`ogacihC
Posts: 3,913
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: 1,719
Default

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

Cheers!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
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: 4,596
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: 1,719
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 v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
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: 12,096
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: 4,596
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: 98
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: 4,596
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: 12,096
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: 4,596
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: 12,096
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: 4,596
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
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
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: 12,096
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
Old 03-31-2020, 05:37 AM   #21
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default

This script in combination with the custom action is great! Is there any way to have it work with the ALT key as a modifier instead of a toggle? I can't see how.

Cheers!

Last edited by fbeauvaisc; 03-31-2020 at 09:01 AM.
fbeauvaisc is offline   Reply With Quote
Old 03-31-2020, 11:34 AM   #22
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

I used this behaviour in Samplitude all the time. Now I have the Z key bound to the action View: Move edit cursor to mouse cursor (no snapping) so I can move it whenever I need (probably hundreds of times a day).
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere 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 02:08 PM.


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