Commit 997a9abd authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Reduce range of volume effect (limit to -50 - +50 dB), and use logarithmic scale in timeline.

Related to #770
parent 68914726
Pipeline #29549 passed with stage
in 29 minutes and 24 seconds
......@@ -3,7 +3,7 @@
<name>Volume (keyframable)</name>
<description>Adjust audio volume with keyframes</description>
<author>Dan Dennedy</author>
<parameter type="animated" name="level" default="0" max="60" min="-100" suffix="dB" scale="-1">
<parameter type="animated" name="level" default="0" max="50" min="-50" suffix="dB" scale="-1">
<name>Gain</name>
</parameter>
</effect>
......@@ -305,9 +305,9 @@ bool KeyframeModel::updateKeyframe(int pos, double newVal)
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
if (newVal >= 0.5) {
realValue = norm + (2 * (newVal - 0.5) * (max / factor - norm));
realValue = norm + pow(2 * (newVal - 0.5), 10.0 / 6) * (max / factor - norm);
} else {
realValue = norm - pow(2 * (0.5 - newVal), 10.0 / 6) * (norm - min / factor);
}
......@@ -461,11 +461,12 @@ QVariant KeyframeModel::data(const QModelIndex &index, int role) const
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double linear = val * factor;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
// transform current value to 0..1 scale
if (linear >= norm) {
return 0.5 + (linear - norm) / (max * factor - norm) * 0.5;
double scaled = (linear - norm) / (max * factor - norm);
return 0.5 + pow(scaled, 0.6) * 0.5;
}
// transform current value to 0..1 scale
double scaled = (linear - norm) / (min * factor - norm);
// Log scale
return 0.5 - pow(scaled, 0.6) * 0.5;
......@@ -896,9 +897,9 @@ QVariant KeyframeModel::getNormalizedValue(double newVal) const
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
if (newVal >= 0.5) {
realValue = norm + (2 * (newVal - 0.5) * (max / factor - norm));
realValue = norm + pow(2 * (newVal - 0.5), 10.0 / 6) * (max / factor - norm);
} else {
realValue = norm - pow(2 * (0.5 - newVal), 10.0 / 6) * (norm - min / factor);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment