Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 12-09-2016, 01:14 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,424
Default Reascript: Function to return mouse pitch and PPQ position in notation editor

Breeder has coded an all-important suite of functions for SWS that return details of the mouse position:

BR_GetMouseCursorContext
BR_GetMouseCursorContext_MIDI
BR_GetMouseCursorContext_Position
BR_GetMouseCursorContext_Take
etc

In the case of BR_GetMouseCursorContext_MIDI, the function returns PPQ position, pitch, CC value, CC lane, etc:

Code:
identifier retval, boolean inlineEditor, number noteRow, number ccLane, number ccLaneVal, number ccLaneId = reaper.BR_GetMouseCursorContext_MIDI()

[BR] Returns midi editor under mouse cursor that was captured with the last call to BR_GetMouseCursorContext.

inlineEditor: if mouse was captured in inline MIDI editor, this will be true (consequentially, returned MIDI editor will be NULL)
noteRow: note row or piano key under mouse cursor (0-127)
ccLane: CC lane under mouse cursor 
ccLaneVal: value in CC lane under mouse cursor (0-127 or 0-16383)
ccLaneId: lane position, counting from the top (0 based)
This allows scripts to track the mouse movement, and to insert MIDI events at the mouse position. For example:




Unfortunately, the SWS functions do not work in the new notation editor, so scripts are blind with regard to mouse position.

Since SWS isn't actively being developed anymore, it would be great if Cockos could provide the missing API function to return the mouse pitch and PPQ position in the notation editor.

(The notation editor is arranged somewhat differently than the piano roll, with different takes on different staves, so the new function may need to return an additional value or two to indicate the take under the mouse.)

Even better than a new function just for the notation editor, would be to replace BR_GetMouseCursorContext_MIDI() with a new, more general function that would work in the notation editor as well as the piano roll and the inline editor.

Since REAPER already tracks mouse movement internally and displays the PPQ position, pitch and/or CC value in the top left corner of the MIDI editor. I expect that this new API function would be easy to implement: the function simply needs to return the values that REAPER already has available.

An added benefit would be improved speed: The SWS functions get slower and slower as the number of MIDI events in the take increase (I suspect that these functions didn't have direct access to the aforementioned internal variables, and had to use some 'trick' to figure out the mouse position). A new, native function would likely be much faster, and would speed up deferred scripts that need to poll the mouse position in each cycle.

Last edited by juliansader; 12-11-2016 at 06:51 PM.
juliansader is offline   Reply With Quote
Old 09-25-2018, 02:03 AM   #2
bFooz
Human being with feelings
 
bFooz's Avatar
 
Join Date: Jul 2010
Location: Slovakia
Posts: 1,662
Default

Yes, +1.
bFooz is offline   Reply With Quote
Old 09-26-2018, 01:59 PM   #3
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 2,136
Default

More love for the MIDI-Editor is always a good thing. +1
mespotine is offline   Reply With Quote
Old 01-23-2021, 04:42 AM   #4
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,424
Default

REAPER already displays the mouse PPQ position, pitch and/or CC value in the top left corner of the MIDI editor. Surely it must be very easy to return the same information to a script via an API function?

juliansader is offline   Reply With Quote
Old 01-23-2021, 05:43 AM   #5
bFooz
Human being with feelings
 
bFooz's Avatar
 
Join Date: Jul 2010
Location: Slovakia
Posts: 1,662
Default

another +1 from me
bFooz is offline   Reply With Quote
Old 01-23-2021, 10:34 PM   #6
pcartwright
Human being with feelings
 
Join Date: Jan 2009
Posts: 987
Default

+1 from me too!
pcartwright is offline   Reply With Quote
Old 01-24-2021, 02:02 AM   #7
bFooz
Human being with feelings
 
bFooz's Avatar
 
Join Date: Jul 2010
Location: Slovakia
Posts: 1,662
Default

What would probably need to have API made for this feature to be complete is to get opened midi items and a midi item under mouse. Especially when there is a continuous view being used with multiple items open.

In the standard MIDI view, the "active context" is a midi item on top of all others opened items covering them and there is a direct editability of just that one item. In notation however there can be multiple items open, shown in lanes and thus editability is not restricted.

In other words, if we can get a current mouse pitch by the API then how can we know which item to insert that note into?
bFooz 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:13 PM.


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