summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/buffer.h15
-rw-r--r--libs/ardour/ardour/mix.h52
-rw-r--r--libs/ardour/ardour/peak.h2
-rw-r--r--libs/ardour/ardour/runtime_functions.h40
-rw-r--r--libs/ardour/ardour/session.h12
5 files changed, 64 insertions, 57 deletions
diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h
index 828eac4d64..6000872bdd 100644
--- a/libs/ardour/ardour/buffer.h
+++ b/libs/ardour/ardour/buffer.h
@@ -24,6 +24,7 @@
#include <iostream>
#include <ardour/types.h>
#include <ardour/data_type.h>
+#include <ardour/runtime_functions.h>
namespace ARDOUR {
@@ -142,21 +143,13 @@ public:
Sample* const dst_raw = _data + offset;
const Sample* const src_raw = src.data(len);
- for (jack_nframes_t n = 0; n < len; ++n) {
- dst_raw[n] += src_raw[n] * gain_coeff;
- }
-
+ mix_buffers_with_gain (dst_raw, src_raw, len, gain_coeff);
+
_silent = ( (src.silent() && _silent) || (_silent && gain_coeff == 0) );
}
void apply_gain(gain_t gain, jack_nframes_t len, jack_nframes_t offset=0) {
- Sample* const buf = _data + offset;
-
- for (jack_nframes_t n = 0; n < len; ++n) {
- buf[n] *= gain;
- }
-
- _silent = (_silent || gain == 0);
+ apply_gain_to_buffer (_data + offset, len, gain);
}
/** Set the data contained by this buffer manually (for setting directly to jack buffer).
diff --git a/libs/ardour/ardour/mix.h b/libs/ardour/ardour/mix.h
index 5555f5437e..67779f0e07 100644
--- a/libs/ardour/ardour/mix.h
+++ b/libs/ardour/ardour/mix.h
@@ -27,53 +27,39 @@
extern "C" {
/* SSE functions */
- float x86_sse_compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current);
-
- void x86_sse_apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain);
-
- void x86_sse_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain);
-
- void x86_sse_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes);
+ float x86_sse_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current);
+ void x86_sse_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain);
+ void x86_sse_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain);
+ void x86_sse_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes);
}
-void x86_sse_find_peaks (ARDOUR::Sample *buf, nframes_t nsamples, float *min, float *max);
+void x86_sse_find_peaks (const ARDOUR::Sample * buf, nframes_t nsamples, float *min, float *max);
/* debug wrappers for SSE functions */
-float debug_compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current);
-
-void debug_apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain);
-
-void debug_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain);
-
-void debug_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes);
+float debug_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current);
+void debug_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain);
+void debug_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain);
+void debug_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes);
#endif
#if defined (__APPLE__)
-float veclib_compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current);
-
-void veclib_find_peaks (ARDOUR::Sample *buf, nframes_t nsamples, float *min, float *max);
-
-void veclib_apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain);
-
-void veclib_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain);
-
-void veclib_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes);
+float veclib_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current);
+void veclib_find_peaks (const ARDOUR::Sample * buf, nframes_t nsamples, float *min, float *max);
+void veclib_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain);
+void veclib_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain);
+void veclib_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes);
#endif
/* non-optimized functions */
-float compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current);
-
-void find_peaks (ARDOUR::Sample *buf, nframes_t nsamples, float *min, float *max);
-
-void apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain);
-
-void mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain);
-
-void mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes);
+float default_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current);
+void default_find_peaks (const ARDOUR::Sample * buf, nframes_t nsamples, float *min, float *max);
+void default_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain);
+void default_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain);
+void default_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes);
#endif /* __ardour_mix_h__ */
diff --git a/libs/ardour/ardour/peak.h b/libs/ardour/ardour/peak.h
index eaeafe0f5d..bbec40eea7 100644
--- a/libs/ardour/ardour/peak.h
+++ b/libs/ardour/ardour/peak.h
@@ -25,7 +25,7 @@
#include <ardour/utils.h>
static inline float
-compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current)
+default_compute_peak (const ARDOUR::Sample * const buf, nframes_t nsamples, float current)
{
for (nframes_t i = 0; i < nsamples; ++i) {
current = f_max (current, fabsf (buf[i]));
diff --git a/libs/ardour/ardour/runtime_functions.h b/libs/ardour/ardour/runtime_functions.h
new file mode 100644
index 0000000000..c1dab4ebc7
--- /dev/null
+++ b/libs/ardour/ardour/runtime_functions.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2007 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __ardour_runtime_functions_h__
+#define __ardour_runtime_functions_h__
+
+#include <ardour/types.h>
+
+namespace ARDOUR {
+
+ typedef float (*compute_peak_t) (const ARDOUR::Sample *, nframes_t, float);
+ typedef void (*find_peaks_t) (const ARDOUR::Sample *, nframes_t, float *, float*);
+ typedef void (*apply_gain_to_buffer_t) (ARDOUR::Sample *, nframes_t, float);
+ typedef void (*mix_buffers_with_gain_t) (ARDOUR::Sample *, const ARDOUR::Sample *, nframes_t, float);
+ typedef void (*mix_buffers_no_gain_t) (ARDOUR::Sample *, const ARDOUR::Sample *, nframes_t);
+
+ extern compute_peak_t compute_peak;
+ extern find_peaks_t find_peaks;
+ extern apply_gain_to_buffer_t apply_gain_to_buffer;
+ extern mix_buffers_with_gain_t mix_buffers_with_gain;
+ extern mix_buffers_no_gain_t mix_buffers_no_gain;
+}
+
+#endif /* __ardour_runtime_functions_h__ */
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index d173f43407..27bc781b79 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -932,18 +932,6 @@ class Session : public PBD::StatefulDestructible
void* ptr,
float opt);
- typedef float (*compute_peak_t) (Sample *, nframes_t, float);
- typedef void (*find_peaks_t) (Sample *, nframes_t, float *, float*);
- typedef void (*apply_gain_to_buffer_t) (Sample *, nframes_t, float);
- typedef void (*mix_buffers_with_gain_t) (Sample *, Sample *, nframes_t, float);
- typedef void (*mix_buffers_no_gain_t) (Sample *, Sample *, nframes_t);
-
- static compute_peak_t compute_peak;
- static find_peaks_t find_peaks;
- static apply_gain_to_buffer_t apply_gain_to_buffer;
- static mix_buffers_with_gain_t mix_buffers_with_gain;
- static mix_buffers_no_gain_t mix_buffers_no_gain;
-
static sigc::signal<void> SendFeedback;
/* Controllables */