case Copy:
/* copy region before adding, so we're not putting same object into two different playlists */
- npl->add_region (RegionFactory::create (r, r->position() - first_position);
+ npl->add_region (RegionFactory::create (r), r->position() - first_position);
break;
case Clear:
#include <iostream>
#include <ardour/types.h>
#include <ardour/data_type.h>
+#include <ardour/runtime_functions.h>
namespace ARDOUR {
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).
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__ */
#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]));
--- /dev/null
+/*
+ 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__ */
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 */
#include <ardour/audiofilter.h>
#include <ardour/audiofilesource.h>
#include <ardour/region_factory.h>
+#include <ardour/runtime_functions.h>
#include "i18n.h"
#include <locale.h>
}
}
} else if (_scale_amplitude != 1.0f) {
- Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
+ apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
}
merge:
return;
}
- maxamp = Session::compute_peak (buf, to_read, maxamp);
+ maxamp = compute_peak (buf, to_read, maxamp);
}
fpos += to_read;
#include <ardour/audiosource.h>
#include <ardour/cycle_timer.h>
-#include <ardour/session.h>
+#include <ardour/runtime_functions.h>
#include "i18n.h"
x.min = peak_leftovers[0];
x.max = peak_leftovers[0];
- Session::find_peaks (peak_leftovers + 1, peak_leftover_cnt - 1, &x.min, &x.max);
+ find_peaks (peak_leftovers + 1, peak_leftover_cnt - 1, &x.min, &x.max);
off_t byte = (peak_leftover_frame / frames_per_peak) * sizeof (PeakData);
peakbuf[peaks_computed].max = buf[0];
peakbuf[peaks_computed].min = buf[0];
- Session::find_peaks (buf+1, this_time-1, &peakbuf[peaks_computed].min, &peakbuf[peaks_computed].max);
+ find_peaks (buf+1, this_time-1, &peakbuf[peaks_computed].min, &peakbuf[peaks_computed].max);
peaks_computed++;
buf += this_time;
#endif
#include <ardour/mix.h>
+#include <ardour/runtime_functions.h>
#if defined (__APPLE__)
#include <Carbon/Carbon.h> // For Gestalt
Change ARDOUR::NameChanged = ARDOUR::new_change ();
Change ARDOUR::BoundsChanged = Change (0); // see init(), below
+compute_peak_t ARDOUR::compute_peak = 0;
+find_peaks_t ARDOUR::find_peaks = 0;
+apply_gain_to_buffer_t ARDOUR::apply_gain_to_buffer = 0;
+mix_buffers_with_gain_t ARDOUR::mix_buffers_with_gain = 0;
+mix_buffers_no_gain_t ARDOUR::mix_buffers_no_gain = 0;
+
#ifdef HAVE_LIBLO
static int
setup_osc ()
info << "Using SSE optimized routines" << endmsg;
// SSE SET
- Session::compute_peak = x86_sse_compute_peak;
- Session::find_peaks = x86_sse_find_peaks;
- Session::apply_gain_to_buffer = x86_sse_apply_gain_to_buffer;
- Session::mix_buffers_with_gain = x86_sse_mix_buffers_with_gain;
- Session::mix_buffers_no_gain = x86_sse_mix_buffers_no_gain;
+ compute_peak = x86_sse_compute_peak;
+ find_peaks = x86_sse_find_peaks;
+ apply_gain_to_buffer = x86_sse_apply_gain_to_buffer;
+ mix_buffers_with_gain = x86_sse_mix_buffers_with_gain;
+ mix_buffers_no_gain = x86_sse_mix_buffers_no_gain;
generic_mix_functions = false;
sysVersion = 0;
if (sysVersion >= 0x00001040) { // Tiger at least
- Session::compute_peak = veclib_compute_peak;
- Session::find_peaks = veclib_find_peaks;
- Session::apply_gain_to_buffer = veclib_apply_gain_to_buffer;
- Session::mix_buffers_with_gain = veclib_mix_buffers_with_gain;
- Session::mix_buffers_no_gain = veclib_mix_buffers_no_gain;
+ compute_peak = veclib_compute_peak;
+ find_peaks = veclib_find_peaks;
+ apply_gain_to_buffer = veclib_apply_gain_to_buffer;
+ mix_buffers_with_gain = veclib_mix_buffers_with_gain;
+ mix_buffers_no_gain = veclib_mix_buffers_no_gain;
generic_mix_functions = false;
}
if (generic_mix_functions) {
-
- Session::compute_peak = compute_peak;
- Session::find_peaks = find_peaks;
- Session::apply_gain_to_buffer = apply_gain_to_buffer;
- Session::mix_buffers_with_gain = mix_buffers_with_gain;
- Session::mix_buffers_no_gain = mix_buffers_no_gain;
+
+ compute_peak = default_compute_peak;
+ find_peaks = default_find_peaks;
+ apply_gain_to_buffer = default_apply_gain_to_buffer;
+ mix_buffers_with_gain = default_mix_buffers_with_gain;
+ mix_buffers_no_gain = default_mix_buffers_no_gain;
info << "No H/W specific optimizations in use" << endmsg;
}
#include <ardour/mix.h>
#include <stdint.h>
+using namespace ARDOUR;
+
#if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS)
// Debug wrappers
float
-compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current)
+default_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current)
{
for (nframes_t i = 0; i < nsamples; ++i) {
current = f_max (current, fabsf (buf[i]));
}
void
-find_peaks (ARDOUR::Sample *buf, nframes_t nframes, float *min, float *max)
+default_find_peaks (const ARDOUR::Sample * buf, nframes_t nframes, float *min, float *max)
{
nframes_t i;
float a, b;
}
void
-apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain)
+default_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain)
{
for (nframes_t i=0; i<nframes; i++)
buf[i] *= gain;
}
void
-mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain)
+default_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain)
{
for (nframes_t i = 0; i < nframes; i++) {
dst[i] += src[i] * gain;
}
void
-mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes)
+default_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes)
{
for (nframes_t i=0; i < nframes; i++) {
dst[i] += src[i];
#include <Accelerate/Accelerate.h>
float
-veclib_compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current)
+veclib_compute_peak (const ARDOUR::Sample * buf, nframes_t nsamples, float current)
{
float tmpmax = 0.0f;
vDSP_maxmgv(buf, 1, &tmpmax, nsamples);
}
void
-veclib_find_peaks (ARDOUR::Sample *buf, nframes_t nframes, float *min, float *max)
+veclib_find_peaks (const ARDOUR::Sample * buf, nframes_t nframes, float *min, float *max)
{
vDSP_maxv (buf, 1, max, nframes);
vDSP_minv (buf, 1, min, nframes);
}
void
-veclib_apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain)
+veclib_apply_gain_to_buffer (ARDOUR::Sample * buf, nframes_t nframes, float gain)
{
vDSP_vsmul(buf, 1, &gain, buf, 1, nframes);
}
void
-veclib_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes, float gain)
+veclib_mix_buffers_with_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes, float gain)
{
vDSP_vsma(src, 1, &gain, dst, 1, dst, 1, nframes);
}
void
-veclib_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, nframes_t nframes)
+veclib_mix_buffers_no_gain (ARDOUR::Sample * dst, const ARDOUR::Sample * src, nframes_t nframes)
{
// It seems that a vector mult only operation does not exist...
float gain = 1.0f;
#include <ardour/panner.h>
#include <ardour/utils.h>
-#include <ardour/mix.h>
+#include <ardour/runtime_functions.h>
#include <ardour/buffer_set.h>
#include "i18n.h"
pan = left * gain_coeff;
- Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
+ mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
} else {
if (pan != 0.0f) {
- Session::mix_buffers_with_gain(dst,src,nframes,pan);
+ mix_buffers_with_gain(dst,src,nframes,pan);
/* mark that we wrote into the buffer */
} else {
- Session::mix_buffers_no_gain(dst,src,nframes);
+ mix_buffers_no_gain(dst,src,nframes);
/* mark that we wrote into the buffer */
pan = right * gain_coeff;
- Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
+ mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
/* XXX it would be nice to mark the buffer as written to */
if (pan != 0.0f) {
- Session::mix_buffers_with_gain(dst,src,nframes,pan);
+ mix_buffers_with_gain(dst,src,nframes,pan);
/* XXX it would be nice to mark the buffer as written to */
}
} else {
- Session::mix_buffers_no_gain(dst,src,nframes);
+ mix_buffers_no_gain(dst,src,nframes);
/* XXX it would be nice to mark the buffer as written to */
}
}
pan = left * gain_coeff;
- Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
+ mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
} else {
if ((pan *= gain_coeff) != 1.0f) {
if (pan != 0.0f) {
- Session::mix_buffers_with_gain(dst,src,nframes,pan);
+ mix_buffers_with_gain(dst,src,nframes,pan);
}
} else {
- Session::mix_buffers_no_gain(dst,src,nframes);
+ mix_buffers_no_gain(dst,src,nframes);
}
#endif
#ifdef CAN_INTERP
#include <ardour/ladspa_plugin.h>
#include <ardour/panner.h>
#include <ardour/dB.h>
-#include <ardour/mix.h>
#include <ardour/amp.h>
#include <ardour/meter.h>
#include <ardour/buffer_set.h>
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
Sample* const sp = i->data(nframes);
- Session::apply_gain_to_buffer(sp,nframes,this_gain);
+ apply_gain_to_buffer(sp,nframes,this_gain);
}
} else if (_gain == 0) {
const char* Session::interchange_dir_name = X_("interchange");
const char* Session::export_dir_name = X_("export");
-Session::compute_peak_t Session::compute_peak = 0;
-Session::find_peaks_t Session::find_peaks = 0;
-Session::apply_gain_to_buffer_t Session::apply_gain_to_buffer = 0;
-Session::mix_buffers_with_gain_t Session::mix_buffers_with_gain = 0;
-Session::mix_buffers_no_gain_t Session::mix_buffers_no_gain = 0;
-
sigc::signal<int> Session::AskAboutPendingState;
sigc::signal<void> Session::SendFeedback;
#include <ardour/types.h>
void
-x86_sse_find_peaks(float *buf, nframes_t nframes, float *min, float *max)
+x86_sse_find_peaks(const ARDOUR::Sample* buf, nframes_t nframes, float *min, float *max)
{
__m128 current_max, current_min, work;