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

Reply
 
Thread Tools Display Modes
Old 05-02-2014, 02:12 PM   #1
David Perry
Human being with feelings
 
Join Date: Oct 2010
Posts: 272
Default Snap or quantize markers to grid (not stretch markers)

Is there any way to do this automatically? I couldn't find an action. I key markers in in real time sometimes and place them at the play cursor. Being able to quantize them to the grid would help.
David Perry is offline   Reply With Quote
Old 05-04-2014, 07:20 AM   #2
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Here's an EEL script - Move project markers to the closest grid.
  • Markers are moved to the closest grid -> set the grid division from the "Snap/Grid settings"
  • "Snap to grid" can be enabled or disabled



Code:
// Move project markers to the closest grid  (EEL script 4.5.2014 by spk77)
// Markers are moved to the closest grid -> set the grid division from "Snap/Grid settings"
// ("Snap to grid" can be enabled or disabled)

function move_markers_to_grid() local(snap, index, isrgn, pos, rgnend, markrgnindexnumber)
(
  index = 0;
  Undo_BeginBlock();
  GetToggleCommandState(1157) ? (
    snap = 1;
  ) : (
    snap = 0;
    Main_OnCommand(1157, 0);
  );

  while(EnumProjectMarkers(index, isrgn, pos, rgnend, #nameOut, markrgnindexnumber)) (
    isrgn == 0 ? SetProjectMarker(markrgnindexnumber, isrgn, SnapToGrid(0, pos), rgnend, #nameOut);
    index += 1;
  );
  snap == 0 ? Main_OnCommand(1157, 0);
  Undo_EndBlock("Move markers to grid", -1);
);

move_markers_to_grid();
spk77 is offline   Reply With Quote
Old 05-07-2014, 03:02 PM   #3
David Perry
Human being with feelings
 
Join Date: Oct 2010
Posts: 272
Default

Great, this works a treat. Thanks a million!
David Perry is offline   Reply With Quote
Old 04-19-2015, 10:54 AM   #4
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

@spk77
As always, many thanks.

Is there a way to get this to work for frames?

I mainly work with CD frames (75)

When I have the project settings set to frames (75), and grid set to: hours:mins:secs:frames, the script works but the pixel or zoom settings messes it up, unless I'm zoomed all the way in.

Is there a possible work around for this?

Thanks,
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 04-19-2015, 12:47 PM   #5
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by WyattRice View Post
@spk77
As always, many thanks.

Is there a way to get this to work for frames?

I mainly work with CD frames (75)

When I have the project settings set to frames (75), and grid set to: hours:mins:secs:frames, the script works but the pixel or zoom settings messes it up, unless I'm zoomed all the way in.

Is there a possible work around for this?

Thanks,
Wyatt
Hmm...yes, it seems "Grid settings->minimum pixels" -setting breaks this script.


Breeder might have a solution :
Quote:
Originally Posted by Breeder View Post
I actually have this solved in the SWS, I can export something like SnapToGridDivision(position) for the next SWS pre, so spk77 can reuse it in his script.
(But it will not work in REAPER 4)


EDIT: I think SnapToGrid(project, pos) snaps to visible grid line and that's why it doesn't work.
spk77 is offline   Reply With Quote
Old 04-19-2015, 02:18 PM   #6
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

It's a while since I wrote it, but I'm sure my CD Track Marker tool will do what you're asking, Wyatt.

Until I fully understood what was needed to make sure markers for tracks didn't mess up gapless CDs (you were a great help to me here, do you remember? -thank you), I included a means to quantise markers to the nearest 1/75 sec frame boundary.

As they were still useful to me -a quantised marker should never be moved by a burning pass -I left them in the tool. The quantise moves to the nearest 1/75s regardless of what frame size or grid settings are being used in the project, and any marker turns green if it aligns. Mousewheel/Ctrl-MW moves the marker to and by 10-frame/1-frame quantised increments.

There is a help page, but it was quite an early script for me so it is a bit clunky -post or PM if you need any help with it. Tool allows easy time selection alignment to the CD range, shows marker positions in terms of source times, and shows the CD tracks, track lengths, etc on the last page (from memory).

I still use it if I create a CD from REAPER, I find it shows stuff clearly and speeds up my workflow (once you know what the bits are ).



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is online now   Reply With Quote
Old 04-19-2015, 03:28 PM   #7
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

Thanks Nathan. PM sent.
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 04-20-2015, 05:05 AM   #8
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

And replied...


I think I'm going to add a "Quantise all markers" button on the Alignment page if that helps at all, Wyatt.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is online now   Reply With Quote
Old 04-20-2015, 10:18 AM   #9
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

That would be great!

Thanks, Wyatt

Edit:
Would it be possible for you to do a stand alone version with no gui, just an action (Quantize all markers)?
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 04-20-2015, 12:52 PM   #10
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by WyattRice View Post
That would be great!

Thanks, Wyatt

Edit:
Would it be possible for you to do a stand alone version with no gui, just an action (Quantize all markers)?

I don't see why not, I just have to pull the right bits out of the tool.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is online now   Reply With Quote
Old 04-22-2015, 07:19 PM   #11
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

Quote:
Originally Posted by planetnine View Post
I don't see why not, I just have to pull the right bits out of the tool.
>
Hi Nathan,
I finally got it figured out. Man it was right there in front of me the whole time from the old "insert cd marker at cursor" code I had.
I'm still a total noob when it comes to coding, but it's fun to watch stuff work right.
Anyway this seems to work. Needs code cleanup, etc.
This was just a quick test.

Code:
// Special thanks to gofer, planetnine, spk77, and, Argitoth.
//Quantize CD markers.eel
 
function round(value,digits) local(y)
(
  y = floor(value * pow(10, digits) + 0.5) / pow(10, digits);
  y;
);

function round(number) local(a b)
(
  b = abs(number);
  a = ceil(b-1);
  a = b - a;
  a >= .5 ? b = ceil(b) : b = floor(b);
  number < 0 ? number = -b : number = b;
  number;
);
Undo_BeginBlock2(0);
index = 0;
framesize = 1.0 / 75.0;

  while(EnumProjectMarkers(index, isrgn, pos, rgnend, #nameOut, markrgnindexnumber)) (
    framediv = pos / framesize;
    FrameCount = round(framediv);  // finds the frame during which the marker position is      
    Framerem = framediv % 1; //get the remainder of the un-rounded frame position to decide whether to round up
    
    quanpos = FrameCount * framesize;
    SetProjectMarker(markrgnindexnumber, isrgn, quanpos, rgnend, #nameOut);
    index += 1;
    Undo_EndBlock2(0, "Quantize CD markers", -1);
);
Edit: Thanks to user Argitoth, for the round function from this thread
Thanks, Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.

Last edited by WyattRice; 04-22-2015 at 09:37 PM.
WyattRice is offline   Reply With Quote
Old 01-19-2018, 04:37 AM   #12
uncleswede
Human being with feelings
 
Join Date: Feb 2015
Posts: 1,096
Default

Quote:
Originally Posted by spk77 View Post
Here's an EEL script - Move project markers to the closest grid.
  • Markers are moved to the closest grid -> set the grid division from the "Snap/Grid settings"
  • "Snap to grid" can be enabled or disabled



Code:
// Move project markers to the closest grid  (EEL script 4.5.2014 by spk77)
// Markers are moved to the closest grid -> set the grid division from "Snap/Grid settings"
// ("Snap to grid" can be enabled or disabled)

function move_markers_to_grid() local(snap, index, isrgn, pos, rgnend, markrgnindexnumber)
(
  index = 0;
  Undo_BeginBlock();
  GetToggleCommandState(1157) ? (
    snap = 1;
  ) : (
    snap = 0;
    Main_OnCommand(1157, 0);
  );

  while(EnumProjectMarkers(index, isrgn, pos, rgnend, #nameOut, markrgnindexnumber)) (
    isrgn == 0 ? SetProjectMarker(markrgnindexnumber, isrgn, SnapToGrid(0, pos), rgnend, #nameOut);
    index += 1;
  );
  snap == 0 ? Main_OnCommand(1157, 0);
  Undo_EndBlock("Move markers to grid", -1);
);

move_markers_to_grid();
Hi. Old thread, but I can't get this script to work correctly on Reaper 5.70. Whatever grid setting I choose, the project markers snap to the nearest whole note (I was trying to snap to the nearest quarter note).

Here's a link to a GIF demonstrating the problem:

https://stash.reaper.fm/32724/snap%2...d%20script.gif

Last edited by uncleswede; 01-20-2018 at 04:20 AM. Reason: clarification
uncleswede is offline   Reply With Quote
Old 01-20-2018, 04:46 AM   #13
uncleswede
Human being with feelings
 
Join Date: Feb 2015
Posts: 1,096
Default

Bump - any scripters able to cast an eye over this quantize project markers issue?

Script appears to be ignoring current snap to grid settings (e.g 1/4 note) and adjusts markers to the nearest whole note?

Cheers
uncleswede is offline   Reply With Quote
Old 01-21-2018, 03:04 AM   #14
Philbo King
Human being with feelings
 
Philbo King's Avatar
 
Join Date: May 2017
Posts: 3,204
Default

{Deleted]

Last edited by Philbo King; 01-21-2018 at 03:16 AM.
Philbo King 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:46 PM.


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