diff options
author | Carl Hetherington <carl@carlh.net> | 2010-12-03 22:26:29 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-12-03 22:26:29 +0000 |
commit | 73192bc1a7ea55fa1864dc3826845b15c00dd2ec (patch) | |
tree | c0039f3f5a848aed6e880abf11519dad855fa899 /libs/audiographer/audiographer | |
parent | 74b4a3c77b08dc1e58274875604eb73e8492fa93 (diff) |
Remove all use of nframes_t.
git-svn-id: svn://localhost/ardour2/branches/3.0@8166 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer')
14 files changed, 81 insertions, 79 deletions
diff --git a/libs/audiographer/audiographer/general/chunker.h b/libs/audiographer/audiographer/general/chunker.h index 38345acb1f..397d67ffc5 100644 --- a/libs/audiographer/audiographer/general/chunker.h +++ b/libs/audiographer/audiographer/general/chunker.h @@ -20,7 +20,7 @@ class Chunker /** Constructs a new Chunker with a constant chunk size. * \n NOT RT safe */ - Chunker (nframes_t chunk_size) + Chunker (framecnt_t chunk_size) : chunk_size (chunk_size) , position (0) { @@ -41,12 +41,12 @@ class Chunker { check_flags (*this, context); - nframes_t frames_left = context.frames(); - nframes_t input_position = 0; + framecnt_t frames_left = context.frames(); + framecnt_t input_position = 0; while (position + frames_left >= chunk_size) { // Copy from context to buffer - nframes_t const frames_to_copy = chunk_size - position; + framecnt_t const frames_to_copy = chunk_size - position; TypeUtils<T>::copy (&context.data()[input_position], &buffer[position], frames_to_copy); // Output whole buffer @@ -73,8 +73,8 @@ class Chunker using Sink<T>::process; private: - nframes_t chunk_size; - nframes_t position; + framecnt_t chunk_size; + framecnt_t position; T * buffer; }; diff --git a/libs/audiographer/audiographer/general/deinterleaver.h b/libs/audiographer/audiographer/general/deinterleaver.h index 2a6ad64ef2..96d77b1f7b 100644 --- a/libs/audiographer/audiographer/general/deinterleaver.h +++ b/libs/audiographer/audiographer/general/deinterleaver.h @@ -34,7 +34,7 @@ class DeInterleaver typedef boost::shared_ptr<Source<T> > SourcePtr; /// Inits the deinterleaver. Must be called before using. \n Not RT safe - void init (unsigned int num_channels, nframes_t max_frames_per_channel) + void init (unsigned int num_channels, framecnt_t max_frames_per_channel) { reset(); channels = num_channels; @@ -59,10 +59,10 @@ class DeInterleaver /// Deinterleaves data and outputs it to the outputs. \n RT safe void process (ProcessContext<T> const & c) { - nframes_t frames = c.frames(); + framecnt_t frames = c.frames(); T const * data = c.data(); - nframes_t const frames_per_channel = frames / channels; + framecnt_t const frames_per_channel = frames / channels; if (throw_level (ThrowProcess) && c.channels() != channels) { throw Exception (*this, "wrong amount of channels given to process()"); @@ -100,7 +100,7 @@ class DeInterleaver std::vector<OutputPtr> outputs; unsigned int channels; - nframes_t max_frames; + framecnt_t max_frames; T * buffer; }; diff --git a/libs/audiographer/audiographer/general/interleaver.h b/libs/audiographer/audiographer/general/interleaver.h index 98a71f3afd..924c1d04a5 100644 --- a/libs/audiographer/audiographer/general/interleaver.h +++ b/libs/audiographer/audiographer/general/interleaver.h @@ -31,7 +31,7 @@ class Interleaver ~Interleaver() { reset(); } /// Inits the interleaver. Must be called before using. \n Not RT safe - void init (unsigned int num_channels, nframes_t max_frames_per_channel) + void init (unsigned int num_channels, framecnt_t max_frames_per_channel) { reset(); channels = num_channels; @@ -78,11 +78,11 @@ class Interleaver using Sink<T>::process; - nframes_t frames() { return frames_written; } + framecnt_t frames() { return frames_written; } void reset() { frames_written = 0; } private: - nframes_t frames_written; + framecnt_t frames_written; Interleaver & parent; unsigned int channel; }; @@ -115,7 +115,7 @@ class Interleaver buffer[channel + (channels * i)] = c.data()[i]; } - nframes_t const ready_frames = ready_to_output(); + framecnt_t const ready_frames = ready_to_output(); if (ready_frames) { ProcessContext<T> c_out (c, buffer, ready_frames, channels); ListedSource<T>::output (c_out); @@ -123,13 +123,13 @@ class Interleaver } } - nframes_t ready_to_output() + framecnt_t ready_to_output() { - nframes_t ready_frames = inputs[0]->frames(); + framecnt_t ready_frames = inputs[0]->frames(); if (!ready_frames) { return 0; } for (unsigned int i = 1; i < channels; ++i) { - nframes_t const frames = inputs[i]->frames(); + framecnt_t const frames = inputs[i]->frames(); if (!frames) { return 0; } if (throw_level (ThrowProcess) && frames != ready_frames) { init (channels, max_frames); @@ -143,7 +143,7 @@ class Interleaver std::vector<InputPtr> inputs; unsigned int channels; - nframes_t max_frames; + framecnt_t max_frames; T * buffer; }; diff --git a/libs/audiographer/audiographer/general/normalizer.h b/libs/audiographer/audiographer/general/normalizer.h index 205f6e70e5..48d0fe8b0b 100644 --- a/libs/audiographer/audiographer/general/normalizer.h +++ b/libs/audiographer/audiographer/general/normalizer.h @@ -48,7 +48,7 @@ class Normalizer * non-const ProcessContexts are given to \a process() . * \n Not RT safe */ - void alloc_buffer(nframes_t frames) + void alloc_buffer(framecnt_t frames) { delete [] buffer; buffer = new float[frames]; @@ -86,7 +86,7 @@ class Normalizer float gain; float * buffer; - nframes_t buffer_size; + framecnt_t buffer_size; }; diff --git a/libs/audiographer/audiographer/general/sample_format_converter.h b/libs/audiographer/audiographer/general/sample_format_converter.h index 8dda57c4cc..a200f37825 100644 --- a/libs/audiographer/audiographer/general/sample_format_converter.h +++ b/libs/audiographer/audiographer/general/sample_format_converter.h @@ -40,7 +40,7 @@ class SampleFormatConverter * \note If the non-const version of process() is used with floats, * there is no need to call this function. */ - void init (nframes_t max_frames, int type, int data_width); + void init (framecnt_t max_frames, int type, int data_width); /// Set whether or not clipping to [-1.0, 1.0] should occur when TOut = float. Clipping is off by default void set_clip_floats (bool yn) { clip_floats = yn; } @@ -53,12 +53,12 @@ class SampleFormatConverter private: void reset(); - void init_common(nframes_t max_frames); // not-template-specialized part of init - void check_frame_and_channel_count(nframes_t frames, ChannelCount channels_); + void init_common (framecnt_t max_frames); // not-template-specialized part of init + void check_frame_and_channel_count (framecnt_t frames, ChannelCount channels_); ChannelCount channels; GDither dither; - nframes_t data_out_size; + framecnt_t data_out_size; TOut * data_out; bool clip_floats; diff --git a/libs/audiographer/audiographer/general/silence_trimmer.h b/libs/audiographer/audiographer/general/silence_trimmer.h index 5256d4a8cc..8782a25d4b 100644 --- a/libs/audiographer/audiographer/general/silence_trimmer.h +++ b/libs/audiographer/audiographer/general/silence_trimmer.h @@ -22,7 +22,7 @@ class SilenceTrimmer public: /// Constructor, \see reset() \n Not RT safe - SilenceTrimmer(nframes_t silence_buffer_size_ = 1024) + SilenceTrimmer(framecnt_t silence_buffer_size_ = 1024) : silence_buffer_size (0) , silence_buffer (0) { @@ -40,7 +40,7 @@ class SilenceTrimmer * This also defines the maximum length of output process context * which can be output during long intermediate silence. */ - void reset (nframes_t silence_buffer_size_ = 1024) + void reset (framecnt_t silence_buffer_size_ = 1024) { if (throw_level (ThrowObject) && silence_buffer_size_ == 0) { throw Exception (*this, @@ -68,7 +68,7 @@ class SilenceTrimmer * Needs to be called before starting processing. * \n RT safe */ - void add_silence_to_beginning (nframes_t frames_per_channel) + void add_silence_to_beginning (framecnt_t frames_per_channel) { if (throw_level (ThrowObject) && !in_beginning) { throw Exception(*this, "Tried to add silence to beginning after already outputting data"); @@ -80,7 +80,7 @@ class SilenceTrimmer * Needs to be called before end is reached. * \n RT safe */ - void add_silence_to_end (nframes_t frames_per_channel) + void add_silence_to_end (framecnt_t frames_per_channel) { if (throw_level (ThrowObject) && in_end) { throw Exception(*this, "Tried to add silence to end after already reaching end"); @@ -131,7 +131,7 @@ class SilenceTrimmer } in_end = c.has_flag (ProcessContext<T>::EndOfInput); - nframes_t frame_index = 0; + framecnt_t frame_index = 0; if (in_beginning) { @@ -223,9 +223,9 @@ class SilenceTrimmer private: - bool find_first_non_zero_sample (ProcessContext<T> const & c, nframes_t & result_frame) + bool find_first_non_zero_sample (ProcessContext<T> const & c, framecnt_t & result_frame) { - for (nframes_t i = 0; i < c.frames(); ++i) { + for (framecnt_t i = 0; i < c.frames(); ++i) { if (c.data()[i] != static_cast<T>(0.0)) { result_frame = i; // Round down to nearest interleaved "frame" beginning @@ -236,13 +236,13 @@ class SilenceTrimmer return false; } - void output_silence_frames (ProcessContext<T> const & c, nframes_t & total_frames, bool adding_to_end = false) + void output_silence_frames (ProcessContext<T> const & c, framecnt_t & total_frames, bool adding_to_end = false) { bool end_of_input = c.has_flag (ProcessContext<T>::EndOfInput); c.remove_flag (ProcessContext<T>::EndOfInput); while (total_frames > 0) { - nframes_t frames = std::min (silence_buffer_size, total_frames); + framecnt_t frames = std::min (silence_buffer_size, total_frames); if (max_output_frames) { frames = std::min (frames, max_output_frames); } @@ -262,20 +262,20 @@ class SilenceTrimmer } - bool in_beginning; - bool in_end; + bool in_beginning; + bool in_end; - bool trim_beginning; - bool trim_end; + bool trim_beginning; + bool trim_end; - nframes_t silence_frames; - nframes_t max_output_frames; + framecnt_t silence_frames; + framecnt_t max_output_frames; - nframes_t add_to_beginning; - nframes_t add_to_end; + framecnt_t add_to_beginning; + framecnt_t add_to_end; - nframes_t silence_buffer_size; - T * silence_buffer; + framecnt_t silence_buffer_size; + T * silence_buffer; }; } // namespace diff --git a/libs/audiographer/audiographer/general/sr_converter.h b/libs/audiographer/audiographer/general/sr_converter.h index f28c8f6953..a3298bbf97 100644 --- a/libs/audiographer/audiographer/general/sr_converter.h +++ b/libs/audiographer/audiographer/general/sr_converter.h @@ -25,10 +25,10 @@ class SampleRateConverter ~SampleRateConverter (); /// Init converter \n Not RT safe - void init (nframes_t in_rate, nframes_t out_rate, int quality = 0); + void init (framecnt_t in_rate, framecnt_t out_rate, int quality = 0); /// Returns max amount of frames that will be output \n RT safe - nframes_t allocate_buffers (nframes_t max_frames); + framecnt_t allocate_buffers (framecnt_t max_frames); /** Does sample rate conversion. * Note that outpt size may vary a lot. @@ -46,14 +46,14 @@ class SampleRateConverter bool active; uint32_t channels; - nframes_t max_frames_in; + framecnt_t max_frames_in; float * leftover_data; - nframes_t leftover_frames; - nframes_t max_leftover_frames; + framecnt_t leftover_frames; + framecnt_t max_leftover_frames; float * data_out; - nframes_t data_out_size; + framecnt_t data_out_size; SRC_DATA src_data; SRC_STATE* src_state; diff --git a/libs/audiographer/audiographer/process_context.h b/libs/audiographer/audiographer/process_context.h index 3ad84d7708..843c09b618 100644 --- a/libs/audiographer/audiographer/process_context.h +++ b/libs/audiographer/audiographer/process_context.h @@ -37,7 +37,7 @@ public: public: /// Basic constructor with data, frame and channel count - ProcessContext (T * data, nframes_t frames, ChannelCount channels) + ProcessContext (T * data, framecnt_t frames, ChannelCount channels) : _data (data), _frames (frames), _channels (channels) { validate_data(); } @@ -48,13 +48,13 @@ public: /// "Copy constructor" with unique data, frame and channel count, but copies flags template<typename Y> - ProcessContext (ProcessContext<Y> const & other, T * data, nframes_t frames, ChannelCount channels) + ProcessContext (ProcessContext<Y> const & other, T * data, framecnt_t frames, ChannelCount channels) : _data (data), _frames (frames), _channels (channels), _flags (other.flags()) { validate_data(); } /// "Copy constructor" with unique data and frame count, but copies channel count and flags template<typename Y> - ProcessContext (ProcessContext<Y> const & other, T * data, nframes_t frames) + ProcessContext (ProcessContext<Y> const & other, T * data, framecnt_t frames) : _data (data), _frames (frames), _channels (other.channels()), _flags (other.flags()) { validate_data(); } @@ -65,7 +65,7 @@ public: { /* No need to validate data */ } /// Make new Context out of the beginning of this context - ProcessContext beginning (nframes_t frames) + ProcessContext beginning (framecnt_t frames) { if (throw_level (ThrowProcess) && frames > _frames) { throw Exception (*this, boost::str (boost::format @@ -84,7 +84,7 @@ public: inline T * data() { return _data; } /// \a frames tells how many frames the array pointed by data contains - inline nframes_t const & frames() const { return _frames; } + inline framecnt_t const & frames() const { return _frames; } /** \a channels tells how many interleaved channels \a data contains * If \a channels is greater than 1, each channel contains \a frames / \a channels frames of data @@ -92,7 +92,7 @@ public: inline ChannelCount const & channels() const { return _channels; } /// Returns the amount of frames per channel - inline nframes_t frames_per_channel() const { return _frames / _channels; } + inline framecnt_t frames_per_channel() const { return _frames / _channels; } /* Flags */ @@ -103,7 +103,7 @@ public: protected: T * const _data; - nframes_t _frames; + framecnt_t _frames; ChannelCount _channels; mutable FlagField _flags; @@ -124,11 +124,11 @@ template <typename T = DefaultSampleType> struct AllocatingProcessContext : public ProcessContext<T> { /// Allocates uninitialized memory - AllocatingProcessContext (nframes_t frames, ChannelCount channels) + AllocatingProcessContext (framecnt_t frames, ChannelCount channels) : ProcessContext<T> (new T[frames], frames, channels) {} /// Allocates and copies data from raw buffer - AllocatingProcessContext (T const * data, nframes_t frames, ChannelCount channels) + AllocatingProcessContext (T const * data, framecnt_t frames, ChannelCount channels) : ProcessContext<T> (new T[frames], frames, channels) { TypeUtils<float>::copy (data, ProcessContext<T>::_data, frames); } @@ -139,12 +139,12 @@ struct AllocatingProcessContext : public ProcessContext<T> /// "Copy constructor" with uninitialized data, unique frame and channel count, but copies flags template<typename Y> - AllocatingProcessContext (ProcessContext<Y> const & other, nframes_t frames, ChannelCount channels) + AllocatingProcessContext (ProcessContext<Y> const & other, framecnt_t frames, ChannelCount channels) : ProcessContext<T> (other, new T[frames], frames, channels) {} /// "Copy constructor" with uninitialized data, unique frame count, but copies channel count and flags template<typename Y> - AllocatingProcessContext (ProcessContext<Y> const & other, nframes_t frames) + AllocatingProcessContext (ProcessContext<Y> const & other, framecnt_t frames) : ProcessContext<T> (other, new T[frames], frames, other.channels()) {} /// "Copy constructor" uninitialized data, that copies frame and channel count + flags @@ -161,7 +161,7 @@ class ConstProcessContext { public: /// Basic constructor with data, frame and channel count - ConstProcessContext (T const * data, nframes_t frames, ChannelCount channels) + ConstProcessContext (T const * data, framecnt_t frames, ChannelCount channels) : context (const_cast<T *>(data), frames, channels) {} /// Copy constructor from const ProcessContext @@ -170,12 +170,12 @@ class ConstProcessContext /// "Copy constructor", with unique data, frame and channel count, but copies flags template<typename ProcessContext> - ConstProcessContext (ProcessContext const & other, T const * data, nframes_t frames, ChannelCount channels) + ConstProcessContext (ProcessContext const & other, T const * data, framecnt_t frames, ChannelCount channels) : context (other, const_cast<T *>(data), frames, channels) {} /// "Copy constructor", with unique data and frame count, but copies channel count and flags template<typename ProcessContext> - ConstProcessContext (ProcessContext const & other, T const * data, nframes_t frames) + ConstProcessContext (ProcessContext const & other, T const * data, framecnt_t frames) : context (other, const_cast<T *>(data), frames) {} /// "Copy constructor", with unique data, but copies frame and channel count + flags diff --git a/libs/audiographer/audiographer/sndfile/sndfile.h b/libs/audiographer/audiographer/sndfile/sndfile.h index 4db2298a90..939e5f8a2c 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile.h +++ b/libs/audiographer/audiographer/sndfile/sndfile.h @@ -16,7 +16,7 @@ class Sndfile : public SndfileWriter<T>, public SndfileReader<T> public: Sndfile (std::string const & filename, SndfileBase::Mode mode = SndfileBase::ReadWrite, int format = 0, - ChannelCount channels = 0, nframes_t samplerate = 0) + ChannelCount channels = 0, framecnt_t samplerate = 0) : SndfileHandle (filename, mode, format, channels, samplerate) {} @@ -27,4 +27,4 @@ class Sndfile : public SndfileWriter<T>, public SndfileReader<T> } // namespace -#endif // AUDIOGRAPHER_SNDFILE_H
\ No newline at end of file +#endif // AUDIOGRAPHER_SNDFILE_H diff --git a/libs/audiographer/audiographer/sndfile/sndfile_reader.h b/libs/audiographer/audiographer/sndfile/sndfile_reader.h index f5f7adcb3a..f7a04f22d6 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_reader.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_reader.h @@ -29,7 +29,7 @@ class SndfileReader * Note that the data read is output to the outputs, as well as read into the context * \return number of frames read */ - nframes_t read (ProcessContext<T> & context) + framecnt_t read (ProcessContext<T> & context) { if (throw_level (ThrowStrict) && context.channels() != channels() ) { throw Exception (*this, boost::str (boost::format @@ -37,7 +37,7 @@ class SndfileReader % context.channels() % channels())); } - nframes_t frames_read = SndfileHandle::read (context.data(), context.frames()); + framecnt_t const frames_read = SndfileHandle::read (context.data(), context.frames()); ProcessContext<T> c_out = context.beginning (frames_read); if (frames_read < context.frames()) { @@ -54,4 +54,4 @@ class SndfileReader } // namespace -#endif // AUDIOGRAPHER_SNDFILE_READER_H
\ No newline at end of file +#endif // AUDIOGRAPHER_SNDFILE_READER_H diff --git a/libs/audiographer/audiographer/sndfile/sndfile_writer.h b/libs/audiographer/audiographer/sndfile/sndfile_writer.h index a6f338487a..7b3c2968ff 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_writer.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_writer.h @@ -27,7 +27,7 @@ class SndfileWriter , public FlagDebuggable<> { public: - SndfileWriter (std::string const & path, int format, ChannelCount channels, nframes_t samplerate, boost::shared_ptr<BroadcastInfo> broadcast_info) + SndfileWriter (std::string const & path, int format, ChannelCount channels, framecnt_t samplerate, boost::shared_ptr<BroadcastInfo> broadcast_info) : SndfileHandle (path, Write, format, channels, samplerate) , path (path) { @@ -54,7 +54,7 @@ class SndfileWriter % c.channels() % channels())); } - nframes_t written = write (c.data(), c.frames()); + framecnt_t const written = write (c.data(), c.frames()); if (throw_level (ThrowProcess) && written != c.frames()) { throw Exception (*this, boost::str (boost::format ("Could not write data to output file (%1%)") diff --git a/libs/audiographer/audiographer/sndfile/tmp_file.h b/libs/audiographer/audiographer/sndfile/tmp_file.h index e312007247..a4e7b2679a 100644 --- a/libs/audiographer/audiographer/sndfile/tmp_file.h +++ b/libs/audiographer/audiographer/sndfile/tmp_file.h @@ -13,7 +13,7 @@ class TmpFile : public SndfileWriter<T>, public SndfileReader<T> { public: - TmpFile (int format, ChannelCount channels, nframes_t samplerate) + TmpFile (int format, ChannelCount channels, framecnt_t samplerate) : SndfileHandle (fileno (tmpfile()), true, SndfileBase::ReadWrite, format, channels, samplerate) {} @@ -24,4 +24,4 @@ class TmpFile : public SndfileWriter<T>, public SndfileReader<T> } // namespace -#endif // AUDIOGRAPHER_TMP_FILE_H
\ No newline at end of file +#endif // AUDIOGRAPHER_TMP_FILE_H diff --git a/libs/audiographer/audiographer/type_utils.h b/libs/audiographer/audiographer/type_utils.h index d17f3634ed..360168d55d 100644 --- a/libs/audiographer/audiographer/type_utils.h +++ b/libs/audiographer/audiographer/type_utils.h @@ -16,11 +16,11 @@ class TypeUtilsBase protected: template<typename T, bool b> - static void do_zero_fill(T * buffer, nframes_t frames, const boost::integral_constant<bool, b>&) + static void do_zero_fill(T * buffer, framecnt_t frames, const boost::integral_constant<bool, b>&) { std::uninitialized_fill_n (buffer, frames, T()); } template<typename T> - static void do_zero_fill(T * buffer, nframes_t frames, const boost::true_type&) + static void do_zero_fill(T * buffer, framecnt_t frames, const boost::true_type&) { memset (buffer, 0, frames * sizeof(T)); } }; @@ -39,21 +39,21 @@ class TypeUtils : private TypeUtilsBase * if T is not a floating point or signed integer type * \n RT safe */ - inline static void zero_fill (T * buffer, nframes_t frames) + inline static void zero_fill (T * buffer, framecnt_t frames) { do_zero_fill(buffer, frames, zero_fillable()); } /** Copies \a frames frames of data from \a source to \a destination * The source and destination may NOT overlap. * \n RT safe */ - inline static void copy (T const * source, T * destination, nframes_t frames) + inline static void copy (T const * source, T * destination, framecnt_t frames) { std::uninitialized_copy (source, &source[frames], destination); } /** Moves \a frames frames of data from \a source to \a destination * The source and destination may overlap in any way. * \n RT safe */ - inline static void move (T const * source, T * destination, nframes_t frames) + inline static void move (T const * source, T * destination, framecnt_t frames) { if (destination < source) { std::copy (source, &source[frames], destination); diff --git a/libs/audiographer/audiographer/types.h b/libs/audiographer/audiographer/types.h index 558bab302f..ae98cde7bd 100644 --- a/libs/audiographer/audiographer/types.h +++ b/libs/audiographer/audiographer/types.h @@ -5,11 +5,13 @@ namespace AudioGrapher { -typedef int64_t nframes_t; +/* XXX: copied from libardour */ +typedef int64_t framecnt_t; + typedef uint8_t ChannelCount; typedef float DefaultSampleType; } // namespace -#endif // AUDIOGRAPHER_TYPES_H
\ No newline at end of file +#endif // AUDIOGRAPHER_TYPES_H |