Old 08-18-2018, 06:41 AM   #1
kgarello
Human being with feelings
 
Join Date: Jan 2009
Posts: 310
Default TrackFX_GetParamEx values

I'm seeing unexpected behavior from TrackFX_GetParam and GetParamNormalized.

My code(c++,csurf) looks as follows:

----------------------------------------------------------------

double min, max,mid;

double val = TrackFX_GetParamEx(track, effectslot, m_id, &min, &max,&mid);

----------------------------------------------------------------

after call:
min = 0
max = 2
mid = 1
val = 2.4385089874267578

why is val > max?

Also if I call:

----------------------------------------------------------------

double val2 = TrackFX_GetParamNormalized(track, effectslot, m_id);

----------------------------------------------------------------

val2 = 1.2192544937133789

Doesn't "Normalized" suggest values between [0,1]?

I'm not sure how to deal with these numbers - any discussion appreciated.

Thanks,

Ken

Edit --- I'm calling on the threshold parameter on reacomp and purposefully put it above 0db (+7.7)
kgarello is offline   Reply With Quote
Old 08-18-2018, 07:32 AM   #2
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

https://forum.cockos.com/showthread....19#post1608719

Quote:
Originally Posted by spk77 View Post
These are the functions (blue text) to convert from dB val -> val or val -> dB_val
Code:
val_to_dB = function(val) return 20*math.log(val, 10) end
dB_to_val = function(dB_val) return 10^(dB_val/20) end

-- test
some_dB_val = val_to_dB(2) -- should be ~6.02 dB
some_dB_val_to_val = dB_to_val(some_dB_val) -- should be "2"
dB to slider value:
10^(7.7/20) = 2.42661009508

Slider value to dB:
20*log10(2.42661009508) = 7.7(dB)
spk77 is offline   Reply With Quote
Old 08-18-2018, 10:41 AM   #3
kgarello
Human being with feelings
 
Join Date: Jan 2009
Posts: 310
Default

Thanks spk77.

I guess I understand what the val represents in real terms (which your function explanation helps), but it I had assumed the max and min values would have given me the proper values to perform a normalize function and also that the normalized function would give me [0,1].

I'm trying to map the values to controller position (in my case 0-127). Which I expected to use the normalized value of the total throw of the control...

best laid plans...

Ken
kgarello is offline   Reply With Quote
Old 08-18-2018, 12:21 PM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Not very consistent, indeed

I guess Reaper's automation/envelopes obey the max/min values that TrackFX_GetParamEx returns. We can override the max value programmatically. Also, it's possible to set the threshold parameter to 12dB (>max val) from the Reacomp UI.



Maybe TrackFX_GetParamNormalized returns unexpected values because your value (2.4385089874267578) is greater than the max val (2) that TrackFX_GetParamEx returns:
normalized value = (current value)/(max value - min value)
= 2.4385089874267578/(2-0)
= 1.2192544937133789
spk77 is offline   Reply With Quote
Old 08-18-2018, 01:32 PM   #5
kgarello
Human being with feelings
 
Join Date: Jan 2009
Posts: 310
Default

Quote:
Originally Posted by spk77 View Post
Maybe TrackFX_GetParamNormalized returns unexpected values because your value (2.4385089874267578) is greater than the max val (2) that TrackFX_GetParamEx returns:
normalized value = (current value)/(max value - min value)
= 2.4385089874267578/(2-0)
= 1.2192544937133789

It is consistent with either function call as you pointed out - Before I found the GetParamNoralized, I was using GetParamEx and running it through my normalize function and getting the same result as GetParamNormalized.


I just think of normalized as a value between 0 and 1 so you can use it to map to another space.

I guess if I know that the max DB is +12, then I can use the db functions to find out what the max val would be but I'm not sure if all vst parameters work the same way.
kgarello 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 05:25 AM.


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