aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/idelay/delay.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-05 11:12:17 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-05 11:12:17 +0000
commit420a758195fea188311fdcd24bff4be2c2afebfb (patch)
tree8d3ef9302ee44ee9563c2997a5625d6ad9bf352e /externals/grill/idelay/delay.cpp
parent60ee6bb60b11bbfbccf56f335c9c6213e6daa79d (diff)
""
svn path=/trunk/; revision=279
Diffstat (limited to 'externals/grill/idelay/delay.cpp')
-rw-r--r--externals/grill/idelay/delay.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/externals/grill/idelay/delay.cpp b/externals/grill/idelay/delay.cpp
new file mode 100644
index 00000000..b126ebce
--- /dev/null
+++ b/externals/grill/idelay/delay.cpp
@@ -0,0 +1,75 @@
+/*
+
+idelay~ - interpolating delay using flext layer
+
+Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+-------------------------------------------------------------------------
+
+This is an example for usage of flext
+It's a simple interpolating delay with signal input with allows for glitchless change of delay times
+Watch out for Doppler effects!
+
+*/
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error You need at least flext version 0.4.0
+#endif
+
+// template class for delay line
+#include "delay.h"
+
+
+class idelay:
+ public flext_dsp
+{
+ FLEXT_HEADER(idelay,flext_dsp)
+
+public:
+ idelay(F msec);
+ ~idelay();
+
+ DelayLine<S> *dline;
+
+protected:
+ virtual V m_signal(I n,S *const *in,S *const *out);
+};
+
+// make implementation of a tilde object with one float arg
+FLEXT_NEW_DSP_1("idelay~",idelay,F)
+
+
+idelay::idelay(F maxmsec)
+{
+ I nsamps = (I)ceil(maxmsec*Samplerate()*0.001f);
+ if (nsamps < 1) nsamps = 1;
+ dline = new DelayLine<F>(nsamps);
+
+ AddInSignal(2); // audio in & delay signals
+ AddOutSignal(); // audio out
+ SetupInOut(); // set up inlets and outlets
+}
+
+idelay::~idelay()
+{
+ if(dline) delete dline;
+}
+
+
+V idelay::m_signal(I n,S *const *in,S *const *out)
+{
+ const S *ins = in[0],*del = in[1];
+ S *outs = out[0];
+ F msr = Samplerate()*0.001f;
+
+ while (n--)
+ {
+ dline->Put(*ins++);
+ *outs++ = dline->Get((*del++)*msr);
+ }
+}
+