From a8c47da3643ec234d11f911316ae3d521a26bdad Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 29 Apr 2021 19:05:09 +0200 Subject: [PATCH] Fix realtime export loudness normalization TmpFileRt::get_samples_written() returns the number of samples written *to disk*. It is only valid after the FileFlushed signal is emitted. This fixes an assert() with Limiter and Analyzer being configured with a too low total sample-count, leading to an overflow in the analysis graph array. --- libs/ardour/export_graph_builder.cc | 5 ++++- libs/audiographer/src/general/limiter.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 63f5dd028e..dd1f1b8417 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -720,7 +720,6 @@ void ExportGraphBuilder::Intermediate::prepare_post_processing() { for (boost::ptr_list::iterator i = children.begin(); i != children.end(); ++i) { - (*i).set_duration (tmp_file->get_samples_written() / config.channel_config->get_n_chans()); if (use_peak) { (*i).set_peak_dbfs (peak_reader->get_peak()); } @@ -736,6 +735,10 @@ ExportGraphBuilder::Intermediate::prepare_post_processing() void ExportGraphBuilder::Intermediate::start_post_processing() { + for (boost::ptr_list::iterator i = children.begin(); i != children.end(); ++i) { + (*i).set_duration (tmp_file->get_samples_written() / config.channel_config->get_n_chans()); + } + tmp_file->seek (0, SEEK_SET); /* called in disk-thread when exporting in realtime, diff --git a/libs/audiographer/src/general/limiter.cc b/libs/audiographer/src/general/limiter.cc index fadb433544..63439c3b37 100644 --- a/libs/audiographer/src/general/limiter.cc +++ b/libs/audiographer/src/general/limiter.cc @@ -73,7 +73,7 @@ Limiter::set_duration (samplecnt_t s) return; } const size_t n_data = sizeof (_result->limiter_pk) / sizeof (float); - _spp = ceilf (s / (float) n_data); + _spp = ceilf ((s + 2.f) / (float) n_data); } void