#include <glib.h>
#include <glibmm.h>
#include <fftw3.h>
+
+#include "ardour/buffer_set.h"
+#include "ardour/chan_mapping.h"
#include "ardour/libardour_visibility.h"
+#include "ardour/types.h"
namespace ARDOUR { namespace DSP {
*/
float log_meter_coeff (float coeff);
+ void process_map (BufferSet* bufs,
+ const ChanMapping& in,
+ const ChanMapping& out,
+ pframes_t nframes, framecnt_t offset,
+ const DataType&);
+
/** 1st order Low Pass filter */
class LIBARDOUR_API LowPass {
public:
#include <stdlib.h>
#include <cmath>
#include "ardour/dB.h"
+#include "ardour/buffer.h"
#include "ardour/dsp_filter.h"
#ifdef COMPILER_MSVC
}
}
+void
+ARDOUR::DSP::process_map (BufferSet* bufs, const ChanMapping& in, const ChanMapping& out, pframes_t nframes, framecnt_t offset, const DataType& dt)
+{
+ const ChanMapping::Mappings& im (in.mappings());
+ const ChanMapping::Mappings& om (out.mappings());
+
+ for (ChanMapping::Mappings::const_iterator tm = im.begin(); tm != im.end(); ++tm) {
+ if (tm->first != dt) { continue; }
+ for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
+ bool valid;
+ const uint32_t idx = out.get (dt, i->second, &valid);
+ if (valid && idx != i->first) {
+ bufs->get (dt, idx).read_from (bufs->get (dt, i->first), nframes, offset, offset);
+ }
+ }
+ }
+ for (ChanMapping::Mappings::const_iterator tm = im.begin(); tm != im.end(); ++tm) {
+ if (tm->first != dt) { continue; }
+ for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
+ bool valid;
+ in.get_src (dt, i->first, &valid);
+ if (!valid) {
+ bufs->get (dt, i->second).silence (nframes, offset);
+ }
+ }
+ }
+
+}
+
LowPass::LowPass (double samplerate, float freq)
: _rate (samplerate)
, _z (0)
.addFunction ("mmult", &DSP::mmult)
.addFunction ("log_meter", &DSP::log_meter)
.addFunction ("log_meter_coeff", &DSP::log_meter_coeff)
+ .addFunction ("process_map", &DSP::process_map)
.addRefFunction ("peaks", &DSP::peaks)
.beginClass <DSP::LowPass> ("LowPass")
-- The following code is needed with "dsp_runmap" to work for arbitrary pin connections
-- this passes though all audio/midi data unprocessed.
- local audio_ins = in_map:count (): n_audio () -- number of audio input buffers
- local audio_outs = out_map:count (): n_audio () -- number of audio output buffers
+ ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("audio"))
+ ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("midi"))
+
+ -- equivalent lua code.
+ -- NOTE: the lua implementation below is intended for io-config [-1,-1].
+ -- It only works for actually mapped channels due to in_map:count() out_map:count()
+ -- being identical to the i/o pin count in this case.
+ --
+ -- Plugins that have multiple possible configurations will need to implement
+ -- dsp_configure() and remember the actual channel count.
+ --
+ -- ARDOUR.DSP.process_map() does iterate over the mapping itself and works generally.
+ -- Still the lua code below does lend itself as elaborate example.
+ --
+ --[[
+
+ local audio_ins = in_map:count (): n_audio () -- number of mapped audio input buffers
+ local audio_outs = out_map:count (): n_audio () -- number of mapped audio output buffers
assert (audio_outs, audio_ins) -- ioconfig [-1, -1]: must match
-- copy audio data if any
bufs:get_midi (ob):silence (n_samples, offset)
end
end
+ --]]
end