From 30b087ab3d28f1585987fa3f6ae006562ae192e3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 Sep 2017 12:39:17 -0400 Subject: 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 --- .../src/general/sample_format_converter.cc | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'libs/audiographer/src/general/sample_format_converter.cc') 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::SampleFormatConverter (ChannelCount channels) : template <> void -SampleFormatConverter::init (framecnt_t max_frames, int /* type */, int data_width) +SampleFormatConverter::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::init (framecnt_t max_frames, int type, int data_width) +SampleFormatConverter::init (samplecnt_t max_samples, int type, int data_width) { if(throw_level (ThrowObject) && data_width > 32) { throw Exception (*this, "Trying to use SampleFormatConverter with a data width > 32"); @@ -62,47 +62,47 @@ SampleFormatConverter::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::init (framecnt_t max_frames, int type, int data_width) +SampleFormatConverter::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::init (framecnt_t max_frames, int type, int data_width) +SampleFormatConverter::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 void -SampleFormatConverter::init_common (framecnt_t max_frames) +SampleFormatConverter::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::process (ProcessContext 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::process (ProcessContext & 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::process (ProcessContext 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::copy (c_in.data(), data_out, c_in.frames()); + check_sample_and_channel_count (c_in.samples(), c_in.channels()); + TypeUtils::copy (c_in.data(), data_out, c_in.samples()); ProcessContext c (c_in, data_out); process (c); @@ -193,7 +193,7 @@ SampleFormatConverter::process (ProcessContext const & c_in) template void -SampleFormatConverter::check_frame_and_channel_count (framecnt_t frames, ChannelCount channels_) +SampleFormatConverter::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::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)); } } -- cgit v1.2.3