View Single Post
Old 11-07-2012, 01:33 AM   #36
Human being with feelings
Anton9's Avatar
Join Date: Jun 2009
Location: Earth
Posts: 1,319


Ok so I messed around a little bit and this is what I came up with.
It's not the best solution, but it does work. What this script does is it will get the time sig. and BPM at the edit cursor position(this is handy if your project has any tempo/time sig. changes). It then creates a new project tab and sets it's time sig and BPM to match. However because the ReaScript API does'nt have a function for setting the time sig of a project directly without adding a time sig marker the new project tab will include a time sig marker at the begining. I'm going to put in a request to the devs for a set project time sig function and if it's added I'll update the script.

You may also notice in the script there are commands that switch to the previous project tab and then back to the new one.., these had to be added because the transport does'nt refresh with the settings contained in the time sig. marker until playback occurs or like I discovered until you switch tabs. The switch happens really fast so you should'nt even really notice it.

I did come up with another way of creating a new project based on current projects time/BPM using the SNM_SetIntConfigVar() and SNM_SetDoubleConfigVar() functions which would'nt require a marker being added to the new project. However it also has a transport refresh issue so I'm not posting that script for now.

# TEST  (Gets Time sig. and Tempo at cursor position then creates a new project tab with these settings.)

curProj = 0
CurPos = RPR_GetCursorPosition()
Tnum = 0	# Time sig. numerator
Tdnom = 0	# Time sig. denominator
BPM = 0
x = RPR_TimeMap_GetTimeSigAtTime(curProj, CurPos, Tnum, Tdnom, BPM)	# Gets the time sig. and BPM of current project at cursor position

RPR_Main_OnCommand(40859,0)	#Creates new project tab
RPR_SetTempoTimeSigMarker(0, -1, 0, 0, 0, x[4], x[2], x[3], 0)	# Sets new project tabs time sig. and BPM
RPR_UpdateTimeline()	#Updates the timeline
RPR_Main_OnCommand(40862, 0)	# Previous project tab
RPR_Main_OnCommand(40861, 0)	# Next project tab
Anton9 is offline   Reply With Quote