summaryrefslogtreecommitdiff
path: root/libs/audiographer/audiographer/routines.h
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2010-03-15 19:11:48 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2010-03-15 19:11:48 +0000
commit830911f6f9451d83a58043b3f9084d3caa164b7b (patch)
treef4ca4e3d86b51d66e7cecfb6b370cc4eb553e2d7 /libs/audiographer/audiographer/routines.h
parent44f4b84551d36ef4103d09452768f5ba53e0002c (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/routines.h')
-rw-r--r--libs/audiographer/audiographer/routines.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/libs/audiographer/audiographer/routines.h b/libs/audiographer/audiographer/routines.h
index fd077e1b3f..b3b7f0921b 100644
--- a/libs/audiographer/audiographer/routines.h
+++ b/libs/audiographer/audiographer/routines.h
@@ -5,43 +5,57 @@
#include <cmath>
-#define routines_nframes_t uint32_t
-
namespace AudioGrapher
{
+/// Allows overriding some routines with more efficient ones.
class Routines
{
public:
- typedef float (*compute_peak_t) (float const *, routines_nframes_t, float);
- typedef void (*apply_gain_to_buffer_t) (float *, routines_nframes_t, float);
+ 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; }
- static inline float compute_peak (float const * data, routines_nframes_t frames, float current_peak)
+ /** Computes peak in float buffer
+ * \n RT safe
+ * \param data buffer from which the peak is computed
+ * \param frames length of the portion of \a buffer that is checked
+ * \param current_peak current peak of buffer, if calculated in several passes
+ * \return maximum of values in [\a data, \a data + \a frames) and \a current_peak
+ */
+ static inline float compute_peak (float const * data, uint_type frames, float current_peak)
{
return (*_compute_peak) (data, frames, current_peak);
}
- static inline void apply_gain_to_buffer (float * data, routines_nframes_t frames, float gain)
+ /** Applies constant gain to buffer
+ * \n RT safe
+ * \param data data to which the gain is applied
+ * \param frames length of data
+ * \param gain gain that is applied
+ */
+ static inline void apply_gain_to_buffer (float * data, uint_type frames, float gain)
{
(*_apply_gain_to_buffer) (data, frames, gain);
}
private:
- static inline float default_compute_peak (float const * data, routines_nframes_t frames, float current_peak)
+ static inline float default_compute_peak (float const * data, uint_type frames, float current_peak)
{
- for (routines_nframes_t i = 0; i < frames; ++i) {
+ for (uint_type i = 0; i < frames; ++i) {
float abs = std::fabs(data[i]);
if (abs > current_peak) { current_peak = abs; }
}
return current_peak;
}
- static inline void default_apply_gain_to_buffer (float * data, routines_nframes_t frames, float gain)
+ static inline void default_apply_gain_to_buffer (float * data, uint_type frames, float gain)
{
- for (routines_nframes_t i = 0; i < frames; ++i) {
+ for (uint_type i = 0; i < frames; ++i) {
data[i] *= gain;
}
}
@@ -52,6 +66,4 @@ class Routines
} // namespace
-#undef routines_nframes_t
-
#endif // AUDIOGRAPHER_ROUTINES_H