Commit 12203f46 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix audio rec level in mixer (track head still todo)

parent 61478765
......@@ -489,10 +489,10 @@ void MixerWidget::gotRecLevels(QVector<qreal>levels)
m_audioMeterWidget->setAudioValues({-100, -100});
break;
case 1:
m_audioMeterWidget->setAudioValues({IEC_Scale(log10(levels[0]) * 20.0), -100});
m_audioMeterWidget->setAudioValues({levels[0], -100});
break;
default:
m_audioMeterWidget->setAudioValues({IEC_Scale(log10(levels[0]) * 20.0), IEC_Scale(log10(levels[1]) * 20.0)});
m_audioMeterWidget->setAudioValues({levels[0], levels[1]});
break;
}
}
......
......@@ -256,7 +256,6 @@ qreal getPeakValue(const QAudioFormat &format)
QVector<qreal> getBufferLevels(const QAudioBuffer &buffer)
{
QVector<qreal> values;
if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian) {
return values;
}
......@@ -284,13 +283,10 @@ QVector<qreal> getBufferLevels(const QAudioBuffer &buffer)
if (buffer.format().sampleSize() == 8) {
values = getBufferLevels(buffer.constData<quint8>(), buffer.frameCount(), channelCount);
}
std::transform(values.begin(), values.end(), values.begin(),
[peak_value](double val) { return qAbs(val - peak_value / 2) / (peak_value / 2); });
break;
case QAudioFormat::Float:
if (buffer.format().sampleSize() == 32) {
values = getBufferLevels(buffer.constData<float>(), buffer.frameCount(), channelCount);
std::transform(values.begin(), values.end(), values.begin(), [peak_value](double val) { return val / peak_value; });
}
break;
case QAudioFormat::SignedInt:
......@@ -303,9 +299,10 @@ QVector<qreal> getBufferLevels(const QAudioBuffer &buffer)
if (buffer.format().sampleSize() == 8) {
values = getBufferLevels(buffer.constData<qint8>(), buffer.frameCount(), channelCount);
}
std::transform(values.begin(), values.end(), values.begin(), [peak_value](double val) { return val / peak_value; });
break;
}
std::transform(values.begin(), values.end(), values.begin(),
[peak_value](double val) { return (20. * log10(val / peak_value)); });
return values;
}
......
......@@ -100,7 +100,7 @@ Item {
if (currentLevel > peak) {
peak = currentLevel
} else if (peak > 0) {
peak -= 0.003
peak -= 0.2
}
}
Rectangle {
......
Supports Markdown
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