diff options
author | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
---|---|---|
committer | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
commit | 830911f6f9451d83a58043b3f9084d3caa164b7b (patch) | |
tree | f4ca4e3d86b51d66e7cecfb6b370cc4eb553e2d7 /libs/audiographer/audiographer/general/sample_format_converter.h | |
parent | 44f4b84551d36ef4103d09452768f5ba53e0002c (diff) |
Fix export, which has been broken since the boost::signals2 changes. Also update Audiographer, bacause of its incomplete sndfile handling. Audiographer is equal to revision 74
git-svn-id: svn://localhost/ardour2/branches/3.0@6760 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer/general/sample_format_converter.h')
-rw-r--r-- | libs/audiographer/audiographer/general/sample_format_converter.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libs/audiographer/audiographer/general/sample_format_converter.h b/libs/audiographer/audiographer/general/sample_format_converter.h new file mode 100644 index 0000000000..8dda57c4cc --- /dev/null +++ b/libs/audiographer/audiographer/general/sample_format_converter.h @@ -0,0 +1,70 @@ +#ifndef AUDIOGRAPHER_SAMPLE_FORMAT_CONVERTER_H +#define AUDIOGRAPHER_SAMPLE_FORMAT_CONVERTER_H + +#include "audiographer/sink.h" +#include "audiographer/utils/listed_source.h" +#include "private/gdither/gdither_types.h" + +namespace AudioGrapher +{ + +/// Dither types from the gdither library +enum DitherType +{ + D_None = GDitherNone, ///< No didtering + D_Rect = GDitherRect, ///< Rectangular dithering, i.e. white noise + 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 + */ +template <typename TOut> +class SampleFormatConverter + : public Sink<float> + , public ListedSource<TOut> + , public Throwing<> +{ + public: + /** Constructor + * \param channels number of channels in stream + */ + 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 + * \param data_width data with in bits + * \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); + + /// 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); + + 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_); + + ChannelCount channels; + GDither dither; + nframes_t data_out_size; + TOut * data_out; + + bool clip_floats; + +}; + +} // namespace + +#endif // AUDIOGRAPHER_SAMPLE_FORMAT_CONVERTER_H |