|
|
|
02-12-2024, 08:39 AM
|
#1
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
Volume automation value conversion to dB
I'm having hard time with this conversion. reaper.Envelope_Evaluate(volumeEnvelope, position, 0, 0) returns values between 0 and 1334.9297943142 for volume automation values between -infinity to +24dB. Does anyone know the exact conversion formula for this?
|
|
|
02-12-2024, 11:52 AM
|
#2
|
Human being with feelings
Join Date: May 2017
Posts: 3,201
|
Geez, I just turn it up or down till it sounds right...
|
|
|
02-12-2024, 11:54 AM
|
#3
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
google gemini says:
You're correct that reaper.Envelope_Evaluate(volumeEnvelope, position, 0, 0) in REAPER returns values between 0 and 1334.9297943142 for volume automation values between -infinity and +24 dB. Here's the exact conversion formula:
Formula:
envelope_value = (linear_gain - 1) / ((10^(max_db / 20)) - 1) * 1334.9297943142
Where:
envelope_value: The REAPER internal envelope value (between 0 and 1334.9297943142).
linear_gain: The linear gain calculated from the dB value using 10^(db / 20).
max_db: The maximum allowed dB value (usually 24 dB).
Explanation:
Convert dB to linear gain: The formula first converts the dB value to linear gain using the equation 10^(db / 20). This conversion is necessary because REAPER's internal envelope values are based on linear gain, not dB.
Normalize to range [0, 1]: The linear gain is then normalized to the range [0, 1] by subtracting 1 and dividing by the difference between the linear gain at the maximum allowed dB and 1. This normalization step ensures that the envelope value remains within the valid range.
Scale to REAPER's range: Finally, the normalized value is multiplied by 1334.9297943142 to scale it to the range used by REAPER's internal envelope.
Example:
To calculate the envelope value for a volume of -10 dB, you would use the following steps:
Calculate the linear gain: linear_gain = 10^(-10 / 20) = 0.1
Normalize to range [0, 1]: normalized_gain = (0.1 - 1) / ((10^(24 / 20)) - 1) = -0.0999999999999955
Scale to REAPER's range: envelope_value = -0.0999999999999955 * 1334.9297943142 = -61.47
Therefore, the envelope value for a volume of -10 dB in REAPER would be approximately -61.47.
I hope this explanation clarifies the conversion formula for you!
|
|
|
02-12-2024, 03:33 PM
|
#4
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
Too bad it's hallucinating like members of the Beatles back in the day. First of all, there are no negative numbers in the parameter.
But I got it quite close already. Conversion to dB is about :
6 * (math.log(value / 716.21785031261) / math.log(1.22))
Quote:
Originally Posted by Coachz
google gemini says:
You're correct that reaper.Envelope_Evaluate(volumeEnvelope, position, 0, 0) in REAPER returns values between 0 and 1334.9297943142 for volume automation values between -infinity and +24 dB. Here's the exact conversion formula:
Formula:
envelope_value = (linear_gain - 1) / ((10^(max_db / 20)) - 1) * 1334.9297943142
Where:
envelope_value: The REAPER internal envelope value (between 0 and 1334.9297943142).
linear_gain: The linear gain calculated from the dB value using 10^(db / 20).
max_db: The maximum allowed dB value (usually 24 dB).
Explanation:
Convert dB to linear gain: The formula first converts the dB value to linear gain using the equation 10^(db / 20). This conversion is necessary because REAPER's internal envelope values are based on linear gain, not dB.
Normalize to range [0, 1]: The linear gain is then normalized to the range [0, 1] by subtracting 1 and dividing by the difference between the linear gain at the maximum allowed dB and 1. This normalization step ensures that the envelope value remains within the valid range.
Scale to REAPER's range: Finally, the normalized value is multiplied by 1334.9297943142 to scale it to the range used by REAPER's internal envelope.
Example:
To calculate the envelope value for a volume of -10 dB, you would use the following steps:
Calculate the linear gain: linear_gain = 10^(-10 / 20) = 0.1
Normalize to range [0, 1]: normalized_gain = (0.1 - 1) / ((10^(24 / 20)) - 1) = -0.0999999999999955
Scale to REAPER's range: envelope_value = -0.0999999999999955 * 1334.9297943142 = -61.47
Therefore, the envelope value for a volume of -10 dB in REAPER would be approximately -61.47.
I hope this explanation clarifies the conversion formula for you!
|
|
|
|
02-12-2024, 06:01 PM
|
#5
|
Human being with feelings
Join Date: Sep 2022
Posts: 222
|
from EEL Envelope Based Compressor:
Code:
// -- DB2VAL - VAL2DB ----------------------------
function DB2VAL(x)
(
exp((x)*0.11512925464970228420089957273422);
);
//----------------------------
function VAL2DB(x)
local(v)
(
x < 0.0000000298023223876953125 ? (
-150;
) : (
v = log(x)*8.6858896380650365530225783783321;
v < -150 ? -150 : v;
);
);
|
|
|
02-13-2024, 02:13 AM
|
#6
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
|
|
|
02-13-2024, 04:26 AM
|
#7
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
Here is lua code to convert from envelope value to dB
https://github.com/ReaTeam/ReaScript...20to%20Val.lua
Note that if faderScaling on the trck is active, use the related API function to convert back to non fader scaled value first.
@Coachz
Quote:
Therefore, the envelope value for a volume of -10 dB in REAPER would be approximately -61.47.
|
No. It would be 0.31622776601684. And 0 would -inf so the answer can't be negative.
So please, dont copy paste AI ChatBots results, especially when wrong and unverified 🙏. People can prompt them on their own if this is the kind of answer they are looking for.
This faulty calculations just add a layers of confusion.
|
|
|
02-14-2024, 04:59 AM
|
#8
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
Thanks for answers. However, I don't mean the value to convert dB to multiplies (like +6dB to 1.995262315) but the value you get with reaper.Envelope_Evaluate(volumeEnvelope, position, 0, 0).
Here are some example returns:
+12dB 1000
+6dB 852.2869803
+0dB 716.22
This formula doesn't seem to be any log or exp function since when I approximate this with exponential function then the difference to ground truth seems to have at least third-degree polynomial nature. See the Google sheet:
https://docs.google.com/spreadsheets...it?usp=sharing
|
|
|
02-14-2024, 05:44 AM
|
#9
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
Thank you so much! It was the fader scaling that messed things up!
Quote:
Originally Posted by X-Raym
Here is lua code to convert from envelope value to dB
https://github.com/ReaTeam/ReaScript...20to%20Val.lua
Note that if faderScaling on the trck is active, use the related API function to convert back to non fader scaled value first.
@Coachz
No. It would be 0.31622776601684. And 0 would -inf so the answer can't be negative.
So please, dont copy paste AI ChatBots results, especially when wrong and unverified 🙏. People can prompt them on their own if this is the kind of answer they are looking for.
This faulty calculations just add a layers of confusion.
|
|
|
|
02-14-2024, 05:55 AM
|
#10
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
So, if I want to read the amplitude scaled value of the track volume automation then I basically need also change the graph to show amplitude scaling? Are there any other possibilities? I would like to read the value while the track plays but would not want to mess with user settings.
So:
- Does anyone know formula to convert between fader scaling and amplitude scaling?
- Is there a way to read the automation in amplitude scaling without changing the preference?
|
|
|
02-14-2024, 06:07 AM
|
#11
|
Human being with feelings
Join Date: Feb 2020
Posts: 24
|
Ok, success with:
reaper.ScaleFromEnvelopeMode(reaper.GetEnvelopeSca lingMode(volumeEnvelope), value)
Thanks X-Raym!
|
|
|
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 06:13 AM.
|