|
|
|
08-25-2014, 07:59 PM
|
#1
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
RPR_BR_EnvSetPoint
is there an example of this anyplace? i'm about as little of a programmer as you could be but could really use a simple script that just drops a point at the cursor with a specific value hardcoded into the script. this is in the current sws beta.
thanks,
BabaG
|
|
|
08-26-2014, 12:15 AM
|
#2
|
Human being with feelings
Join Date: Nov 2010
Posts: 2,436
|
Not exactly the example you asked for, but this should definitely get you started (and explain why you can't use RPR_ prefix on SWS API functions):
https://github.com/Jeff0S/sws/issues/655
|
|
|
08-26-2014, 12:41 AM
|
#3
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
no, but very interesting and helpful nonetheless. i'll start to try to play with what's here. thanks!
BabaG
|
|
|
08-26-2014, 11:23 AM
|
#4
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
i added a line to the script from msmucr in Breeder's link:
Code:
#!/usr/bin/env python
from reaper_python import *
from sws_python import *
def msg(m): RPR_ShowConsoleMsg(str(m) + "\n")
cur_pos = RPR_GetCursorPositionEx(0)
envelope = RPR_GetSelectedEnvelope(0)
msg("Selected envelope: {}".format(envelope))
if envelope != 0:
brEnv = BR_EnvAlloc(envelope, True)
cur_automation_value = BR_EnvValueAtPos(brEnv, cur_pos)
msg("Envelope Value at cursor is: {}".format(cur_automation_value))
BR_EnvSetPoint(void* envelope, Int id, Float position, Float value, Int shape, Boolean selected, Float bezier)
BR_EnvFree(brEnv, False)
the added line is:
Code:
BR_EnvSetPoint(void* envelope, Int id, Float position, Float value, Int shape, Boolean selected, Float bezier)
i tried by hit-and-miss to figure out the syntax for that line but kept getting errors. two questions:
1. am i correct that all this needs is the added line in order to set a new point in the envelope?
2. how would i simply apply a -3db point using this line? i'm testing this on a track volume envelope.
thanks,
BabaG
Last edited by babag; 08-26-2014 at 11:29 AM.
|
|
|
08-26-2014, 12:52 PM
|
#5
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
I thought there was something wrong with the functions, but then I noticed that..
this
Code:
BR_EnvFree(brEnv, False)
has to be
Code:
BR_EnvFree(brEnv, True)
(There are some examples at the end how to change a "dB val" to "slider val")
Code:
#!/usr/bin/env python
from reaper_python import *
from sws_python import *
import math
def msg(m): RPR_ShowConsoleMsg(str(m) + "\n")
cur_pos = RPR_GetCursorPositionEx(0)
envelope = RPR_GetSelectedEnvelope(0)
msg("Selected envelope: {}".format(envelope))
if envelope != 0:
brEnv = BR_EnvAlloc(envelope, True)
cur_automation_value = BR_EnvValueAtPos(brEnv, cur_pos)
id = env_point_id_at_cursor = BR_EnvFind(brEnv, cur_pos, 0.0) # Returns envelope point id (zero-based) on success or -1 on failure.
msg("Envelope Value at cursor is: {}".format(cur_automation_value))
msg("Point Id at cursor: {}".format(id))
# func desc: BR_EnvSetPoint(void* envelope, Int id, Float position, Float value, Int shape, Boolean selected, Float bezier)
if id > -1:
minus3dB = math.pow(10, -3 / 20.0)
BR_EnvSetPoint(brEnv, env_point_id_at_cursor, cur_pos, minus3dB, 0, True, 0.0)
BR_EnvFree(brEnv, True)
dB_val = 20 * math.log10(cur_automation_value)
msg("Point value in dB: {}".format(dB_val))
slider_val = math.pow(10, dB_val / 20.0)
msg("Point dB value back to 'slider value': {}".format(slider_val))
slider_val_at_minus3dB = math.pow(10, -3 / 20.0)
msg("'Slider value' if dB value == -3dB: {}".format(slider_val_at_minus3dB))
|
|
|
08-26-2014, 01:07 PM
|
#6
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
This seems to work (for adding a -3dB point at edit cursor). There are probably better ways to do it - I'm using RPR_Main_OnCommand(40915, 0) (for inserting a point at edit cursor) if BR_EnvFind returns -1.
Code:
#!/usr/bin/env python
from reaper_python import *
from sws_python import *
import math
def msg(m): RPR_ShowConsoleMsg(str(m) + "\n")
cur_pos = RPR_GetCursorPositionEx(0)
envelope = RPR_GetSelectedEnvelope(0)
if envelope != 0:
brEnv = BR_EnvAlloc(envelope, True)
cur_automation_value = BR_EnvValueAtPos(brEnv, cur_pos)
id = env_point_id_at_cursor = BR_EnvFind(brEnv, cur_pos, 0.0) # Returns envelope point id (zero-based) on success or -1 on failure.
minus3dB = math.pow(10, -3 / 20.0)
if id > -1:
BR_EnvSetPoint(brEnv, env_point_id_at_cursor, cur_pos, minus3dB, 0, True, 0.0)
if id == -1:
RPR_Main_OnCommand(40915, 0) # insert new point
BR_EnvSetPoint(brEnv, env_point_id_at_cursor, cur_pos, minus3dB, 0, True, 0.0)
BR_EnvFree(brEnv, True)
|
|
|
08-26-2014, 02:14 PM
|
#7
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Set selected points in selected envelope to -3dB:
Code:
#!/usr/bin/env python
from reaper_python import *
from sws_python import *
import math
def msg(m): RPR_ShowConsoleMsg(str(m) + "\n")
envelope = RPR_GetSelectedEnvelope(0)
if envelope != 0:
pos = -10000.0
minus3dB = math.pow(10, -3 / 20.0)
brEnv = BR_EnvAlloc(envelope, True)
num_points = BR_EnvCountPoints(brEnv)
for i in range(num_points):
id = BR_EnvFindNext(brEnv, pos)
if id > -1:
retval, env, id, pos, val, shape, sel, bez = BR_EnvGetPoint(brEnv, id, 0.0, 0.0, 0, 0, 0.0)
if retval and sel:
BR_EnvSetPoint(brEnv, id, pos, minus3dB, shape, sel, bez)
BR_EnvFree(brEnv, True)
|
|
|
08-26-2014, 04:29 PM
|
#8
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
thanks, spk77. i tried your first and found it both confusing and revealing. i think i was misunderstanding the command as creating a point when it actually only modified the value of an EXISTING point. do i have that right? will try your new one when i get back to my test system.
edit>
back and playing with the script. seems to work great. a question: this works with db values for a volume curve. i see the line
Code:
minus3dB = math.pow(10, -3 / 20.0)
i assume this has to do with converting db values to whatever numbers reaper take directly at the curve. i see the python docs say it's about converting to float. how would i use numbers other than db values? i have other curves i want to modify (reasurround placement) that take other types of values like .039 and .958. also, what about when the volume curve is all the way down to -inf. how would that be input? i seem to be able to change the -3 value easily but these are other things that have come up.
edit>
got it. i had a typo.
thanks again,
BabaG
Last edited by babag; 08-26-2014 at 09:30 PM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 12:52 PM.
|