summaryrefslogtreecommitdiff
path: root/libs/audiographer/src
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-09-18 12:39:17 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2017-09-18 12:39:17 -0400
commit30b087ab3d28f1585987fa3f6ae006562ae192e3 (patch)
tree620ae0250b5d77f90a18f8c2b83be61e4fe7b0b5 /libs/audiographer/src
parentcb956e3e480716a3efd280a5287bdd7bee1cedc5 (diff)
globally change all use of "frame" to refer to audio into "sample".
Generated by tools/f2s. Some hand-editing will be required in a few places to fix up comments related to timecode and video in order to keep the legible
Diffstat (limited to 'libs/audiographer/src')
-rw-r--r--libs/audiographer/src/general/analyser.cc26
-rw-r--r--libs/audiographer/src/general/loudness_reader.cc12
-rw-r--r--libs/audiographer/src/general/normalizer.cc16
-rw-r--r--libs/audiographer/src/general/sample_format_converter.cc44
-rw-r--r--libs/audiographer/src/general/sr_converter.cc78
5 files changed, 88 insertions, 88 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);
}
diff --git a/libs/audiographer/src/general/loudness_reader.cc b/libs/audiographer/src/general/loudness_reader.cc
index 0c2e361fde..924a047561 100644
--- a/libs/audiographer/src/general/loudness_reader.cc
+++ b/libs/audiographer/src/general/loudness_reader.cc
@@ -21,7 +21,7 @@
using namespace AudioGrapher;
-LoudnessReader::LoudnessReader (float sample_rate, unsigned int channels, framecnt_t bufsize)
+LoudnessReader::LoudnessReader (float sample_rate, unsigned int channels, samplecnt_t bufsize)
: _ebur_plugin (0)
, _dbtp_plugin (0)
, _sample_rate (sample_rate)
@@ -91,17 +91,17 @@ LoudnessReader::reset ()
void
LoudnessReader::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 ());
unsigned processed_channels = 0;
if (_ebur_plugin) {
assert (_channels <= 2);
processed_channels = _channels;
- framecnt_t s;
+ samplecnt_t s;
float const * d = ctx.data ();
for (s = 0; s < n_samples; ++s) {
for (unsigned int c = 0; c < _channels; ++c, ++d) {
@@ -126,7 +126,7 @@ LoudnessReader::process (ProcessContext<float> const & ctx)
if (!_dbtp_plugin[c]) {
continue;
}
- framecnt_t s;
+ samplecnt_t s;
float const * const d = ctx.data ();
for (s = 0; s < n_samples; ++s) {
_bufs[0][s] = d[s * _channels + c];
diff --git a/libs/audiographer/src/general/normalizer.cc b/libs/audiographer/src/general/normalizer.cc
index a10382031a..ae603ef946 100644
--- a/libs/audiographer/src/general/normalizer.cc
+++ b/libs/audiographer/src/general/normalizer.cc
@@ -54,23 +54,23 @@ float Normalizer::set_peak (float peak)
* non-const ProcessContexts are given to \a process() .
* \n Not RT safe
*/
-void Normalizer::alloc_buffer(framecnt_t frames)
+void Normalizer::alloc_buffer(samplecnt_t samples)
{
delete [] buffer;
- buffer = new float[frames];
- buffer_size = frames;
+ buffer = new float[samples];
+ buffer_size = samples;
}
/// Process a const ProcessContext \see alloc_buffer() \n RT safe
void Normalizer::process (ProcessContext<float> const & c)
{
- if (throw_level (ThrowProcess) && c.frames() > buffer_size) {
- throw Exception (*this, "Too many frames given to process()");
+ if (throw_level (ThrowProcess) && c.samples() > buffer_size) {
+ throw Exception (*this, "Too many samples given to process()");
}
if (enabled) {
- memcpy (buffer, c.data(), c.frames() * sizeof(float));
- Routines::apply_gain_to_buffer (buffer, c.frames(), gain);
+ memcpy (buffer, c.data(), c.samples() * sizeof(float));
+ Routines::apply_gain_to_buffer (buffer, c.samples(), gain);
}
ProcessContext<float> c_out (c, buffer);
@@ -81,7 +81,7 @@ void Normalizer::process (ProcessContext<float> const & c)
void Normalizer::process (ProcessContext<float> & c)
{
if (enabled) {
- Routines::apply_gain_to_buffer (c.data(), c.frames(), gain);
+ Routines::apply_gain_to_buffer (c.data(), c.samples(), gain);
}
ListedSource<float>::output(c);
}
diff --git a/libs/audiographer/src/general/sample_format_converter.cc b/libs/audiographer/src/general/sample_format_converter.cc
index 1f79818a8b..fbe509fca5 100644
--- a/libs/audiographer/src/general/sample_format_converter.cc
+++ b/libs/audiographer/src/general/sample_format_converter.cc
@@ -41,18 +41,18 @@ SampleFormatConverter<TOut>::SampleFormatConverter (ChannelCount channels) :
template <>
void
-SampleFormatConverter<float>::init (framecnt_t max_frames, int /* type */, int data_width)
+SampleFormatConverter<float>::init (samplecnt_t max_samples, int /* type */, int data_width)
{
if (throw_level (ThrowObject) && data_width != 32) {
throw Exception (*this, "Unsupported data width");
}
- init_common (max_frames);
+ init_common (max_samples);
dither = gdither_new (GDitherNone, channels, GDitherFloat, data_width);
}
template <>
void
-SampleFormatConverter<int32_t>::init (framecnt_t max_frames, int type, int data_width)
+SampleFormatConverter<int32_t>::init (samplecnt_t max_samples, int type, int data_width)
{
if(throw_level (ThrowObject) && data_width > 32) {
throw Exception (*this, "Trying to use SampleFormatConverter<int32_t> with a data width > 32");
@@ -62,47 +62,47 @@ SampleFormatConverter<int32_t>::init (framecnt_t max_frames, int type, int data_
// And since floats only have 24 bits of data, we are fine with this.
data_width = std::min(data_width, 24);
- init_common (max_frames);
+ init_common (max_samples);
dither = gdither_new ((GDitherType) type, channels, GDither32bit, data_width);
}
template <>
void
-SampleFormatConverter<int16_t>::init (framecnt_t max_frames, int type, int data_width)
+SampleFormatConverter<int16_t>::init (samplecnt_t max_samples, int type, int data_width)
{
if (throw_level (ThrowObject) && data_width > 16) {
throw Exception (*this, boost::str(boost::format
("Data width (%1%) too large for int16_t")
% data_width));
}
- init_common (max_frames);
+ init_common (max_samples);
dither = gdither_new ((GDitherType) type, channels, GDither16bit, data_width);
}
template <>
void
-SampleFormatConverter<uint8_t>::init (framecnt_t max_frames, int type, int data_width)
+SampleFormatConverter<uint8_t>::init (samplecnt_t max_samples, int type, int data_width)
{
if (throw_level (ThrowObject) && data_width > 8) {
throw Exception (*this, boost::str(boost::format
("Data width (%1%) too large for uint8_t")
% data_width));
}
- init_common (max_frames);
+ init_common (max_samples);
dither = gdither_new ((GDitherType) type, channels, GDither8bit, data_width);
}
template <typename TOut>
void
-SampleFormatConverter<TOut>::init_common (framecnt_t max_frames)
+SampleFormatConverter<TOut>::init_common (samplecnt_t max_samples)
{
reset();
- if (max_frames > data_out_size) {
+ if (max_samples > data_out_size) {
delete[] data_out;
- data_out = new TOut[max_frames];
- data_out_size = max_frames;
+ data_out = new TOut[max_samples];
+ data_out_size = max_samples;
}
}
@@ -135,12 +135,12 @@ SampleFormatConverter<TOut>::process (ProcessContext<float> const & c_in)
{
float const * const data = c_in.data();
- check_frame_and_channel_count (c_in.frames (), c_in.channels ());
+ check_sample_and_channel_count (c_in.samples (), c_in.channels ());
/* Do conversion */
for (uint32_t chn = 0; chn < c_in.channels(); ++chn) {
- gdither_runf (dither, chn, c_in.frames_per_channel (), data, data_out);
+ gdither_runf (dither, chn, c_in.samples_per_channel (), data, data_out);
}
/* Write forward */
@@ -162,11 +162,11 @@ template<>
void
SampleFormatConverter<float>::process (ProcessContext<float> & c_in)
{
- framecnt_t frames = c_in.frames();
+ samplecnt_t samples = c_in.samples();
float * data = c_in.data();
if (clip_floats) {
- for (framecnt_t x = 0; x < frames; ++x) {
+ for (samplecnt_t x = 0; x < samples; ++x) {
if (data[x] > 1.0f) {
data[x] = 1.0f;
} else if (data[x] < -1.0f) {
@@ -184,8 +184,8 @@ void
SampleFormatConverter<float>::process (ProcessContext<float> const & c_in)
{
// Make copy of data and pass it to non-const version
- check_frame_and_channel_count (c_in.frames(), c_in.channels());
- TypeUtils<float>::copy (c_in.data(), data_out, c_in.frames());
+ check_sample_and_channel_count (c_in.samples(), c_in.channels());
+ TypeUtils<float>::copy (c_in.data(), data_out, c_in.samples());
ProcessContext<float> c (c_in, data_out);
process (c);
@@ -193,7 +193,7 @@ SampleFormatConverter<float>::process (ProcessContext<float> const & c_in)
template<typename TOut>
void
-SampleFormatConverter<TOut>::check_frame_and_channel_count (framecnt_t frames, ChannelCount channels_)
+SampleFormatConverter<TOut>::check_sample_and_channel_count (samplecnt_t samples, ChannelCount channels_)
{
if (throw_level (ThrowStrict) && channels_ != channels) {
throw Exception (*this, boost::str (boost::format
@@ -201,10 +201,10 @@ SampleFormatConverter<TOut>::check_frame_and_channel_count (framecnt_t frames, C
% channels_ % channels));
}
- if (throw_level (ThrowProcess) && frames > data_out_size) {
+ if (throw_level (ThrowProcess) && samples > data_out_size) {
throw Exception (*this, boost::str (boost::format
- ("Too many frames given to process(), %1% instad of %2%")
- % frames % data_out_size));
+ ("Too many samples given to process(), %1% instad of %2%")
+ % samples % data_out_size));
}
}
diff --git a/libs/audiographer/src/general/sr_converter.cc b/libs/audiographer/src/general/sr_converter.cc
index 1468e6a734..a4d19593f0 100644
--- a/libs/audiographer/src/general/sr_converter.cc
+++ b/libs/audiographer/src/general/sr_converter.cc
@@ -34,10 +34,10 @@ using boost::str;
SampleRateConverter::SampleRateConverter (uint32_t channels)
: active (false)
, channels (channels)
- , max_frames_in(0)
+ , max_samples_in(0)
, leftover_data (0)
- , leftover_frames (0)
- , max_leftover_frames (0)
+ , leftover_samples (0)
+ , max_leftover_samples (0)
, data_out (0)
, data_out_size (0)
, src_state (0)
@@ -46,7 +46,7 @@ SampleRateConverter::SampleRateConverter (uint32_t channels)
}
void
-SampleRateConverter::init (framecnt_t in_rate, framecnt_t out_rate, int quality)
+SampleRateConverter::init (samplecnt_t in_rate, samplecnt_t out_rate, int quality)
{
reset();
@@ -72,31 +72,31 @@ SampleRateConverter::~SampleRateConverter ()
reset();
}
-framecnt_t
-SampleRateConverter::allocate_buffers (framecnt_t max_frames)
+samplecnt_t
+SampleRateConverter::allocate_buffers (samplecnt_t max_samples)
{
- if (!active) { return max_frames; }
+ if (!active) { return max_samples; }
- framecnt_t max_frames_out = (framecnt_t) ceil (max_frames * src_data.src_ratio);
- max_frames_out -= max_frames_out % channels;
+ samplecnt_t max_samples_out = (samplecnt_t) ceil (max_samples * src_data.src_ratio);
+ max_samples_out -= max_samples_out % channels;
- if (data_out_size < max_frames_out) {
+ if (data_out_size < max_samples_out) {
delete[] data_out;
- data_out = new float[max_frames_out];
+ data_out = new float[max_samples_out];
src_data.data_out = data_out;
- max_leftover_frames = 4 * max_frames;
- leftover_data = (float *) realloc (leftover_data, max_leftover_frames * sizeof (float));
+ max_leftover_samples = 4 * max_samples;
+ leftover_data = (float *) realloc (leftover_data, max_leftover_samples * sizeof (float));
if (throw_level (ThrowObject) && !leftover_data) {
throw Exception (*this, "A memory allocation error occurred");
}
- max_frames_in = max_frames;
- data_out_size = max_frames_out;
+ max_samples_in = max_samples;
+ data_out_size = max_samples_out;
}
- return max_frames_out;
+ return max_samples_out;
}
void
@@ -109,13 +109,13 @@ SampleRateConverter::process (ProcessContext<float> const & c)
return;
}
- framecnt_t frames = c.frames();
+ samplecnt_t samples = c.samples();
float * in = const_cast<float *> (c.data()); // TODO check if this is safe!
- if (throw_level (ThrowProcess) && frames > max_frames_in) {
+ if (throw_level (ThrowProcess) && samples > max_samples_in) {
throw Exception (*this, str (format (
- "process() called with too many frames, %1% instead of %2%")
- % frames % max_frames_in));
+ "process() called with too many samples, %1% instead of %2%")
+ % samples % max_samples_in));
}
int err;
@@ -125,7 +125,7 @@ SampleRateConverter::process (ProcessContext<float> const & c)
src_data.output_frames = data_out_size / channels;
src_data.data_out = data_out;
- if (leftover_frames > 0) {
+ if (leftover_samples > 0) {
/* input data will be in leftover_data rather than data_in */
@@ -135,8 +135,8 @@ SampleRateConverter::process (ProcessContext<float> const & c)
/* first time, append new data from data_in into the leftover_data buffer */
- TypeUtils<float>::copy (in, &leftover_data [leftover_frames * channels], frames);
- src_data.input_frames = frames / channels + leftover_frames;
+ TypeUtils<float>::copy (in, &leftover_data [leftover_samples * channels], samples);
+ src_data.input_frames = samples / channels + leftover_samples;
} else {
/* otherwise, just use whatever is still left in leftover_data; the contents
@@ -144,12 +144,12 @@ SampleRateConverter::process (ProcessContext<float> const & c)
below)
*/
- src_data.input_frames = leftover_frames;
+ src_data.input_frames = leftover_samples;
}
} else {
src_data.data_in = in;
- src_data.input_frames = frames / channels;
+ src_data.input_frames = samples / channels;
}
first_time = false;
@@ -168,18 +168,18 @@ SampleRateConverter::process (ProcessContext<float> const & c)
% src_strerror (err)));
}
- leftover_frames = src_data.input_frames - src_data.input_frames_used;
+ leftover_samples = src_data.input_frames - src_data.input_frames_used;
- if (leftover_frames > 0) {
- if (throw_level (ThrowProcess) && leftover_frames > max_leftover_frames) {
- throw Exception(*this, "leftover frames overflowed");
+ if (leftover_samples > 0) {
+ if (throw_level (ThrowProcess) && leftover_samples > max_leftover_samples) {
+ throw Exception(*this, "leftover samples overflowed");
}
TypeUtils<float>::move (&src_data.data_in[src_data.input_frames_used * channels],
- leftover_data, leftover_frames * channels);
+ leftover_data, leftover_samples * channels);
}
ProcessContext<float> c_out (c, data_out, src_data.output_frames_gen * channels);
- if (!src_data.end_of_input || leftover_frames) {
+ if (!src_data.end_of_input || leftover_samples) {
c_out.remove_flag (ProcessContext<float>::EndOfInput);
}
output (c_out);
@@ -187,16 +187,16 @@ SampleRateConverter::process (ProcessContext<float> const & c)
if (debug_level (DebugProcess)) {
debug_stream() <<
"src_data.output_frames_gen: " << src_data.output_frames_gen <<
- ", leftover_frames: " << leftover_frames << std::endl;
+ ", leftover_samples: " << leftover_samples << std::endl;
}
- if (throw_level (ThrowProcess) && src_data.output_frames_gen == 0 && leftover_frames) {
+ if (throw_level (ThrowProcess) && src_data.output_frames_gen == 0 && leftover_samples) {
throw Exception (*this, boost::str (boost::format
- ("No output frames generated with %1% leftover frames")
- % leftover_frames));
+ ("No output samples generated with %1% leftover samples")
+ % leftover_samples));
}
- } while (leftover_frames > frames);
+ } while (leftover_samples > samples);
// src_data.end_of_input has to be checked to prevent infinite recursion
if (!src_data.end_of_input && c.has_flag(ProcessContext<float>::EndOfInput)) {
@@ -224,15 +224,15 @@ void SampleRateConverter::set_end_of_input (ProcessContext<float> const & c)
void SampleRateConverter::reset ()
{
active = false;
- max_frames_in = 0;
+ max_samples_in = 0;
src_data.end_of_input = false;
if (src_state) {
src_delete (src_state);
}
- leftover_frames = 0;
- max_leftover_frames = 0;
+ leftover_samples = 0;
+ max_leftover_samples = 0;
if (leftover_data) {
free (leftover_data);
}