Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 10-16-2019, 01:02 PM   #1
n997
Human being with feelings
 
Join Date: Dec 2018
Posts: 503
Default Any way to set zoom of MIDI editor so 1/16th is 60 pixels, for example?

Is there a script or action to set MIDI editor/piano roll horizontal zoom so that a 1/16th note corresponds to specific number of pixels - for example, 60px?



The use case for this is to have standard visual references for horizontal scale of MIDI notes. For example, 1/16=60px zoom would be for making rhythm patterns which may contain very short notes, 1/16=10px would be for writing pad chord progressions which have long notes, and so on.
n997 is offline   Reply With Quote
Old 10-17-2019, 08:45 AM   #2
n997
Human being with feelings
 
Join Date: Dec 2018
Posts: 503
Default

OK, so far the closest solution was in Dofman's scripts along with idea to fully zoom in/out before zooming to specific level:
https://forum.cockos.com/showthread.php?t=171389

There are also scripts to zoom MIDI editor / piano roll horizontally to 5 bars etc., based on utilizing "zoom to loop" functions:
https://forum.cockos.com/showthread.php?t=91048&page=4



I've made another simple script [for horizontal zooming in MIDI editor] which works by zooming in as far as possible and then zooming out a number of steps.


It works for me, but I have no idea how this is internally related to DPI etc. of a monitor, so anyone who wants to use this might have to customize zoom levels in the script to their own needs.

Good thing is - the script is so simple, anyone can do that (and make several variations for different zoom levels if needed).

Lua code below:
Code:
-- get MIDI editor window to address
active_MIDI_editor = reaper.MIDIEditor_GetActive()

-- don't show intermediate steps
reaper.PreventUIRefresh(1)

--zoom in to maximum (200 steps is likely to cover most cases)
for i=0,200,1
do
  reaper.MIDIEditor_OnCommand(active_MIDI_editor, 1012) --zoom in horizontally
end

--zoom back out a specific number of steps
for i=0,35,1
do
  reaper.MIDIEditor_OnCommand(active_MIDI_editor, 1011) --zoom out horizontally
end

-- update UI
reaper.PreventUIRefresh(-1)
NOTE: the script might not work if it's currently being edited in ReaScript Development Environment. Closing the script editor fixes that.


My way of using this is to load the script into Main section of Actions list, then make a button for it in a custom toolbar. If intended as a button for MIDI Editor toolbar, the script would have to be loaded into MIDI Editor section of Actions list.

If buttons for multiple zoom levels are needed, they can be done by copying the .lua file, changing its name and the number of steps in the script [and loading that file into Actions list, and so on].
Attached Files
File Type: lua n997 MIDI editor - zoom for 16ths.lua (509 Bytes, 74 views)
n997 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 03:56 AM.


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