diff options
Diffstat (limited to 'libs/audiographer/audiographer')
24 files changed, 185 insertions, 185 deletions
diff --git a/libs/audiographer/audiographer/broadcast_info.h b/libs/audiographer/audiographer/broadcast_info.h index dd776d17af..82641e6c00 100644 --- a/libs/audiographer/audiographer/broadcast_info.h +++ b/libs/audiographer/audiographer/broadcast_info.h @@ -33,7 +33,7 @@ namespace AudioGrapher { -class SndfileHandle; +class SndfileHandle; class LIBAUDIOGRAPHER_API BroadcastInfo { diff --git a/libs/audiographer/audiographer/debug_utils.h b/libs/audiographer/audiographer/debug_utils.h index a8c63e85b6..410567d51b 100644 --- a/libs/audiographer/audiographer/debug_utils.h +++ b/libs/audiographer/audiographer/debug_utils.h @@ -34,7 +34,7 @@ struct LIBAUDIOGRAPHER_API DebugUtils #endif return typeid(obj).name(); } - + /// Returns name of ProcessContext::Flag static std::string process_context_flag_name (FlagField::Flag flag); }; diff --git a/libs/audiographer/audiographer/flag_debuggable.h b/libs/audiographer/audiographer/flag_debuggable.h index 7ff6a79ed1..f5d4fbf6ed 100644 --- a/libs/audiographer/audiographer/flag_debuggable.h +++ b/libs/audiographer/audiographer/flag_debuggable.h @@ -26,14 +26,14 @@ class /*LIBAUDIOGRAPHER_API*/ FlagDebuggable : public Debuggable<L> { flags.set (flag); } - + /// Prints debug output if \a context contains flags that are not supported by this class template<typename SelfType, typename ContextType> void check_flags (SelfType & self, ProcessContext<ContextType> context) { if (!Debuggable<L>::debug_level (DebugFlags)) { return; } FlagField unsupported = flags.unsupported_flags_of (context.flags()); - + for (FlagField::iterator it = unsupported.begin(); it != unsupported.end(); ++it) { Debuggable<L>::debug_stream() << boost::str (boost::format ("%1% does not support flag %2%") diff --git a/libs/audiographer/audiographer/flag_field.h b/libs/audiographer/audiographer/flag_field.h index 34ab5efdd6..989478f808 100644 --- a/libs/audiographer/audiographer/flag_field.h +++ b/libs/audiographer/audiographer/flag_field.h @@ -20,10 +20,10 @@ class LIBAUDIOGRAPHER_API FlagField , boost::equality_comparable<FlagField> { public: - + typedef uint8_t Flag; typedef uint32_t storage_type; - + /// Bi-directional iterator for flag set. Iterates over flags that are set in this field. class iterator : public std::iterator<std::bidirectional_iterator_tag, Flag> @@ -34,10 +34,10 @@ class LIBAUDIOGRAPHER_API FlagField public: iterator (FlagField const & parent, Flag position) : parent (parent), position (position) {} iterator (iterator const & other) : parent (other.parent), position (other.position) {} - + value_type operator*() const { return position; } value_type const * operator->() const { return &position; } - + iterator & operator++() { do { @@ -46,7 +46,7 @@ class LIBAUDIOGRAPHER_API FlagField return *this; } iterator operator++(int) { iterator copy (*this); ++(*this); return copy; } - + iterator & operator--() { do { @@ -55,19 +55,19 @@ class LIBAUDIOGRAPHER_API FlagField return *this; } iterator operator--(int) { iterator copy (*this); --(*this); return copy; } - + bool operator< (iterator const & other) const { return position < other.position; } - + private: FlagField const & parent; Flag position; }; - + public: - + FlagField() : _flags (0) {} FlagField(FlagField const & other) : _flags (other._flags) {} - + inline bool has (Flag flag) const { return _flags & (1 << flag); } inline storage_type flags () const { return _flags; } inline operator bool() const { return _flags; } @@ -77,10 +77,10 @@ class LIBAUDIOGRAPHER_API FlagField /// Returns the flags in \a other that are not set in this field inline FlagField unsupported_flags_of (FlagField const & other) const { return ~(_flags | ~other._flags); } - + /// Set all flags that are set in \a other inline FlagField & operator+= (FlagField const & other) { _flags |= other._flags; return *this; } - + /** Checks whether this field has all the flags set that are set in \a other * NOTE: Can NOT be used for strict weak ordering! * \return \a true if \a other has flags set that this field does not @@ -99,7 +99,7 @@ class LIBAUDIOGRAPHER_API FlagField private: FlagField(storage_type flags) : _flags (flags) {} static Flag max() { return CHAR_BIT * sizeof (storage_type) + 1; } - + storage_type _flags; }; diff --git a/libs/audiographer/audiographer/general/chunker.h b/libs/audiographer/audiographer/general/chunker.h index d61c68dee4..466a333655 100644 --- a/libs/audiographer/audiographer/general/chunker.h +++ b/libs/audiographer/audiographer/general/chunker.h @@ -28,12 +28,12 @@ class /*LIBAUDIOGRAPHER_API*/ Chunker buffer = new T[chunk_size]; add_supported_flag (ProcessContext<T>::EndOfInput); } - + ~Chunker() { delete [] buffer; } - + /** Outputs data in \a context in chunks with the size specified in the constructor. * Note that some calls might not produce any output, while others may produce several. * \n RT safe @@ -41,15 +41,15 @@ class /*LIBAUDIOGRAPHER_API*/ Chunker void process (ProcessContext<T> const & context) { check_flags (*this, context); - + framecnt_t frames_left = context.frames(); framecnt_t input_position = 0; - + while (position + frames_left >= chunk_size) { // Copy from context to buffer framecnt_t const frames_to_copy = chunk_size - position; TypeUtils<T>::copy (&context.data()[input_position], &buffer[position], frames_to_copy); - + // Update counters position = 0; input_position += frames_to_copy; @@ -60,25 +60,25 @@ class /*LIBAUDIOGRAPHER_API*/ Chunker if (frames_left) { c_out.remove_flag(ProcessContext<T>::EndOfInput); } ListedSource<T>::output (c_out); } - + if (frames_left) { // Copy the rest of the data TypeUtils<T>::copy (&context.data()[input_position], &buffer[position], frames_left); position += frames_left; } - + if (context.has_flag (ProcessContext<T>::EndOfInput) && position > 0) { ProcessContext<T> c_out (context, buffer, position); ListedSource<T>::output (c_out); } } using Sink<T>::process; - + private: framecnt_t chunk_size; framecnt_t position; T * buffer; - + }; } // namespace diff --git a/libs/audiographer/audiographer/general/deinterleaver.h b/libs/audiographer/audiographer/general/deinterleaver.h index fac38912d7..63b6c95589 100644 --- a/libs/audiographer/audiographer/general/deinterleaver.h +++ b/libs/audiographer/audiographer/general/deinterleaver.h @@ -21,7 +21,7 @@ class /*LIBAUDIOGRAPHER_API*/ DeInterleaver { private: typedef boost::shared_ptr<IdentityVertex<T> > OutputPtr; - + public: /// Constructor. \n RT safe DeInterleaver() @@ -29,11 +29,11 @@ class /*LIBAUDIOGRAPHER_API*/ DeInterleaver , max_frames (0) , buffer (0) {} - + ~DeInterleaver() { reset(); } - + 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, framecnt_t max_frames_per_channel) { @@ -41,53 +41,53 @@ class /*LIBAUDIOGRAPHER_API*/ DeInterleaver channels = num_channels; max_frames = max_frames_per_channel; buffer = new T[max_frames]; - + for (unsigned int i = 0; i < channels; ++i) { outputs.push_back (OutputPtr (new IdentityVertex<T>)); } } - + /// Returns an output indexed by \a channel \n RT safe SourcePtr output (unsigned int channel) { if (throw_level (ThrowObject) && channel >= channels) { throw Exception (*this, "channel out of range"); } - + return outputs[channel]; } - + /// Deinterleaves data and outputs it to the outputs. \n RT safe void process (ProcessContext<T> const & c) { framecnt_t frames = c.frames(); T const * data = c.data(); - + 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()"); } - + if (throw_level (ThrowProcess) && frames_per_channel > max_frames) { throw Exception (*this, "too many frames given to process()"); } - + unsigned int channel = 0; for (typename std::vector<OutputPtr>::iterator it = outputs.begin(); it != outputs.end(); ++it, ++channel) { if (!*it) { continue; } - + for (unsigned int i = 0; i < frames_per_channel; ++i) { buffer[i] = data[channel + (channels * i)]; } - + ProcessContext<T> c_out (c, buffer, frames_per_channel, 1); (*it)->process (c_out); } } - + using Sink<T>::process; - + private: void reset () @@ -98,7 +98,7 @@ class /*LIBAUDIOGRAPHER_API*/ DeInterleaver channels = 0; max_frames = 0; } - + std::vector<OutputPtr> outputs; unsigned int channels; framecnt_t max_frames; diff --git a/libs/audiographer/audiographer/general/interleaver.h b/libs/audiographer/audiographer/general/interleaver.h index 2bc62e5443..c1b5e92cfe 100644 --- a/libs/audiographer/audiographer/general/interleaver.h +++ b/libs/audiographer/audiographer/general/interleaver.h @@ -21,30 +21,30 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver , public Throwing<> { public: - + /// Constructs an interleaver \n RT safe Interleaver() : channels (0) , max_frames (0) , buffer (0) {} - + ~Interleaver() { reset(); } - + /// Inits the interleaver. Must be called before using. \n Not RT safe void init (unsigned int num_channels, framecnt_t max_frames_per_channel) { reset(); channels = num_channels; max_frames = max_frames_per_channel; - + buffer = new T[channels * max_frames]; - + for (unsigned int i = 0; i < channels; ++i) { inputs.push_back (InputPtr (new Input (*this, i))); } } - + /** Returns the input indexed by \a channel \n RT safe * \n The \a process function of returned Sinks are also RT Safe */ @@ -53,10 +53,10 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver if (throw_level (ThrowObject) && channel >= channels) { throw Exception (*this, "Channel out of range"); } - + return boost::static_pointer_cast<Sink<T> > (inputs[channel]); } - + private: class Input : public Sink<T> @@ -64,7 +64,7 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver public: Input (Interleaver & parent, unsigned int channel) : frames_written (0), parent (parent), channel (channel) {} - + void process (ProcessContext<T> const & c) { if (parent.throw_level (ThrowProcess) && c.channels() > 1) { @@ -76,18 +76,18 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver frames_written = c.frames(); parent.write_channel (c, channel); } - + using Sink<T>::process; - + framecnt_t frames() { return frames_written; } void reset() { frames_written = 0; } - + private: framecnt_t frames_written; Interleaver & parent; unsigned int channel; }; - + void reset () { inputs.clear(); @@ -96,7 +96,7 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver channels = 0; max_frames = 0; } - + void reset_channels () { for (unsigned int i = 0; i < channels; ++i) { @@ -104,18 +104,18 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver } } - + void write_channel (ProcessContext<T> const & c, unsigned int channel) { if (throw_level (ThrowProcess) && c.frames() > max_frames) { reset_channels(); throw Exception (*this, "Too many frames given to an input"); } - + for (unsigned int i = 0; i < c.frames(); ++i) { buffer[channel + (channels * i)] = c.data()[i]; } - + framecnt_t const ready_frames = ready_to_output(); if (ready_frames) { ProcessContext<T> c_out (c, buffer, ready_frames, channels); @@ -142,7 +142,7 @@ class /*LIBAUDIOGRAPHER_API*/ Interleaver typedef boost::shared_ptr<Input> InputPtr; std::vector<InputPtr> inputs; - + unsigned int channels; framecnt_t max_frames; T * buffer; diff --git a/libs/audiographer/audiographer/general/normalizer.h b/libs/audiographer/audiographer/general/normalizer.h index e95f0e3852..025131022e 100644 --- a/libs/audiographer/audiographer/general/normalizer.h +++ b/libs/audiographer/audiographer/general/normalizer.h @@ -32,7 +32,7 @@ public: /// Process a const ProcessContext \see alloc_buffer() \n RT safe void process (ProcessContext<float> const & c); - + /// Process a non-const ProcsesContext in-place \n RT safe void process (ProcessContext<float> & c); @@ -40,7 +40,7 @@ private: bool enabled; float target; float gain; - + float * buffer; framecnt_t buffer_size; }; diff --git a/libs/audiographer/audiographer/general/peak_reader.h b/libs/audiographer/audiographer/general/peak_reader.h index dd5d65491c..8bf0faa792 100644 --- a/libs/audiographer/audiographer/general/peak_reader.h +++ b/libs/audiographer/audiographer/general/peak_reader.h @@ -15,10 +15,10 @@ class /*LIBAUDIOGRAPHER_API*/ PeakReader : public ListedSource<float>, public Si public: /// Constructor \n RT safe PeakReader() : peak (0.0) {} - + /// Returns the highest absolute of the values found so far. \n RT safe float get_peak() { return peak; } - + /// Resets the peak to 0 \n RT safe void reset() { peak = 0.0; } @@ -28,9 +28,9 @@ class /*LIBAUDIOGRAPHER_API*/ PeakReader : public ListedSource<float>, public Si peak = Routines::compute_peak (c.data(), c.frames(), peak); ListedSource<float>::output(c); } - + using Sink<float>::process; - + private: float peak; }; diff --git a/libs/audiographer/audiographer/general/sample_format_converter.h b/libs/audiographer/audiographer/general/sample_format_converter.h index af30ac1605..96dd6aa72a 100644 --- a/libs/audiographer/audiographer/general/sample_format_converter.h +++ b/libs/audiographer/audiographer/general/sample_format_converter.h @@ -17,7 +17,7 @@ enum /*LIBAUDIOGRAPHER_API*/ DitherType D_Tri = GDitherTri, ///< Triangular dithering D_Shaped = GDitherShaped ///< Actually noise shaping, only works for 46kHzish signals }; - + /** Sample format converter that does dithering. * This class can only convert floats to either \a float, \a int32_t, \a int16_t, or \a uint8_t */ @@ -33,7 +33,7 @@ class LIBAUDIOGRAPHER_API SampleFormatConverter */ SampleFormatConverter (ChannelCount channels); ~SampleFormatConverter (); - + /** Initialize and allocate buffers for processing. * \param max_frames maximum number of frames that is allowed to be used in calls to \a process() * \param type dither type from \a DitherType @@ -45,10 +45,10 @@ class LIBAUDIOGRAPHER_API SampleFormatConverter /// 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; } - + /// Processes data without modifying it void process (ProcessContext<float> const & c_in); - + /// This version is only different in the case when \a TOut = float, and float clipping is on. void process (ProcessContext<float> & c_in); diff --git a/libs/audiographer/audiographer/general/silence_trimmer.h b/libs/audiographer/audiographer/general/silence_trimmer.h index a715feb0c8..7e8d3c485c 100644 --- a/libs/audiographer/audiographer/general/silence_trimmer.h +++ b/libs/audiographer/audiographer/general/silence_trimmer.h @@ -47,14 +47,14 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer throw Exception (*this, "Silence trimmer constructor and reset() must be called with a non-zero parameter!"); } - + if (silence_buffer_size != silence_buffer_size_) { silence_buffer_size = silence_buffer_size_; delete [] silence_buffer; silence_buffer = new T[silence_buffer_size]; TypeUtils<T>::zero_fill (silence_buffer, silence_buffer_size); } - + in_beginning = true; in_end = false; trim_beginning = false; @@ -64,7 +64,7 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer add_to_beginning = 0; add_to_end = 0; } - + /** Tells that \a frames_per_channel frames of silence per channel should be added to beginning * Needs to be called before starting processing. * \n RT safe @@ -76,7 +76,7 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer } add_to_beginning = frames_per_channel; } - + /** Tells that \a frames_per_channel frames of silence per channel should be added to end * Needs to be called before end is reached. * \n RT safe @@ -88,7 +88,7 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer } add_to_end = frames_per_channel; } - + /** Tells whether ot nor silence should be trimmed from the beginning * Has to be called before starting processing. * \n RT safe @@ -100,7 +100,7 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer } trim_beginning = yn; } - + /** Tells whether ot nor silence should be trimmed from the end * Has to be called before the is reached. * \n RT safe @@ -124,9 +124,9 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer debug_stream () << DebugUtils::demangled_name (*this) << "::process()" << std::endl; } - + check_flags (*this, c); - + if (throw_level (ThrowStrict) && in_end) { throw Exception(*this, "process() after reaching end of input"); } @@ -134,27 +134,27 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer // If adding to end, delay end of input propagation if (add_to_end) { c.remove_flag(ProcessContext<T>::EndOfInput); } - + framecnt_t frame_index = 0; - + if (in_beginning) { - + bool has_data = true; - + // only check silence if doing either of these // This will set both has_data and frame_index if (add_to_beginning || trim_beginning) { has_data = find_first_non_zero_sample (c, frame_index); } - + // Added silence if there is silence to add if (add_to_beginning) { - + if (debug_level (DebugVerbose)) { debug_stream () << DebugUtils::demangled_name (*this) << " adding to beginning" << std::endl; } - + ConstProcessContext<T> c_copy (c); if (has_data) { // There will be more output, so remove flag c_copy().remove_flag (ProcessContext<T>::EndOfInput); @@ -162,54 +162,54 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer add_to_beginning *= c.channels(); output_silence_frames (c_copy, add_to_beginning); } - + // If we are not trimming the beginning, output everything // Then has_data = true and frame_index = 0 // Otherwise these reflect the silence state if (has_data) { - + if (debug_level (DebugVerbose)) { debug_stream () << DebugUtils::demangled_name (*this) << " outputting whole frame to beginning" << std::endl; } - + in_beginning = false; ConstProcessContext<T> c_out (c, &c.data()[frame_index], c.frames() - frame_index); ListedSource<T>::output (c_out); } - + } else if (trim_end) { // Only check zero samples if trimming end - + if (find_first_non_zero_sample (c, frame_index)) { - + if (debug_level (DebugVerbose)) { debug_stream () << DebugUtils::demangled_name (*this) << " flushing intermediate silence and outputting frame" << std::endl; } - + // context contains non-zero data output_silence_frames (c, silence_frames); // flush intermediate silence ListedSource<T>::output (c); // output rest of data } else { // whole context is zero - + if (debug_level (DebugVerbose)) { debug_stream () << DebugUtils::demangled_name (*this) << " no, output, adding frames to silence count" << std::endl; } - + silence_frames += c.frames(); } - + } else { // no need to do anything special - + if (debug_level (DebugVerbose)) { debug_stream () << DebugUtils::demangled_name (*this) << " outputting whole frame in middle" << std::endl; } - + ListedSource<T>::output (c); } - + // Finally, if in end, add silence to end if (in_end && add_to_end) { c.set_flag (ProcessContext<T>::EndOfInput); @@ -218,7 +218,7 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer debug_stream () << DebugUtils::demangled_name (*this) << " adding to end" << std::endl; } - + add_to_end *= c.channels(); output_silence_frames (c, add_to_end, true); } @@ -240,22 +240,22 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer } return 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) { framecnt_t frames = std::min (silence_buffer_size, total_frames); if (max_output_frames) { frames = std::min (frames, max_output_frames); } frames -= frames % c.channels(); - + total_frames -= frames; ConstProcessContext<T> c_out (c, silence_buffer, frames); - + // boolean commentation :) bool const no_more_silence_will_be_added = adding_to_end || (add_to_end == 0); bool const is_last_frame_output_in_this_function = (total_frames == 0); @@ -272,16 +272,16 @@ class /*LIBAUDIOGRAPHER_API*/ SilenceTrimmer bool in_beginning; bool in_end; - + bool trim_beginning; bool trim_end; - + framecnt_t silence_frames; framecnt_t max_output_frames; - + framecnt_t add_to_beginning; framecnt_t add_to_end; - + framecnt_t silence_buffer_size; T * silence_buffer; }; diff --git a/libs/audiographer/audiographer/general/sr_converter.h b/libs/audiographer/audiographer/general/sr_converter.h index 0cbe3bd294..a2e94d9bc0 100644 --- a/libs/audiographer/audiographer/general/sr_converter.h +++ b/libs/audiographer/audiographer/general/sr_converter.h @@ -27,10 +27,10 @@ class LIBAUDIOGRAPHER_API SampleRateConverter /// Init converter \n Not RT safe 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 framecnt_t allocate_buffers (framecnt_t max_frames); - + /** Does sample rate conversion. * Note that outpt size may vary a lot. * May or may not output several contexts of data. @@ -48,7 +48,7 @@ class LIBAUDIOGRAPHER_API SampleRateConverter bool active; uint32_t channels; framecnt_t max_frames_in; - + float * leftover_data; framecnt_t leftover_frames; framecnt_t max_leftover_frames; diff --git a/libs/audiographer/audiographer/general/threader.h b/libs/audiographer/audiographer/general/threader.h index e9a953ce44..2ef4099efe 100644 --- a/libs/audiographer/audiographer/general/threader.h +++ b/libs/audiographer/audiographer/general/threader.h @@ -39,7 +39,7 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : public Source<T>, public Sink<T> typedef std::vector<typename Source<T>::SinkPtr> OutputVec; public: - + /** Constructor * \n RT safe * \param thread_pool a thread pool from which all tasks are scheduled @@ -50,39 +50,39 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : public Source<T>, public Sink<T> , readers (0) , wait_timeout (wait_timeout_milliseconds) { } - + virtual ~Threader () {} - + /// Adds output \n RT safe void add_output (typename Source<T>::SinkPtr output) { outputs.push_back (output); } - + /// Clears outputs \n RT safe void clear_outputs () { outputs.clear (); } - + /// Removes a specific output \n RT safe void remove_output (typename Source<T>::SinkPtr output) { typename OutputVec::iterator new_end = std::remove(outputs.begin(), outputs.end(), output); outputs.erase (new_end, outputs.end()); } - + /// Processes context concurrently by scheduling each output separately to the given thread pool void process (ProcessContext<T> const & c) { wait_mutex.lock(); - + exception.reset(); - + unsigned int outs = outputs.size(); g_atomic_int_add (&readers, outs); for (unsigned int i = 0; i < outs; ++i) { thread_pool.push (sigc::bind (sigc::mem_fun (this, &Threader::process_output), c, i)); } - + wait(); } - + using Sink<T>::process; - + private: void wait() @@ -93,12 +93,12 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : public Source<T>, public Sink<T> } wait_mutex.unlock(); - + if (exception) { throw *exception; } } - + void process_output(ProcessContext<T> const & c, unsigned int output) { try { @@ -109,7 +109,7 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : public Source<T>, public Sink<T> if(!exception) { exception.reset (new ThreaderException (*this, e)); } exception_mutex.unlock(); } - + if (g_atomic_int_dec_and_test (&readers)) { wait_cond.signal(); } @@ -122,7 +122,7 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : public Source<T>, public Sink<T> Glib::Threads::Cond wait_cond; gint readers; long wait_timeout; - + Glib::Threads::Mutex exception_mutex; boost::shared_ptr<ThreaderException> exception; diff --git a/libs/audiographer/audiographer/process_context.h b/libs/audiographer/audiographer/process_context.h index 36abd4fba0..16e637b85c 100644 --- a/libs/audiographer/audiographer/process_context.h +++ b/libs/audiographer/audiographer/process_context.h @@ -45,30 +45,30 @@ public: ProcessContext (T * data, framecnt_t frames, ChannelCount channels) : _data (data), _frames (frames), _channels (channels) { validate_data(); } - + /// Normal copy constructor ProcessContext (ProcessContext<T> const & other) : Throwing<throwLevel>(), _data (other._data), _frames (other._frames), _channels (other._channels), _flags (other._flags) { /* No need to validate data */ } - + /// "Copy constructor" with unique data, frame and channel count, but copies flags template<typename Y> ProcessContext (ProcessContext<Y> const & other, T * data, framecnt_t frames, ChannelCount channels) : Throwing<throwLevel>(), _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, framecnt_t frames) : Throwing<throwLevel>(), _data (data), _frames (frames), _channels (other.channels()), _flags (other.flags()) { validate_data(); } - + /// "Copy constructor" with unique data, but copies frame and channel count + flags template<typename Y> ProcessContext (ProcessContext<Y> const & other, T * data) : Throwing<throwLevel>(), _data (data), _frames (other.frames()), _channels (other.channels()), _flags (other.flags()) { /* No need to validate data */ } - + /// Make new Context out of the beginning of this context ProcessContext beginning (framecnt_t frames) { @@ -78,39 +78,39 @@ public: % DebugUtils::demangled_name (*this) % frames % _frames)); } validate_data (); - + return ProcessContext (*this, _data, frames); } - + virtual ~ProcessContext () {} - + /// \a data points to the array of data to process inline T const * data() const { return _data; } inline T * data() { return _data; } - + /// \a frames tells how many frames the array pointed by data contains 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 */ inline ChannelCount const & channels() const { return _channels; } - + /// Returns the amount of frames per channel inline framecnt_t frames_per_channel() const { return _frames / _channels; } /* Flags */ - + inline bool has_flag (Flag flag) const { return _flags.has (flag); } inline void set_flag (Flag flag) const { _flags.set (flag); } inline void remove_flag (Flag flag) const { _flags.remove (flag); } inline FlagField const & flags () const { return _flags; } - + protected: T * const _data; framecnt_t _frames; ChannelCount _channels; - + mutable FlagField _flags; private: @@ -132,32 +132,32 @@ public: /// Allocates uninitialized memory AllocatingProcessContext (framecnt_t frames, ChannelCount channels) : ProcessContext<T> (new T[frames], frames, channels) {} - + /// Allocates and copies data from raw buffer AllocatingProcessContext (T const * data, framecnt_t frames, ChannelCount channels) : ProcessContext<T> (new T[frames], frames, channels) { TypeUtils<float>::copy (data, ProcessContext<T>::_data, frames); } - + /// Copy constructor, copies data from other ProcessContext AllocatingProcessContext (ProcessContext<T> const & other) : ProcessContext<T> (other, new T[other._frames]) { TypeUtils<float>::copy (ProcessContext<T>::_data, other._data, other._frames); } - + /// "Copy constructor" with uninitialized data, unique frame and channel count, but copies flags template<typename Y> 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, framecnt_t frames) : ProcessContext<T> (other, new T[frames], frames, other.channels()) {} - + /// "Copy constructor" uninitialized data, that copies frame and channel count + flags template<typename Y> AllocatingProcessContext (ProcessContext<Y> const & other) : ProcessContext<T> (other, new T[other._frames]) {} - + ~AllocatingProcessContext () { delete [] ProcessContext<T>::_data; } }; @@ -169,21 +169,21 @@ class /*LIBAUDIOGRAPHER_API*/ ConstProcessContext /// Basic constructor with data, frame and channel count ConstProcessContext (T const * data, framecnt_t frames, ChannelCount channels) : context (const_cast<T *>(data), frames, channels) {} - + /// Copy constructor from const ProcessContext ConstProcessContext (ProcessContext<T> const & other) : context (const_cast<ProcessContext<T> &> (other)) {} - + /// "Copy constructor", with unique data, frame and channel count, but copies flags template<typename ProcessContext> 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, framecnt_t frames) : context (other, const_cast<T *>(data), frames) {} - + /// "Copy constructor", with unique data, but copies frame and channel count + flags template<typename ProcessContext> ConstProcessContext (ProcessContext const & other, T const * data) diff --git a/libs/audiographer/audiographer/routines.h b/libs/audiographer/audiographer/routines.h index 4ab3bc5fb5..d78fa602b6 100644 --- a/libs/audiographer/audiographer/routines.h +++ b/libs/audiographer/audiographer/routines.h @@ -15,13 +15,13 @@ class LIBAUDIOGRAPHER_API Routines { public: typedef uint32_t uint_type; - + typedef float (*compute_peak_t) (float const *, uint_type, float); typedef void (*apply_gain_to_buffer_t) (float *, uint_type, float); - + static void override_compute_peak (compute_peak_t func) { _compute_peak = func; } static void override_apply_gain_to_buffer (apply_gain_to_buffer_t func) { _apply_gain_to_buffer = func; } - + /** Computes peak in float buffer * \n RT safe * \param data buffer from which the peak is computed @@ -61,7 +61,7 @@ class LIBAUDIOGRAPHER_API Routines data[i] *= gain; } } - + static compute_peak_t _compute_peak; static apply_gain_to_buffer_t _apply_gain_to_buffer; }; diff --git a/libs/audiographer/audiographer/sink.h b/libs/audiographer/audiographer/sink.h index b1e5605206..da9e7350ee 100644 --- a/libs/audiographer/audiographer/sink.h +++ b/libs/audiographer/audiographer/sink.h @@ -17,13 +17,13 @@ template <typename T> class /*LIBAUDIOGRAPHER_API*/ Sink { public: virtual ~Sink () {} - + /** Process given data. * The data can not be modified, so in-place processing is not allowed. * At least this function must be implemented by deriving classes */ virtual void process (ProcessContext<T> const & context) = 0; - + /** Process given data * Data may be modified, so in place processing is allowed. * The default implementation calls the non-modifying version, diff --git a/libs/audiographer/audiographer/sndfile/sndfile.h b/libs/audiographer/audiographer/sndfile/sndfile.h index 939e5f8a2c..c48a0331ab 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile.h +++ b/libs/audiographer/audiographer/sndfile/sndfile.h @@ -14,15 +14,15 @@ template<typename T = DefaultSampleType> 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, framecnt_t samplerate = 0) : SndfileHandle (filename, mode, format, channels, samplerate) {} - + Sndfile (Sndfile const & other) : SndfileHandle (other) {} using SndfileHandle::operator=; - + }; } // namespace diff --git a/libs/audiographer/audiographer/sndfile/sndfile_base.h b/libs/audiographer/audiographer/sndfile/sndfile_base.h index 02d5a7f6ea..67a34d484e 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_base.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_base.h @@ -18,7 +18,7 @@ class SndfileBase : public virtual AudioGrapher::SndfileHandle Write = SFM_WRITE, ReadWrite = SFM_RDWR }; - + protected: SndfileBase () {} }; diff --git a/libs/audiographer/audiographer/sndfile/sndfile_reader.h b/libs/audiographer/audiographer/sndfile/sndfile_reader.h index aa3c0cc899..ea27470d77 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_reader.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_reader.h @@ -18,13 +18,13 @@ class SndfileReader , public Throwing<> { public: - + SndfileReader (std::string const & path) : SndfileHandle (path) {} virtual ~SndfileReader () {} SndfileReader (SndfileReader const & other) : SndfileHandle (other) {} using SndfileHandle::operator=; - + /** Read data into buffer in \a context, only the data is modified (not frame count) * Note that the data read is output to the outputs, as well as read into the context * \return number of frames read @@ -36,17 +36,17 @@ class SndfileReader ("Wrong number of channels given to process(), %1% instead of %2%") % context.channels() % channels())); } - + framecnt_t const frames_read = SndfileHandle::read (context.data(), context.frames()); ProcessContext<T> c_out = context.beginning (frames_read); - + if (frames_read < context.frames()) { c_out.set_flag (ProcessContext<T>::EndOfInput); } this->output (c_out); return frames_read; } - + protected: /// SndfileHandle has to be constructed directly by deriving classes SndfileReader () {} diff --git a/libs/audiographer/audiographer/sndfile/sndfile_writer.h b/libs/audiographer/audiographer/sndfile/sndfile_writer.h index 984ec01d41..57ad968dc5 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_writer.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_writer.h @@ -37,9 +37,9 @@ class SndfileWriter broadcast_info->write_to_file (this); } } - + virtual ~SndfileWriter () {} - + SndfileWriter (SndfileWriter const & other) : SndfileHandle (other) { @@ -50,18 +50,18 @@ class SndfileWriter framecnt_t get_frames_written() const { return frames_written; } void reset_frames_written_count() { frames_written = 0; } - + /// Writes data to file void process (ProcessContext<T> const & c) { check_flags (*this, c); - + if (throw_level (ThrowStrict) && c.channels() != channels()) { throw Exception (*this, boost::str (boost::format ("Wrong number of channels given to process(), %1% instead of %2%") % c.channels() % channels())); } - + framecnt_t const written = write (c.data(), c.frames()); frames_written += written; @@ -76,9 +76,9 @@ class SndfileWriter FileWritten (path); } } - + using Sink<T>::process; - + PBD::Signal1<void, std::string> FileWritten; protected: diff --git a/libs/audiographer/audiographer/source.h b/libs/audiographer/audiographer/source.h index 945cb13298..2d80345b9b 100644 --- a/libs/audiographer/audiographer/source.h +++ b/libs/audiographer/audiographer/source.h @@ -19,15 +19,15 @@ class /*LIBAUDIOGRAPHER_API*/ Source { public: virtual ~Source () { } - + typedef boost::shared_ptr<Sink<T> > SinkPtr; - + /// Adds an output to this source. All data generated is forwarded to \a output virtual void add_output (SinkPtr output) = 0; - + /// Removes all outputs added virtual void clear_outputs () = 0; - + /// Removes a specific output from this source virtual void remove_output (SinkPtr output) = 0; }; diff --git a/libs/audiographer/audiographer/type_utils.h b/libs/audiographer/audiographer/type_utils.h index e86fbcc282..4e12937165 100644 --- a/libs/audiographer/audiographer/type_utils.h +++ b/libs/audiographer/audiographer/type_utils.h @@ -17,7 +17,7 @@ namespace AudioGrapher class LIBAUDIOGRAPHER_API TypeUtilsBase { protected: - + template<typename T, 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()); } @@ -32,7 +32,7 @@ template<typename T = DefaultSampleType> class /*LIBAUDIOGRAPHER_API*/ TypeUtils : private TypeUtilsBase { BOOST_STATIC_ASSERT (boost::has_trivial_destructor<T>::value); - + typedef boost::integral_constant<bool, boost::is_floating_point<T>::value || boost::is_signed<T>::value> zero_fillable; @@ -44,14 +44,14 @@ class /*LIBAUDIOGRAPHER_API*/ TypeUtils : private TypeUtilsBase */ 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, 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 diff --git a/libs/audiographer/audiographer/types.h b/libs/audiographer/audiographer/types.h index 4288dce0c6..1ecf6360a0 100644 --- a/libs/audiographer/audiographer/types.h +++ b/libs/audiographer/audiographer/types.h @@ -7,9 +7,9 @@ namespace AudioGrapher { -/* XXX: copied from libardour */ +/* XXX: copied from libardour */ typedef int64_t framecnt_t; - + typedef uint8_t ChannelCount; typedef float DefaultSampleType; diff --git a/libs/audiographer/audiographer/utils/listed_source.h b/libs/audiographer/audiographer/utils/listed_source.h index b9bfbc65f8..7069f13c72 100644 --- a/libs/audiographer/audiographer/utils/listed_source.h +++ b/libs/audiographer/audiographer/utils/listed_source.h @@ -19,11 +19,11 @@ class /*LIBAUDIOGRAPHER_API*/ ListedSource : public Source<T> void add_output (typename Source<T>::SinkPtr output) { outputs.push_back(output); } void clear_outputs () { outputs.clear(); } void remove_output (typename Source<T>::SinkPtr output) { outputs.remove(output); } - + protected: - + typedef std::list<typename Source<T>::SinkPtr> SinkList; - + /// Helper for derived classes void output (ProcessContext<T> const & c) { |