Old 05-19-2012, 08:12 AM   #1
drew
Mobile
 
drew's Avatar
 
Join Date: Jan 2006
Location: London & São Paulo. Hardcore commercial REAPERite
Posts: 1,669
Default Adding a new tempo / time signature marker in Python

Ok - I give in!

Can anyone advise how to add Time Sig and/or tempo markers (with the optional 'gradual transition') in ReaScript?

For some reason this one has got me stuck!

Cheers!
__________________
Proudly using REAPER exclusively for...
* Media and event music composition & production, sound design + auto-processing at Qsonics.com
* Broadcast branding, promos, education & training and narration voice-overs at DrewWhite.com
drew is offline   Reply With Quote
Old 05-21-2012, 12:04 PM   #2
KarlLai
Human being with feelings
 
KarlLai's Avatar
 
Join Date: Feb 2012
Posts: 26
Default

I would like to know the answer too! I am working on a C++ plugin and I need to add tempo markers. If there is a way to do in scripts, there should be a way to do in c++ too!

Quote:
Originally Posted by drew View Post
Ok - I give in!

Can anyone advise how to add Time Sig and/or tempo markers (with the optional 'gradual transition') in ReaScript?

For some reason this one has got me stuck!

Cheers!
KarlLai is offline   Reply With Quote
Old 05-21-2012, 01:15 PM   #3
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Interesting. I could imagine an approach would be to edit the envelope state of the master track's tempo envelope. Here is what the WIKI sais how a tempo envelope state chunk looks like (look at the descriptions for the lines starting with "PT ..."
From the WIKI: http://wiki.cockos.com/wiki/index.ph...tEnvelopeState:
Code:
TEMPOENVEX

These are on the master track; they store tempo change information.

<TEMPOENVEX
ACT 1
VIS 1 0 1.000000
LANEHEIGHT 0 0
ARM 0
DEFSHAPE 1
PT 16.800000000000 100.0000000000 1 524294 // 1st value: location on timeline
                                           // 2nd value: bpm
                                           // 3rd value: If 1, square shape (no linear increase in tempo to next pt). if 0, increase
                                           //            tempo linearly to next tempo pt
                                           // 4th value: time signature, first 3 digits are denominator, last 3 are numerator
                                           // denom: 8388 = 128th, 4194 = 64th, 2097 = 32nd, 1048 = 16th,
                                                      524 = 8th, 262 = quarter, 131 = half, 65 = whole
                                           // num: starts at different value for each denom, then increments as numerator increments
                                           //      In above order, starts from: 609; 305; 153; 577; 289; 145; 073; 537
PT 27.600000000000 140.0000000000 1 262148
>
I can't say I understand how exactly the 4th value of a PT line encodes the time sig from that description, but it should make sense with some thinking .

I also couldn't tell you how to get to the pointer of the tempo envelope or the master track in the first place, never tried to do any scripting towards the master track yet. I hope someone else has an idea, or there is a totally different approach altogether.
gofer is offline   Reply With Quote
Old 05-22-2012, 07:30 AM   #4
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,167
Default

Here is a python script I made for tweaking tempo maps:

http://forum.cockos.com/showpost.php...9&postcount=23

Hope it helps in some way...
Youn is offline   Reply With Quote
Old 05-22-2012, 07:43 AM   #5
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,167
Default

Basically, all you do is this:

Code:
# Get Master track pointer:
trkptr = RPR_CSurf_TrackFromID(0,0)

# Get Envelope Pointer:
envptr = RPR_GetTrackEnvelopeByName( trkptr, 'Tempo map' )

# Get Envelope Data:
envstate = RPR_GetSetEnvelopeState(envptr, "", maxlen)

# Now do simple string manipulations to rebuild the envelope data

# Then update it like this:
RPR_GetSetEnvelopeState(envptr, NEWenvstate, maxlen)
RPR_UpdateTimeline()
I'd love to see what y'all come up with. I'm a tempo-map hound, apparently.
Youn is offline   Reply With Quote
Old 05-22-2012, 03:41 PM   #6
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Check out the latest pre
4.23pre11 has
+ API: added function to insert tempo/time signature changes

Might make some stuff way easier .
gofer is offline   Reply With Quote
Old 05-22-2012, 05:59 PM   #7
drew
Mobile
 
drew's Avatar
 
Join Date: Jan 2006
Location: London & São Paulo. Hardcore commercial REAPERite
Posts: 1,669
Default

Youn - that's a great help.. really going to enjoy using (and learning from) that script! Thanks so much.

gofer - that's amazing timing, isn't it?? It's almost as if someone is reading what people write :O

{thanks Cockos!}
__________________
Proudly using REAPER exclusively for...
* Media and event music composition & production, sound design + auto-processing at Qsonics.com
* Broadcast branding, promos, education & training and narration voice-overs at DrewWhite.com
drew 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:35 AM.


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