aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2004-08-03 17:51:51 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:56 +0200
commitf91b27f71b88c45202afe0baf9776e30c4177e19 (patch)
tree1773f3e03a575e45ea97cd7f9d677e2458edf613
parentb85f8bc7af3fda0f31af1c79a9f25145b8004705 (diff)
small changes
svn path=/trunk/externals/tb/; revision=1907
-rwxr-xr-xsc4pd/config-pd-linux.txt2
-rwxr-xr-xsc4pd/make-files.txt3
-rw-r--r--sc4pd/source/DelayN.cpp5
-rw-r--r--sc4pd/source/DelayUnit.cpp19
-rw-r--r--sc4pd/source/DelayUnit.hpp9
-rw-r--r--sc4pd/source/main.cpp9
-rw-r--r--sc4pd/source/support.hpp33
7 files changed, 63 insertions, 17 deletions
diff --git a/sc4pd/config-pd-linux.txt b/sc4pd/config-pd-linux.txt
index 1e95392..9b46ed4 100755
--- a/sc4pd/config-pd-linux.txt
+++ b/sc4pd/config-pd-linux.txt
@@ -1,7 +1,7 @@
# config file for sc4pd, adapted from Thomas Grill's xsample makefile
# your c++ compiler (if not g++)
- CXX=icc
+# CXX=icc
# where does the PD installation reside?
diff --git a/sc4pd/make-files.txt b/sc4pd/make-files.txt
index 78ed170..38c790a 100755
--- a/sc4pd/make-files.txt
+++ b/sc4pd/make-files.txt
@@ -10,4 +10,5 @@ SRCS= \
excess.cpp hypot.cpp ring1.cpp ring2.cpp ring3.cpp ring4.cpp \
difsqr.cpp sumsqr.cpp sqrdif.cpp sqrsum.cpp absdif.cpp LFSaw.cpp \
LFPulse.cpp Impulse.cpp Integrator.cpp Decay.cpp Decay2.cpp Lag.cpp \
- Lag2.cpp Lag3.cpp LinExp.cpp DelayUnit.cpp DelayN.cpp \ No newline at end of file
+ Lag2.cpp Lag3.cpp LinExp.cpp DelayUnit.cpp DelayN.cpp DelayL.cpp \
+ DelayC.cpp CombN.cpp
diff --git a/sc4pd/source/DelayN.cpp b/sc4pd/source/DelayN.cpp
index 176c6c3..6bbbb18 100644
--- a/sc4pd/source/DelayN.cpp
+++ b/sc4pd/source/DelayN.cpp
@@ -32,7 +32,7 @@
http://www.audiosynth.com
Coded while listening to:
-
+
*/
#include "sc4pd.hpp"
@@ -54,8 +54,7 @@ protected:
virtual void m_dsp(int n, t_sample *const *in, t_sample *const *out)
{
changed = false;
- DelayUnit_Reset(m_maxdelaytime, m_delaytime);
- post("start");
+ DelayUnit_Reset();
}
void m_set(float f)
diff --git a/sc4pd/source/DelayUnit.cpp b/sc4pd/source/DelayUnit.cpp
index 7f96677..5b11f96 100644
--- a/sc4pd/source/DelayUnit.cpp
+++ b/sc4pd/source/DelayUnit.cpp
@@ -46,26 +46,24 @@ void DelayUnit_ar::DelayUnit_AllocDelayLine()
delaybufsize = NEXTPOWEROFTWO(delaybufsize); // round up to next power of two
m_fdelaylen = m_idelaylen = delaybufsize;
- delete m_dlybuf;
+ delete[] m_dlybuf;
m_dlybuf = new float[delaybufsize] ;
m_mask = delaybufsize - 1;
}
void DelayUnit_ar::DelayUnit_Dtor()
{
- delete m_dlybuf;
+ delete[] m_dlybuf;
}
float DelayUnit_ar::CalcDelay(float delaytime)
{
- float next_dsamp = delaytime * Samplerate();
- return sc_clip(next_dsamp, 1.f, m_fdelaylen);
+ float next_dsamp = delaytime * Samplerate();
+ return sc_clip(next_dsamp, 1.f, m_fdelaylen);
}
-void DelayUnit_ar::DelayUnit_Reset(float f, float g)
+void DelayUnit_ar::DelayUnit_Reset()
{
- m_maxdelaytime = f;
- m_delaytime = g;
m_dlybuf = 0;
DelayUnit_AllocDelayLine();
@@ -75,3 +73,10 @@ void DelayUnit_ar::DelayUnit_Reset(float f, float g)
m_numoutput = 0;
m_iwrphase = 0;
}
+
+void FeedbackDelay_ar::FeedbackDelay_Reset()
+{
+ DelayUnit_Reset();
+
+ m_feedbk = CalcFeedback(m_delaytime, m_decaytime);
+}
diff --git a/sc4pd/source/DelayUnit.hpp b/sc4pd/source/DelayUnit.hpp
index d794031..a15a8c3 100644
--- a/sc4pd/source/DelayUnit.hpp
+++ b/sc4pd/source/DelayUnit.hpp
@@ -43,7 +43,7 @@ class DelayUnit_ar : public flext_dsp
public:
/* functions */
void DelayUnit_AllocDelayLine();
- void DelayUnit_Reset(float maxdelaytime, float delaytime);
+ void DelayUnit_Reset();
float CalcDelay(float delaytime);
void DelayUnit_Dtor();
@@ -56,3 +56,10 @@ public:
};
/* todo: a delay for control messages? */
+
+class FeedbackDelay_ar : public DelayUnit_ar
+{
+ FLEXT_HEADER(FeedbackDelay_ar,DelayUnit_ar);
+ float m_feedbk, m_decaytime;
+ void FeedbackDelay_Reset();
+};
diff --git a/sc4pd/source/main.cpp b/sc4pd/source/main.cpp
index 568d130..126cf50 100644
--- a/sc4pd/source/main.cpp
+++ b/sc4pd/source/main.cpp
@@ -58,8 +58,9 @@ void sc4pd_library_setup()
" ring2(~), ring3(~), ring4(~), difsqr(~), sumsqr(~), "
"sqrdif(~),\n"
" sqrsum(~), absdif(~), LFSaw(~), LFPulse(~), Impulse(~),\n"
- " Integrator(~), Decay~, Decay2~, Lag~, Lag2~, LinExp(~)"
- "DelayN~\n"
+ " Integrator(~), Decay~, Decay2~, Lag~, Lag2~, LinExp(~), "
+ "DelayN~,\n"
+ " DelayL~, DelayC~"
);
//initialize objects
@@ -208,6 +209,10 @@ void sc4pd_library_setup()
FLEXT_SETUP(LinExp_kr);
FLEXT_DSP_SETUP(DelayN_ar);
+
+ FLEXT_DSP_SETUP(DelayL_ar);
+
+ FLEXT_DSP_SETUP(DelayC_ar);
}
FLEXT_LIB_SETUP(sc4pd,sc4pd_library_setup);
diff --git a/sc4pd/source/support.hpp b/sc4pd/source/support.hpp
index 34e260a..6b51f2b 100644
--- a/sc4pd/source/support.hpp
+++ b/sc4pd/source/support.hpp
@@ -34,16 +34,18 @@
*/
+#ifndef _SUPPORT_HPP
+#define _SUPPORT_HPP
+
#include <flext.h>
-//#include <flsupport.h>
#include "SC_PlugIn.h"
-//#include <strings.h>
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406)
#error You need at least FLEXT version 0.4.6
#endif
+
/* for argument parsing */
bool sc_add (flext::AtomList a);
float sc_getfloatarg (flext::AtomList a,int i);
@@ -65,6 +67,32 @@ bool sc_ar(flext::AtomList a);
int32 timeseed();
+/* cubic interpolation from DelayUGens.cpp */
+inline float cubicinterp(float x, float y0, float y1, float y2, float y3)
+{
+ // 4-point, 3rd-order Hermite (x-form)
+ float c0 = y1;
+ float c1 = 0.5f * (y2 - y0);
+ float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3;
+ float c3 = 0.5f * (y3 - y0) + 1.5f * (y1 - y2);
+
+ return ((c3 * x + c2) * x + c1) * x + c0;
+}
+
+/* feedback calculation from DelayUGens.cpp */
+inline float CalcFeedback(float delaytime, float decaytime)
+{
+ if (delaytime == 0.f) {
+ return 0.f;
+ } else if (decaytime > 0.f) {
+ return exp(log001 * delaytime / decaytime);
+ } else if (decaytime < 0.f) {
+ return -exp(log001 * delaytime / -decaytime);
+ } else {
+ return 0.f;
+ }
+}
+
/* this is copied from thomas grill's xsample:
xsample - extended sample objects for Max/MSP and pd (pure data)
@@ -95,3 +123,4 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define SIGFUN(FUN) &thisType::FUN
+#endif