Old 04-15-2021, 10:27 AM   #1
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default Q: Get current value of envelope?

I am trying to get the current (at the play cursor or edit cursor position) value of an Automation Envelope

Code:
env_id = reaper.GetTrackEnvelopeByChunkName(track, "<VOLENV"
env_play = reaper.GetPlayPosition()
env_value = reaper.BR_EnvValueAtPos(env_id, reaper.GetPlayPosition()) +0.217
env_value2 = reaper.Envelope_FormatValue(env_id, env_value)
env_value is always 0.217 indicating that reaper.BR_EnvValueAtPos is always returning 0. "track" is a valid MediaTrack.

Any thoughts or suggestions?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 04-15-2021, 10:48 AM   #2
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Use this ..
Code:
retval, value, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( envelope, time, samplerate, samplesRequested )
J Reverb is offline   Reply With Quote
Old 04-15-2021, 11:06 AM   #3
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Thank you, I'll give that a try. I did see that one but all those D's and V's and S's put me off.

Do you know if reaper.BR_EnvValueAtPos() works at all?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 04-15-2021 at 03:37 PM.
DarkStar is offline   Reply With Quote
Old 04-15-2021, 11:47 AM   #4
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Yes but you have to allocate the envelope with

reaper.BR_EnvAlloc( envelope, takeEnvelopesUseProjectTime )

with reaper.Envelope_Evaluate
you just need the return value so
Code:
retval, value, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( env, cursor_position, 0, 0 )

Last edited by J Reverb; 04-15-2021 at 12:28 PM.
J Reverb is offline   Reply With Quote
Old 04-15-2021, 01:41 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by J Reverb View Post
Yes but you have to allocate the envelope with

reaper.BR_EnvAlloc( envelope, takeEnvelopesUseProjectTime )
Just to add, and call BR_EnvFree when done, otherwise you'd create a memory leak.
nofish is offline   Reply With Quote
Old 04-15-2021, 03:38 PM   #6
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Thank you, guys.

That sounds messy. But reaper.Envelope_Evaluate() worked, once I has qorkws out what the parameters were and where to get them from
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar 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 02:59 AM.


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