diff options
Diffstat (limited to 'libs/audiographer/src/general/analyser.cc')
-rw-r--r-- | libs/audiographer/src/general/analyser.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/libs/audiographer/src/general/analyser.cc b/libs/audiographer/src/general/analyser.cc index 84120b6f53..05491c9da0 100644 --- a/libs/audiographer/src/general/analyser.cc +++ b/libs/audiographer/src/general/analyser.cc @@ -23,7 +23,7 @@ using namespace AudioGrapher; const float Analyser::fft_range_db (120); // dB -Analyser::Analyser (float sample_rate, unsigned int channels, framecnt_t bufsize, framecnt_t n_samples) +Analyser::Analyser (float sample_rate, unsigned int channels, samplecnt_t bufsize, samplecnt_t n_samples) : LoudnessReader (sample_rate, channels, bufsize) , _n_samples (n_samples) , _pos (0) @@ -104,11 +104,11 @@ Analyser::~Analyser () void Analyser::process (ProcessContext<float> const & ctx) { - const framecnt_t n_samples = ctx.frames () / ctx.channels (); + const samplecnt_t n_samples = ctx.samples () / ctx.channels (); assert (ctx.channels () == _channels); - assert (ctx.frames () % ctx.channels () == 0); + assert (ctx.samples () % ctx.channels () == 0); assert (n_samples <= _bufsize); - //printf ("PROC %p @%ld F: %ld, S: %ld C:%d\n", this, _pos, ctx.frames (), n_samples, ctx.channels ()); + //printf ("PROC %p @%ld F: %ld, S: %ld C:%d\n", this, _pos, ctx.samples (), n_samples, ctx.channels ()); // allow 1 sample slack for resampling if (_pos + n_samples > _n_samples + 1) { @@ -118,11 +118,11 @@ Analyser::process (ProcessContext<float> const & ctx) } float const * d = ctx.data (); - framecnt_t s; + samplecnt_t s; const unsigned cmask = _result.n_channels - 1; // [0, 1] for (s = 0; s < n_samples; ++s) { _fft_data_in[s] = 0; - const framecnt_t pbin = (_pos + s) / _spp; + const samplecnt_t pbin = (_pos + s) / _spp; for (unsigned int c = 0; c < _channels; ++c) { const float v = *d; if (fabsf(v) > _result.peak) { _result.peak = fabsf(v); } @@ -169,8 +169,8 @@ Analyser::process (ProcessContext<float> const & ctx) #undef FIm const size_t height = sizeof (_result.spectrum[0]) / sizeof (float); - const framecnt_t x0 = _pos / _fpp; - framecnt_t x1 = (_pos + n_samples) / _fpp; + const samplecnt_t x0 = _pos / _fpp; + samplecnt_t x1 = (_pos + n_samples) / _fpp; if (x0 == x1) x1 = x0 + 1; for (uint32_t i = 0; i < _fft_data_size - 1; ++i) { @@ -212,9 +212,9 @@ Analyser::result () if (_pos + 1 < _n_samples) { // crude re-bin (silence stripped version) const size_t peaks = sizeof (_result.peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4; - for (framecnt_t b = peaks - 1; b > 0; --b) { + for (samplecnt_t b = peaks - 1; b > 0; --b) { for (unsigned int c = 0; c < _result.n_channels; ++c) { - const framecnt_t sb = b * _pos / _n_samples; + const samplecnt_t sb = b * _pos / _n_samples; _result.peaks[c][b].min = _result.peaks[c][sb].min; _result.peaks[c][b].max = _result.peaks[c][sb].max; } @@ -223,9 +223,9 @@ Analyser::result () 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; - for (framecnt_t b = width - 1; b > 0; --b) { + for (samplecnt_t b = width - 1; b > 0; --b) { // TODO round down to prev _fft_data_size bin - const framecnt_t sb = b * _pos / _n_samples; + const samplecnt_t sb = b * _pos / _n_samples; for (unsigned int y = 0; y < height; ++y) { _result.spectrum[b][y] = _result.spectrum[sb][y]; } @@ -258,7 +258,7 @@ Analyser::result () for (std::vector<float>::const_iterator i = features[1][0].values.begin(); i != features[1][0].values.end(); ++i) { - const framecnt_t pk = (*i) / _spp; + const samplecnt_t pk = (*i) / _spp; const unsigned int cc = c & cmask; _result.truepeakpos[cc].insert (pk); } |