Update analysis duration when post-processing
This prevents the need to re-bin data in case silence is trimmed at start or end of the export.
This commit is contained in:
parent
df47da4e55
commit
89a65f76b0
@ -136,6 +136,7 @@ class LIBARDOUR_API ExportGraphBuilder
|
|||||||
void remove_children (bool remove_out_files);
|
void remove_children (bool remove_out_files);
|
||||||
bool operator== (FileSpec const & other_config) const;
|
bool operator== (FileSpec const & other_config) const;
|
||||||
|
|
||||||
|
void set_duration (samplecnt_t);
|
||||||
void set_peak_dbfs (float, bool force = false);
|
void set_peak_dbfs (float, bool force = false);
|
||||||
void set_peak_lufs (AudioGrapher::LoudnessReader const&);
|
void set_peak_lufs (AudioGrapher::LoudnessReader const&);
|
||||||
|
|
||||||
|
@ -452,6 +452,7 @@ ExportGraphBuilder::SFC::SFC (ExportGraphBuilder &parent, FileSpec const & new_c
|
|||||||
samplecnt_t sb = config.format->silence_beginning_at (parent.timespan->get_start(), sample_rate);
|
samplecnt_t sb = config.format->silence_beginning_at (parent.timespan->get_start(), sample_rate);
|
||||||
samplecnt_t se = config.format->silence_end_at (parent.timespan->get_end(), sample_rate);
|
samplecnt_t se = config.format->silence_end_at (parent.timespan->get_end(), sample_rate);
|
||||||
samplecnt_t duration = parent.timespan->get_length () + sb + se;
|
samplecnt_t duration = parent.timespan->get_length () + sb + se;
|
||||||
|
|
||||||
max_samples = std::min ((samplecnt_t) 8192 * channels, std::max ((samplecnt_t) 4096 * channels, max_samples));
|
max_samples = std::min ((samplecnt_t) 8192 * channels, std::max ((samplecnt_t) 4096 * channels, max_samples));
|
||||||
chunker.reset (new Chunker<Sample> (max_samples));
|
chunker.reset (new Chunker<Sample> (max_samples));
|
||||||
analyser.reset (new Analyser (config.format->sample_rate(), channels, max_samples,
|
analyser.reset (new Analyser (config.format->sample_rate(), channels, max_samples,
|
||||||
@ -502,6 +503,15 @@ ExportGraphBuilder::SFC::SFC (ExportGraphBuilder &parent, FileSpec const & new_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ExportGraphBuilder::SFC::set_duration (samplecnt_t n_samples)
|
||||||
|
{
|
||||||
|
/* update after silence trim */
|
||||||
|
if (analyser) {
|
||||||
|
analyser->set_duration (n_samples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ExportGraphBuilder::SFC::set_peak_dbfs (float peak, bool force)
|
ExportGraphBuilder::SFC::set_peak_dbfs (float peak, bool force)
|
||||||
{
|
{
|
||||||
@ -704,8 +714,8 @@ ExportGraphBuilder::Intermediate::process()
|
|||||||
void
|
void
|
||||||
ExportGraphBuilder::Intermediate::prepare_post_processing()
|
ExportGraphBuilder::Intermediate::prepare_post_processing()
|
||||||
{
|
{
|
||||||
if (use_loudness || use_peak) {
|
|
||||||
for (boost::ptr_list<SFC>::iterator i = children.begin(); i != children.end(); ++i) {
|
for (boost::ptr_list<SFC>::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) {
|
if (use_peak) {
|
||||||
(*i).set_peak_dbfs (peak_reader->get_peak());
|
(*i).set_peak_dbfs (peak_reader->get_peak());
|
||||||
}
|
}
|
||||||
@ -713,7 +723,6 @@ ExportGraphBuilder::Intermediate::prepare_post_processing()
|
|||||||
(*i).set_peak_lufs (*loudness_reader);
|
(*i).set_peak_lufs (*loudness_reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tmp_file->add_output (threader);
|
tmp_file->add_output (threader);
|
||||||
parent.intermediates.push_back (this);
|
parent.intermediates.push_back (this);
|
||||||
|
@ -34,6 +34,8 @@ class LIBAUDIOGRAPHER_API Analyser : public LoudnessReader
|
|||||||
void process (ProcessContext<float> const & c);
|
void process (ProcessContext<float> const & c);
|
||||||
ARDOUR::ExportAnalysisPtr result ();
|
ARDOUR::ExportAnalysisPtr result ();
|
||||||
|
|
||||||
|
void set_duration (samplecnt_t n_samples);
|
||||||
|
|
||||||
void set_normalization_gain (float gain) {
|
void set_normalization_gain (float gain) {
|
||||||
_result.normalized = true;
|
_result.normalized = true;
|
||||||
_result.norm_gain_factor = gain;
|
_result.norm_gain_factor = gain;
|
||||||
|
@ -33,15 +33,7 @@ Analyser::Analyser (float sample_rate, unsigned int channels, samplecnt_t bufsiz
|
|||||||
assert (bufsize > 1);
|
assert (bufsize > 1);
|
||||||
assert (_bufsize > 0);
|
assert (_bufsize > 0);
|
||||||
|
|
||||||
|
set_duration (n_samples);
|
||||||
|
|
||||||
const size_t peaks = sizeof (_result.peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
|
|
||||||
_spp = ceil ((_n_samples + 2.f) / (float) peaks);
|
|
||||||
|
|
||||||
const size_t swh = sizeof (_result.spectrum) / sizeof (float);
|
|
||||||
const size_t height = sizeof (_result.spectrum[0]) / sizeof (float);
|
|
||||||
const size_t width = swh / height;
|
|
||||||
_fpp = ceil ((_n_samples + 2.f) / (float) width);
|
|
||||||
|
|
||||||
_fft_data_size = _bufsize / 2;
|
_fft_data_size = _bufsize / 2;
|
||||||
_fft_freq_per_bin = sample_rate / _fft_data_size / 2.f;
|
_fft_freq_per_bin = sample_rate / _fft_data_size / 2.f;
|
||||||
@ -57,6 +49,7 @@ Analyser::Analyser (float sample_rate, unsigned int channels, samplecnt_t bufsiz
|
|||||||
_fft_data_out[i] = 0;
|
_fft_data_out[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const size_t height = sizeof (_result.spectrum[0]) / sizeof (float);
|
||||||
const float nyquist = (sample_rate * .5);
|
const float nyquist = (sample_rate * .5);
|
||||||
#if 0 // linear
|
#if 0 // linear
|
||||||
#define YPOS(FREQ) rint (height * (1.0 - FREQ / nyquist))
|
#define YPOS(FREQ) rint (height * (1.0 - FREQ / nyquist))
|
||||||
@ -101,6 +94,23 @@ Analyser::~Analyser ()
|
|||||||
free (_hann_window);
|
free (_hann_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Analyser::set_duration (samplecnt_t n_samples)
|
||||||
|
{
|
||||||
|
if (_pos != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_n_samples = n_samples;
|
||||||
|
|
||||||
|
const size_t peaks = sizeof (_result.peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
|
||||||
|
_spp = ceil ((_n_samples + 2.f) / (float) peaks);
|
||||||
|
|
||||||
|
const size_t swh = sizeof (_result.spectrum) / sizeof (float);
|
||||||
|
const size_t height = sizeof (_result.spectrum[0]) / sizeof (float);
|
||||||
|
const size_t width = swh / height;
|
||||||
|
_fpp = ceil ((_n_samples + 2.f) / (float) width);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Analyser::process (ProcessContext<float> const & ctx)
|
Analyser::process (ProcessContext<float> const & ctx)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user