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

Reply
 
Thread Tools Display Modes
Old 07-01-2022, 11:42 AM   #1
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,205
Default Delete tempo marker but preserve timing of surrounding tempo



I want to remove the middle one, changing the first tempo marker to one which perfectly lasts the two bars until the third one, so as not to ruin the mapping of the rest of the song.. Scratching my head.

I know I can use create measures from time selection action to do this, but that doesn't scale well to removing many tempo markers from a large arrangement.

Last edited by Fergler; 07-01-2022 at 11:56 AM.
Fergler is offline   Reply With Quote
Old 07-01-2022, 03:29 PM   #2
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

I think if you set BPM at 120.1 to 132.258, then delete the time sig at 121.1, it will be close. There is no BPM# that will be perfect and I think 132.258 is as close as you can get.
Tod is offline   Reply With Quote
Old 07-02-2022, 06:21 AM   #3
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

Here's a little EEL script that does this kindof It's pretty dumb, would need some work for anything but n/4. (would it? haven't tried)

If you make a time selection that starts and finishes precisely on the 1st and 3rd tempo markers (i.e. snapped)...

[EDIT]

Oh hang on, it's buggy a.f. will have a look at that.

[EDIT]

Fixed. Not sure who's fault that is. But should work "reliably" now.

UPDATE! something more general - that'll remove all "interior" tempo markers (rather than just one) and update the first marker to preserve the time. Seems like it would be useful for thinning out tempo mapped stuff.

Code:
// make a time selection that starts and finishes precisely on the 1st and last tempo markers. 
// Run this script - any tempo markers inbetween the start and end are removed, 
// but the first one is adjusted to preserve the overall time
  
// time selection
GetSet_LoopTimeRange(0, 0, start_t, end_t, 0);

// the 0.001 fudge helps us pick the first and penultimate markers

mindex_1 = FindTempoTimeSigMarker(0,  start_t + 0.001);

mindex_p = FindTempoTimeSigMarker(0,  end_t - 0.001);

GetTempoTimeSigMarker(0, mindex_1, timeposOut, measureposOut, beatposOut, bpmOut, timesig_numOut, timesig_denomOut, lineartempoOut);

// find number of quarternotes between start and end

start_qn = TimeMap2_timeToQN(0, start_t);
end_qn = TimeMap2_timeToQN(0, end_t);

qn_diff = end_qn - start_qn;
time_diff = end_t - start_t;

// calculate bpm  required to preserve this time difference when interior marker(s) removed

time_per_qn = time_diff / qn_diff;
new_bpm = 60 / time_per_qn;

Undo_BeginBlock();

// update 1st marker
SetTempoTimeSigMarker(0, mindex_1,  timeposOut, measureposOut, beatposOut, new_bpm, timesig_numOut, timesig_denomOut, lineartempoOut);


// remove markers between first and last  

while (mindex_p > mindex_1)
(
	DeleteTempoTimeSigMarker(0, mindex_p );
	mindex_p -=1;
);
UpdateTimeline();

Undo_EndBlock("delete interior tempo marker(s)", 0);
__________________
it's meant to sound like that...

Last edited by jrk; 07-02-2022 at 10:53 AM.
jrk is offline   Reply With Quote
Old 07-02-2022, 11:50 AM   #4
bolgwrad
Human being with feelings
 
bolgwrad's Avatar
 
Join Date: Mar 2011
Location: On my arse in Glasgow, Scotland
Posts: 2,032
Default

Thanks for that jrk, very handy
__________________
www.sachetsofrelish.com
bolgwrad is online now   Reply With Quote
Old 07-03-2022, 06:48 AM   #5
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,205
Default

Very nice jrk
It's it possible to override opt/alt click on a tempo marker while script is running to have the same effect? That would be perfect for me
Fergler is offline   Reply With Quote
Old 07-03-2022, 07:18 AM   #6
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

OK, that would need to find the next and previous tempo markers... And that's simple...

mouse modifier... er... click isn't available... so it would have to be {something}-left drag

.. or ruler context...

I'll get back to you.
__________________
it's meant to sound like that...

Last edited by jrk; 07-03-2022 at 09:21 AM.
jrk is offline   Reply With Quote
Old 07-05-2022, 02:40 PM   #7
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

OK, it doesn't seem that we can assign a mouse modifier to the tempo marker click. So I've made a little EEL script that you can bind to (for instance) ctrl left click on the ruler

Via Preferences | Mouse Modifiers, pick the Ruler / left click context

So you'd ctrl left click under the marker (i.e. on the ruler).

The script should delete the nearest tempo marker, and adjust the tempo of the previous one, preserving the time between that and the marker after...

Code:



function GetClosestTempoTimeSigMarker(time, n)
(
	smallest_diff = GetProjectLength(0);
	
	i = 0;
	
	
	while(i < n)
	(
		GetTempoTimeSigMarker(0, i, timeposOut, measureposOut, beatposOut, bpmOut, timesig_numOut, timesig_denomOut, lineartempoOut);
		diff = abs(time - timeposOut);
		
		diff < smallest_diff ?
		(
			smallest_diff = diff;
			near_marker = i;
		);
		i += 1;
	);
	near_marker;
);


function GetMouseTime()
(
	BR_GetMouseCursorContext(window, segment, details);
	BR_GetMouseCursorContext_Position();
);

n = CountTempoTimeSigMarkers(0);
mouse_t = GetMouseTime();
marker_closest = GetClosestTempoTimeSigMarker(mouse_t,n);

(n > 2) && (marker_closest > 0) && (marker_closest < (n-1)) ?
(
	
	// get the times of these markers, do the prev marker last as we'll be re-using these values below.
	GetTempoTimeSigMarker(0, marker_closest + 1, end_t, measureposOut, beatposOut, bpmOut, timesig_numOut, timesig_denomOut, lineartempoOut);
	GetTempoTimeSigMarker(0, marker_closest - 1, start_t, measureposOut, beatposOut, bpmOut, timesig_numOut, timesig_denomOut, lineartempoOut);
	
	
	start_qn = TimeMap2_timeToQN(0, start_t);
	end_qn = TimeMap2_timeToQN(0, end_t);

	qn_diff = end_qn - start_qn;
	time_diff = end_t - start_t;

	// calculate bpm  required to preserve this time difference when interior marker removed

	time_per_qn = time_diff / qn_diff;
	new_bpm = 60 / time_per_qn;	
		
	Undo_BeginBlock();

	// update previous marker
	SetTempoTimeSigMarker(0, marker_closest - 1,  start_t, measureposOut, beatposOut, new_bpm, timesig_numOut, timesig_denomOut, lineartempoOut);
		
	DeleteTempoTimeSigMarker(0,  marker_closest);     

	UpdateTimeline();
	Undo_EndBlock("delete closest tempo marker", 0);
);
I'm afraid that's the best I can do - perhaps one of the wizards in the scripting sub-forum would have a better idea.
__________________
it's meant to sound like that...

Last edited by jrk; 07-05-2022 at 02:56 PM.
jrk is offline   Reply With Quote
Old 12-19-2022, 09:20 PM   #8
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,205
Default

Jrk, I didn't realize I had more replies here. This is way over-due - but thank you very much for this script!
Fergler is offline   Reply With Quote
Old 12-19-2022, 09:26 PM   #9
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

Quote:
Originally Posted by jrk View Post
I'm afraid that's the best I can do - perhaps one of the wizards in the scripting sub-forum would have a better idea.
I think that's pretty cool jrk.
Tod 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:52 AM.


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