Commit 3ba202fb authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Minor fix for updated MLT audiolevel filter (will fix track levels)

parent f142cade
Pipeline #237069 passed with stage
in 5 minutes and 25 seconds
......@@ -108,7 +108,7 @@ void MixerManager::registerTrack(int tid, std::shared_ptr<Mlt::Tractor> service,
connect(mixer.get(), &MixerWidget::muteTrack, this,
[&](int id, bool mute) { m_model->setTrackProperty(id, "hide", mute ? QStringLiteral("1") : QStringLiteral("3")); });
if (m_visibleMixerManager) {
mixer->connectMixer(!KdenliveSettings::mixerCollapse(), m_filterIsV2);
mixer->connectMixer(!KdenliveSettings::mixerCollapse());
}
connect(pCore.get(), &Core::updateMixerLevels, mixer.get(), &MixerWidget::updateAudioLevel);
connect(this, &MixerManager::clearMixers, mixer.get(), &MixerWidget::clear);
......@@ -205,7 +205,7 @@ void MixerManager::setModel(std::shared_ptr<TimelineItemModel> model)
m_masterMixer.reset(new MixerWidget(-1, service, i18n("Master"), QString(), this));
connect(m_masterMixer.get(), &MixerWidget::muteTrack, this, [&](int /*id*/, bool mute) { m_model->tractor()->set("hide", mute ? 3 : 1); });
if (m_visibleMixerManager) {
m_masterMixer->connectMixer(true, m_filterIsV2);
m_masterMixer->connectMixer(true);
}
connect(this, &MixerManager::clearMixers, m_masterMixer.get(), &MixerWidget::clear);
m_masterBox->addWidget(m_masterMixer.get());
......@@ -226,10 +226,10 @@ void MixerManager::connectMixer(bool doConnect)
{
m_visibleMixerManager = doConnect;
for (const auto &item : m_mixers) {
item.second->connectMixer(m_visibleMixerManager && !KdenliveSettings::mixerCollapse(), m_filterIsV2);
item.second->connectMixer(m_visibleMixerManager && !KdenliveSettings::mixerCollapse());
}
if (m_masterMixer != nullptr) {
m_masterMixer->connectMixer(m_visibleMixerManager, m_filterIsV2);
m_masterMixer->connectMixer(m_visibleMixerManager);
}
}
......@@ -277,3 +277,8 @@ int MixerManager::recordTrack() const
{
return m_monitorTrack;
}
bool MixerManager::audioLevelV2() const
{
return m_filterIsV2;
}
......@@ -44,6 +44,8 @@ public:
void monitorAudio(int tid, bool monitor);
/** @brief Track currently monitored that will be used for recording */
int recordTrack() const;
/** @brief Return true if we have MLT's audiolevel filter version 2 or above (fixes reading track audio level) */
bool audioLevelV2() const;
public slots:
void recordStateChanged(int tid, bool recording);
......
......@@ -228,7 +228,9 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
m_monitorFilter.reset(new Mlt::Filter(service->get_profile(), "audiolevel"));
if (m_monitorFilter->is_valid()) {
m_monitorFilter->set("iec_scale", 0);
m_monitorFilter->set("peak", 1);
if (m_manager->audioLevelV2()) {
m_monitorFilter->set("dbpeak", 1);
}
service->attach(*m_monitorFilter.get());
}
}
......@@ -559,15 +561,16 @@ void MixerWidget::setRecordState(bool recording)
updateMonitorState();
}
void MixerWidget::connectMixer(bool doConnect, bool filterV2)
void MixerWidget::connectMixer(bool doConnect)
{
if (doConnect) {
if (m_tid == -1) {
// Master level
connect(pCore.get(), &Core::audioLevelsAvailable, m_audioMeterWidget.get(), &AudioLevelWidget::setAudioValues);
} else if (m_listener == nullptr) {
m_listener = m_monitorFilter->listen(
"property-changed", this, filterV2 ? reinterpret_cast<mlt_listener>(property_changedV2) : reinterpret_cast<mlt_listener>(property_changed));
m_listener = m_monitorFilter->listen("property-changed", this,
m_manager->audioLevelV2() ? reinterpret_cast<mlt_listener>(property_changedV2)
: reinterpret_cast<mlt_listener>(property_changed));
}
} else {
if (m_tid == -1) {
......
......@@ -53,7 +53,7 @@ public:
* */
void unSolo();
/** @brief Connect the mixer widgets to the correspondent filters */
void connectMixer(bool doConnect, bool filterV2);
void connectMixer(bool doConnect);
/** @brief Disable/enable monitoring by disabling/enabling filter */
void pauseMonitoring(bool pause);
/** @brief Update widget to reflect state (monitor/record/none) */
......
  • Audio clip: sin tone level is now perfectly aligned: track = master. Why does the track level meter “vibrate” while playing and the master level is steady?

    AV clip: audio track level is lower than the master level by about 3db.

  • MLT's fix has not been committed yet. The MR is here: https://github.com/mltframework/mlt/pull/823

  • MLT fix https://github.com/mltframework/mlt/pull/823 was merged. I updated MLT master.
    Audio clip: sin tone level is now perfectly aligned: track = master. Track level meter has no “vibrate” anymore while playing -> fixed.

    AV clip or audio clip: audio track level is not in sync with master level. If you stop while playback in some cases track level = no audio, master level = audio is visible.

    1. When you click into the timeline it plays always 1 frame of the audio.
    2. Audio stutters when start playback for about 1-2 second then the playback get stable.
  • Interesting thanks. Looking at the difference in AV clips between master and track I found out the problem is that MLT's audiolevel filter (used to get the level from the tracks) only analyzes the first 200 audio samples per frame, while the master level is calculated based on all audio samples returned by the frame (a typical audio frame contains 1600-1900 samples). That explains the difference. So now I have to think about whether it's best to update the MLT audiolevel filter or to adjust the code in Kdenlive to also only use the first 200 samples. Regarding empty track level on pause that's another issue I have to check.

  • With the three commits: 35814d86, e19ec6c5, d1bdc451 this is definitely fixed:

    AV clip or audio clip: audio track level is not in sync with master level. If you stop while playback in some cases track level = no audio, master level = audio is visible.

    Point 1 and 2 are still open.

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