aboutsummaryrefslogtreecommitdiff
path: root/sc4pd
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2004-07-15 19:05:05 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:55 +0200
commit9ecfff90135ec05498f9f55a39cd386c855a8571 (patch)
tree4df5eeeadcca3431512a2a6f4a22b29bbeb0756e /sc4pd
parent0f1258611b064b215d1dd877f69e694fedf0d109 (diff)
rng have setable seed and other changes
svn path=/trunk/externals/tb/; revision=1867
Diffstat (limited to 'sc4pd')
-rwxr-xr-xsc4pd/make-files.txt3
-rw-r--r--sc4pd/source/BrownNoise.cpp22
-rw-r--r--sc4pd/source/ClipNoise.cpp19
-rw-r--r--sc4pd/source/Dust.cpp19
-rw-r--r--sc4pd/source/Dust2.cpp18
-rw-r--r--sc4pd/source/ExpRand.cpp168
-rw-r--r--sc4pd/source/GrayNoise.cpp18
-rw-r--r--sc4pd/source/IRand.cpp20
-rw-r--r--sc4pd/source/PinkNoise.cpp18
-rw-r--r--sc4pd/source/Rand.cpp22
-rw-r--r--sc4pd/source/TExpRand.cpp18
-rw-r--r--sc4pd/source/TIRand.cpp17
-rw-r--r--sc4pd/source/TRand.cpp17
-rw-r--r--sc4pd/source/WhiteNoise.cpp18
-rw-r--r--sc4pd/source/main.cpp16
-rw-r--r--sc4pd/source/support.hpp48
16 files changed, 393 insertions, 68 deletions
diff --git a/sc4pd/make-files.txt b/sc4pd/make-files.txt
index be5dcbc..7bd3221 100755
--- a/sc4pd/make-files.txt
+++ b/sc4pd/make-files.txt
@@ -4,4 +4,5 @@ SRCS= \
main.cpp Dust.cpp MantissaMask.cpp Hasher.cpp Median.cpp \
BrownNoise.cpp ClipNoise.cpp GrayNoise.cpp WhiteNoise.cpp \
PinkNoise.cpp Dust2.cpp Crackle.cpp Rand.cpp TRand.cpp TExpRand.cpp \
- IRand.cpp TIRand.cpp \ No newline at end of file
+ IRand.cpp TIRand.cpp CoinGate.cpp support.cpp LinRand.cpp NRand.cpp\
+ \ No newline at end of file
diff --git a/sc4pd/source/BrownNoise.cpp b/sc4pd/source/BrownNoise.cpp
index 39cbc26..b9bc138 100644
--- a/sc4pd/source/BrownNoise.cpp
+++ b/sc4pd/source/BrownNoise.cpp
@@ -58,22 +58,29 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
float m_level;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("BrownNoise~",BrownNoise_ar);
BrownNoise_ar::BrownNoise_ar(int argc, t_atom *argv)
{
-
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
m_level=rgen.frand2();
-
+
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
AddOutSignal();
}
@@ -115,11 +122,17 @@ public:
protected:
void m_perform();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_level;
RGen rgen;
FLEXT_CALLBACK(m_perform);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("BrownNoise",BrownNoise_kr);
@@ -127,11 +140,12 @@ FLEXT_LIB_V("BrownNoise",BrownNoise_kr);
BrownNoise_kr::BrownNoise_kr(int argc, t_atom *argv)
{
FLEXT_ADDBANG(0,m_perform);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
m_level=rgen.frand2();
AddOutFloat();
diff --git a/sc4pd/source/ClipNoise.cpp b/sc4pd/source/ClipNoise.cpp
index 14b5101..891342c 100644
--- a/sc4pd/source/ClipNoise.cpp
+++ b/sc4pd/source/ClipNoise.cpp
@@ -57,20 +57,27 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("ClipNoise~",ClipNoise_ar);
ClipNoise_ar::ClipNoise_ar(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -104,10 +111,16 @@ public:
protected:
void m_perform();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
RGen rgen;
FLEXT_CALLBACK(m_perform);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("ClipNoise",ClipNoise_kr);
@@ -115,11 +128,11 @@ FLEXT_LIB_V("ClipNoise",ClipNoise_kr);
ClipNoise_kr::ClipNoise_kr(int argc, t_atom *argv)
{
FLEXT_ADDBANG(0,m_perform);
-
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutFloat();
}
diff --git a/sc4pd/source/Dust.cpp b/sc4pd/source/Dust.cpp
index 58decd8..0acd45f 100644
--- a/sc4pd/source/Dust.cpp
+++ b/sc4pd/source/Dust.cpp
@@ -63,9 +63,15 @@ protected:
m_thresh = m_density/Samplerate();
m_scale = m_thresh > 0.f ? 1.f / m_thresh : 0.f;
}
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
FLEXT_CALLBACK_F(m_set);
+ FLEXT_CALLBACK_I(m_seed);
float m_density, m_thresh, m_scale;
RGen rgen;
@@ -76,12 +82,14 @@ FLEXT_LIB_DSP_V("Dust~",Dust_ar);
Dust_ar::Dust_ar(int argc, t_atom *argv)
{
FLEXT_ADDMETHOD_(0,"set",m_set);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
m_density=sc_getfloatarg(Args,0);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
+
AddOutSignal();
}
@@ -129,6 +137,11 @@ protected:
void m_set(float f);
Timer Dust_timer;
void m_doit(void*);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_density, m_scale;
@@ -136,6 +149,7 @@ private:
RGen rgen;
FLEXT_CALLBACK_1(m_set,float);
FLEXT_CALLBACK_T(m_doit);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("Dust",Dust_kr);
@@ -144,12 +158,13 @@ Dust_kr::Dust_kr(int argc, t_atom *argv)
: Dust_timer(false)
{
FLEXT_ADDMETHOD(0,m_set);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
m_density=sc_getfloatarg(Args,0);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutFloat();
FLEXT_ADDTIMER(Dust_timer,m_doit);
diff --git a/sc4pd/source/Dust2.cpp b/sc4pd/source/Dust2.cpp
index ef41d9a..cb5d509 100644
--- a/sc4pd/source/Dust2.cpp
+++ b/sc4pd/source/Dust2.cpp
@@ -64,9 +64,15 @@ protected:
m_thresh = m_density/Samplerate();
m_scale = m_thresh > 0.f ? 1.f / m_thresh : 0.f;
}
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
FLEXT_CALLBACK_F(m_set);
+ FLEXT_CALLBACK_I(m_seed);
float m_density, m_thresh, m_scale;
RGen rgen;
@@ -77,12 +83,13 @@ FLEXT_LIB_DSP_V("Dust2~",Dust2_ar);
Dust2_ar::Dust2_ar(int argc, t_atom *argv)
{
FLEXT_ADDMETHOD_(0,"set",m_set);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
m_density=sc_getfloatarg(Args,0);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -130,12 +137,18 @@ protected:
void m_set(float f);
Timer Dust2_timer;
void m_doit(void*);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_density, m_scale;
float mtbt; //medium time between trigger
RGen rgen;
FLEXT_CALLBACK_1(m_set,float);
+ FLEXT_CALLBACK_I(m_seed);
FLEXT_CALLBACK_T(m_doit);
};
@@ -145,12 +158,13 @@ Dust2_kr::Dust2_kr(int argc, t_atom *argv)
: Dust2_timer(false)
{
FLEXT_ADDMETHOD(0,m_set);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
m_density=sc_getfloatarg(Args,0);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutFloat();
FLEXT_ADDTIMER(Dust2_timer,m_doit);
diff --git a/sc4pd/source/ExpRand.cpp b/sc4pd/source/ExpRand.cpp
new file mode 100644
index 0000000..e0718c8
--- /dev/null
+++ b/sc4pd/source/ExpRand.cpp
@@ -0,0 +1,168 @@
+/* sc4pd
+ ExpRand, ExpRand~
+
+ Copyright (c) 2004 Tim Blechmann.
+
+ This code is derived from:
+ SuperCollider real time audio synthesis system
+ Copyright (c) 2002 James McCartney. All rights reserved.
+ http://www.audiosynth.com
+
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Based on:
+ PureData by Miller Puckette and others.
+ http://www.crca.ucsd.edu/~msp/software.html
+ FLEXT by Thomas Grill
+ http://www.parasitaere-kapazitaeten.net/ext
+ SuperCollider by James McCartney
+ http://www.audiosynth.com
+
+ Coded while listening to: Jim O'Rourke & Loren Mazzacane Connors: In Bern
+
+*/
+
+#include <flext.h>
+#include "SC_PlugIn.h"
+#include "support.hpp"
+
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406)
+#error You need at least FLEXT version 0.4.6
+#endif
+
+
+/* ------------------------ ExpRand~ -------------------------------*/
+
+class ExpRand_ar:
+ public flext_dsp
+{
+ FLEXT_HEADER(ExpRand_ar,flext_dsp);
+
+public:
+ ExpRand_ar(int argc, t_atom *argv);
+
+protected:
+ virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+ virtual void m_dsp(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
+private:
+ float m_sample;
+ float lo;
+ float hi;
+ int sc_n;
+ RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
+};
+
+FLEXT_LIB_DSP_V("ExpRand~",ExpRand_ar);
+
+ExpRand_ar::ExpRand_ar(int argc, t_atom *argv)
+{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
+ AtomList Args(argc,argv);
+
+ if (Args.Count() != 2)
+ {
+ post("not enough arguments");
+ return;
+ }
+ lo=sc_getfloatarg(Args,0);
+ hi=sc_getfloatarg(Args,1);
+
+ rgen.init(timeseed());
+
+ AddOutSignal();
+}
+
+void ExpRand_ar::m_dsp(int n, t_sample *const *in, t_sample *const *out)
+{
+ float ratio = hi / lo;
+ m_sample = pow(ratio,rgen.frand()) * lo);
+}
+
+
+void ExpRand_ar::m_signal(int n, t_sample *const *in,
+ t_sample *const *out)
+{
+ t_sample *nout = *out;
+
+ float sample = m_sample;
+
+ for (int i = 0; i!= n;++i)
+ {
+ (*(nout)++) = sample;
+ }
+}
+
+
+/* ------------------------ ExpRand ---------------------------------*/
+
+class ExpRand_kr:
+ public flext_base
+{
+ FLEXT_HEADER(ExpRand_kr,flext_base);
+
+public:
+ ExpRand_kr(int argc, t_atom *argv);
+
+protected:
+ void m_loadbang();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
+private:
+ float lo;
+ float hi;
+ int sc_n;
+ RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
+};
+
+FLEXT_LIB_V("ExpRand",ExpRand_kr);
+
+ExpRand_kr::ExpRand_kr(int argc, t_atom *argv)
+{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
+ AtomList Args(argc,argv);
+ if (Args.Count() != 2)
+ {
+ post("not enough arguments");
+ return;
+ }
+ lo=sc_getfloatarg(Args,0);
+ hi=sc_getfloatarg(Args,1);
+
+ rgen.init(timeseed());
+
+ AddOutFloat();
+}
+
+void ExpRand_kr::m_loadbang()
+{
+ float ratio = hi / lo;
+ ToOutFloat(0,pow(ratio,rgen.frand()) * lo);
+}
diff --git a/sc4pd/source/GrayNoise.cpp b/sc4pd/source/GrayNoise.cpp
index 8628bca..6c76217 100644
--- a/sc4pd/source/GrayNoise.cpp
+++ b/sc4pd/source/GrayNoise.cpp
@@ -57,21 +57,28 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
int m_counter;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("GrayNoise~",GrayNoise_ar);
GrayNoise_ar::GrayNoise_ar(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -108,11 +115,17 @@ public:
protected:
void m_perform();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
int m_counter;
RGen rgen;
FLEXT_CALLBACK(m_perform);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("GrayNoise",GrayNoise_kr);
@@ -120,11 +133,12 @@ FLEXT_LIB_V("GrayNoise",GrayNoise_kr);
GrayNoise_kr::GrayNoise_kr(int argc, t_atom *argv)
{
FLEXT_ADDBANG(0,m_perform);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutFloat();
}
diff --git a/sc4pd/source/IRand.cpp b/sc4pd/source/IRand.cpp
index 05cc5f0..095df92 100644
--- a/sc4pd/source/IRand.cpp
+++ b/sc4pd/source/IRand.cpp
@@ -58,18 +58,26 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
virtual void m_dsp(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_sample;
int lo;
int hi;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("IRand~",IRand_ar);
IRand_ar::IRand_ar(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
AtomList Args(argc,argv);
if (Args.Count() != 2)
@@ -80,7 +88,7 @@ IRand_ar::IRand_ar(int argc, t_atom *argv)
lo=int(sc_getfloatarg(Args,0));
hi=int(sc_getfloatarg(Args,1));
- rgen.init(0); //this should be changed
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -119,16 +127,24 @@ public:
protected:
void m_loadbang();
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
int lo;
int hi;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("IRand",IRand_kr);
IRand_kr::IRand_kr(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
AtomList Args(argc,argv);
if (Args.Count() != 2)
{
@@ -138,7 +154,7 @@ IRand_kr::IRand_kr(int argc, t_atom *argv)
lo=int(sc_getfloatarg(Args,0));
hi=int(sc_getfloatarg(Args,1));
- rgen.init(0);
+ rgen.init(timeseed());
AddOutInt();
}
diff --git a/sc4pd/source/PinkNoise.cpp b/sc4pd/source/PinkNoise.cpp
index bf6db62..9a1c5bc 100644
--- a/sc4pd/source/PinkNoise.cpp
+++ b/sc4pd/source/PinkNoise.cpp
@@ -57,11 +57,17 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
uint32 m_dice[16];
int32 m_total;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("PinkNoise~",PinkNoise_ar);
@@ -69,11 +75,12 @@ FLEXT_LIB_DSP_V("PinkNoise~",PinkNoise_ar);
PinkNoise_ar::PinkNoise_ar(int argc, t_atom *argv)
: m_total(0)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
for (int i=0; i<16; ++i)
{
@@ -123,12 +130,18 @@ public:
protected:
void m_perform();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
uint32 m_dice[16];
int32 m_total;
RGen rgen;
FLEXT_CALLBACK(m_perform);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("PinkNoise",PinkNoise_kr);
@@ -137,11 +150,12 @@ PinkNoise_kr::PinkNoise_kr(int argc, t_atom *argv)
: m_total(0)
{
FLEXT_ADDBANG(0,m_perform);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
for (int i=0; i<16; ++i)
{
diff --git a/sc4pd/source/Rand.cpp b/sc4pd/source/Rand.cpp
index 1601be9..243cc5e 100644
--- a/sc4pd/source/Rand.cpp
+++ b/sc4pd/source/Rand.cpp
@@ -58,18 +58,26 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
virtual void m_dsp(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_sample;
float lo;
float hi;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("Rand~",Rand_ar);
Rand_ar::Rand_ar(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
AtomList Args(argc,argv);
if (Args.Count() != 2)
@@ -80,7 +88,7 @@ Rand_ar::Rand_ar(int argc, t_atom *argv)
lo=sc_getfloatarg(Args,0);
hi=sc_getfloatarg(Args,1);
- rgen.init(0); //this should be changed
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -119,16 +127,24 @@ public:
protected:
void m_loadbang();
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
float lo;
float hi;
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("Rand",Rand_kr);
Rand_kr::Rand_kr(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
+
AtomList Args(argc,argv);
if (Args.Count() != 2)
{
@@ -138,8 +154,8 @@ Rand_kr::Rand_kr(int argc, t_atom *argv)
lo=sc_getfloatarg(Args,0);
hi=sc_getfloatarg(Args,1);
- rgen.init(0);
-
+ rgen.init(timeseed());
+
AddOutFloat();
}
diff --git a/sc4pd/source/TExpRand.cpp b/sc4pd/source/TExpRand.cpp
index 806fba1..b7ee16e 100644
--- a/sc4pd/source/TExpRand.cpp
+++ b/sc4pd/source/TExpRand.cpp
@@ -72,6 +72,11 @@ protected:
lo = f;
ratio = hi / lo;
}
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_sample;
@@ -83,6 +88,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_F(m_setlo);
FLEXT_CALLBACK_F(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("TExpRand~",TExpRand_ar);
@@ -100,13 +106,14 @@ TExpRand_ar::TExpRand_ar(int argc, t_atom *argv)
hi=sc_getfloatarg(Args,1);
ratio = hi / lo;
- rgen.init(0); //this should be changed
+ rgen.init(timeseed());
AddOutSignal();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TExpRand_ar::m_dsp(int n, t_sample *const *in, t_sample *const *out)
@@ -159,6 +166,11 @@ protected:
ratio = hi / lo;
}
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
float lo;
float hi;
@@ -167,6 +179,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_F(m_setlo);
FLEXT_CALLBACK_F(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("TExpRand",TExpRand_kr);
@@ -183,13 +196,14 @@ TExpRand_kr::TExpRand_kr(int argc, t_atom *argv)
hi=sc_getfloatarg(Args,1);
ratio = hi / lo;
- rgen.init(0);
+ rgen.init(timeseed());
AddOutFloat();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TExpRand_kr::m_loadbang()
diff --git a/sc4pd/source/TIRand.cpp b/sc4pd/source/TIRand.cpp
index b68278e..93fdd09 100644
--- a/sc4pd/source/TIRand.cpp
+++ b/sc4pd/source/TIRand.cpp
@@ -73,6 +73,10 @@ protected:
range = hi - lo;
}
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_sample;
@@ -84,6 +88,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_I(m_setlo);
FLEXT_CALLBACK_I(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("TIRand~",TIRand_ar);
@@ -101,13 +106,14 @@ TIRand_ar::TIRand_ar(int argc, t_atom *argv)
hi=int(sc_getfloatarg(Args,1));
range = hi - lo;
- rgen.init(0); //this should be changed
+ rgen.init(timeseed());
AddOutSignal();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TIRand_ar::m_dsp(int n, t_sample *const *in, t_sample *const *out)
@@ -160,6 +166,11 @@ protected:
range = hi - lo;
}
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
int lo;
int hi;
@@ -168,6 +179,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_I(m_setlo);
FLEXT_CALLBACK_I(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("TIRand",TIRand_kr);
@@ -184,13 +196,14 @@ TIRand_kr::TIRand_kr(int argc, t_atom *argv)
hi=int(sc_getfloatarg(Args,1));
range = hi - lo;
- rgen.init(0);
+ rgen.init(timeseed());
AddOutInt();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TIRand_kr::m_loadbang()
diff --git a/sc4pd/source/TRand.cpp b/sc4pd/source/TRand.cpp
index f1ca9b2..b18704f 100644
--- a/sc4pd/source/TRand.cpp
+++ b/sc4pd/source/TRand.cpp
@@ -73,6 +73,10 @@ protected:
range = hi - lo;
}
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
float m_sample;
@@ -84,6 +88,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_F(m_setlo);
FLEXT_CALLBACK_F(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("TRand~",TRand_ar);
@@ -101,13 +106,14 @@ TRand_ar::TRand_ar(int argc, t_atom *argv)
hi=sc_getfloatarg(Args,1);
range = hi - lo;
- rgen.init(0); //this should be changed
+ rgen.init(timeseed());
AddOutSignal();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TRand_ar::m_dsp(int n, t_sample *const *in, t_sample *const *out)
@@ -160,6 +166,11 @@ protected:
range = hi - lo;
}
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
+
private:
float lo;
float hi;
@@ -168,6 +179,7 @@ private:
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_F(m_setlo);
FLEXT_CALLBACK_F(m_sethi);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("TRand",TRand_kr);
@@ -184,13 +196,14 @@ TRand_kr::TRand_kr(int argc, t_atom *argv)
hi=sc_getfloatarg(Args,1);
range = hi - lo;
- rgen.init(0);
+ rgen.init(timeseed());
AddOutFloat();
FLEXT_ADDBANG(0,m_bang);
FLEXT_ADDMETHOD_(0,"setlo",m_setlo);
FLEXT_ADDMETHOD_(0,"sethi",m_sethi);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
}
void TRand_kr::m_loadbang()
diff --git a/sc4pd/source/WhiteNoise.cpp b/sc4pd/source/WhiteNoise.cpp
index ecedf3d..6d308db 100644
--- a/sc4pd/source/WhiteNoise.cpp
+++ b/sc4pd/source/WhiteNoise.cpp
@@ -57,20 +57,27 @@ public:
protected:
virtual void m_signal(int n, t_sample *const *in, t_sample *const *out);
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
RGen rgen;
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_DSP_V("WhiteNoise~",WhiteNoise_ar);
WhiteNoise_ar::WhiteNoise_ar(int argc, t_atom *argv)
{
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutSignal();
}
@@ -104,10 +111,16 @@ public:
protected:
void m_perform();
+
+ void m_seed(int i)
+ {
+ rgen.init(i);
+ }
private:
RGen rgen;
FLEXT_CALLBACK(m_perform);
+ FLEXT_CALLBACK_I(m_seed);
};
FLEXT_LIB_V("WhiteNoise",WhiteNoise_kr);
@@ -115,11 +128,12 @@ FLEXT_LIB_V("WhiteNoise",WhiteNoise_kr);
WhiteNoise_kr::WhiteNoise_kr(int argc, t_atom *argv)
{
FLEXT_ADDBANG(0,m_perform);
+ FLEXT_ADDMETHOD_(0,"seed",m_seed);
//parse arguments
AtomList Args(argc,argv);
- rgen.init(0); //set seed to 0
+ rgen.init(timeseed());
AddOutFloat();
}
diff --git a/sc4pd/source/main.cpp b/sc4pd/source/main.cpp
index 3ae9108..2de28fa 100644
--- a/sc4pd/source/main.cpp
+++ b/sc4pd/source/main.cpp
@@ -36,6 +36,7 @@
*/
#include <flext.h>
+#include "SC_PlugIn.h"
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406)
#error You need at least FLEXT version 0.4.6
@@ -43,6 +44,7 @@
#define SC4PD_VERSION "0.01"
+
void sc4pd_library_setup()
{
post("\nsc4pd: by tim blechmann");
@@ -53,7 +55,8 @@ void sc4pd_library_setup()
"BrownNoise(~),\n"
" ClipNoise(~), GrayNoise(~), Dust2(~), WhiteNoise(~), "
"PinkNoise(~), \n Crackle(~), Rand(~), TRand(~), "
- "TExpRand(~), IRand(~), TIRand(~)\n");
+ "TExpRand(~), IRand(~), TIRand(~),\n CoinGate, "
+ "LinRand(~), NRand(~), ExpRand(~)\n");
//initialize objects
FLEXT_DSP_SETUP(Dust_ar);
@@ -103,6 +106,17 @@ void sc4pd_library_setup()
FLEXT_DSP_SETUP(TIRand_ar);
FLEXT_SETUP(TIRand_kr);
+
+ FLEXT_SETUP(CoinGate_kr);
+
+ FLEXT_DSP_SETUP(LinRand_ar);
+ FLEXT_SETUP(LinRand_kr);
+
+ FLEXT_DSP_SETUP(NRand_ar);
+ FLEXT_SETUP(NRand_kr);
+
+ FLEXT_DSP_SETUP(ExpRand_ar);
+ FLEXT_SETUP(ExpRand_kr);
}
FLEXT_LIB_SETUP(sc4pd,sc4pd_library_setup);
diff --git a/sc4pd/source/support.hpp b/sc4pd/source/support.hpp
index b6d67a8..79faff5 100644
--- a/sc4pd/source/support.hpp
+++ b/sc4pd/source/support.hpp
@@ -35,51 +35,22 @@
*/
#include <flext.h>
-#include <flsupport.h>
+//#include <flsupport.h>
+#include "SC_PlugIn.h"
-#include <strings.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);
+bool sc_ar(flext::AtomList a);
-inline bool sc_add (flext::AtomList a)
-{
- for (int i = 0; i!=a.Count();++i)
- {
- if ( flext::IsSymbol(a[i]) )
- {
- const char * teststring;
- teststring = flext::GetString(a[i]);
- if((strcmp(teststring,"add"))==0)
- return true;
- }
- }
- return false;
-}
-
-inline float sc_getfloatarg (flext::AtomList a,int i)
-{
- if (a.Count() > 0 && a.Count() > i)
- return flext::GetAFloat(a[i]);
- else
- return 0;
-}
-inline bool sc_ar(flext::AtomList a)
-{
- for (int i = 0; i!=a.Count();++i)
- {
- if ( flext::IsSymbol(a[i]) )
- {
- const char * teststring;
- teststring = flext::GetString(a[i]);
- if((strcmp(teststring,"ar"))==0)
- return true;
- }
- }
- return false;
-}
+/* for rngs */
// macros to put rgen state in registers
#define RGET \
@@ -92,3 +63,4 @@ inline bool sc_ar(flext::AtomList a)
rgen.s2 = s2; \
rgen.s3 = s3;
+int32 timeseed();