aboutsummaryrefslogtreecommitdiff
path: root/experimental/pvocfreq.c
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2002-06-17 10:13:57 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2002-06-17 10:13:57 +0000
commitfc3d3c0a4f110a23335398c327ac0a4fc949d5cb (patch)
tree1849d6afbe34cee9cec97bdb2295401f5126870b /experimental/pvocfreq.c
This commit was generated by cvs2svn to compensate for changes in r12,svn2git-root
which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ggee/; revision=13
Diffstat (limited to 'experimental/pvocfreq.c')
-rwxr-xr-xexperimental/pvocfreq.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/experimental/pvocfreq.c b/experimental/pvocfreq.c
new file mode 100755
index 0000000..4eb30ca
--- /dev/null
+++ b/experimental/pvocfreq.c
@@ -0,0 +1,114 @@
+/* (C) Guenter Geiger <geiger@epy.co.at> */
+
+
+#include <m_pd.h>
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* ------------------------ shuffle ----------------------------- */
+
+static t_class *shuffle_class;
+
+
+typedef struct _shuffle
+{
+ t_object x_obj;
+ t_float x;
+} t_shuffle;
+
+
+void shuffle_float(t_shuffle *x, t_floatarg f)
+{
+ post("float %f",f);
+ x->x = f;
+}
+
+
+
+static t_int *shuffle_perform(t_int *w)
+{
+ t_shuffle* x = (t_shuffle*)(w[1]);
+ t_float* in1 = (t_float*) w[2];
+ t_float* in2 = (t_float*) w[3];
+ t_float* out = (t_float*) w[4];
+ int n = w[5];
+
+ if (x->x <= 0) {
+ while (n--) {
+ *out++ = *in1++;
+ }
+ return w+6;
+ }
+
+ if (x->x < 0.5) {
+ t_int index = 1/x->x;
+ while (n--) {
+ if (n%index){
+ *out++ = *in1++;
+ in2++;
+ }
+ else {
+ *out++ = *in2++;
+ in1++;
+ }
+ }
+ return w+6;
+ }
+
+ if (x->x > 1.0) {
+ while (n--) {
+ *out++ = *in2++;
+ }
+ return w+6;
+ }
+
+ if (x->x >= 0.5) {
+ t_int index = 1/(1.0- x->x);
+ while (n--) {
+ if (n%index) {
+ *out++ = *in2++;
+ in1++;
+ }
+ else {
+ *out++ = *in1++;
+ in2++;
+ }
+ }
+ }
+
+ return w+6;
+}
+
+
+static void shuffle_dsp(t_shuffle *x, t_signal **sp)
+{
+ dsp_add(shuffle_perform, 5, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec, sp[0]->s_n);
+
+}
+
+static void *shuffle_new()
+{
+ t_shuffle *x = (t_shuffle *)pd_new(shuffle_class);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+
+
+ outlet_new(&x->x_obj, gensym("signal"));
+ return (x);
+}
+
+void shuffle_setup(void)
+{
+ shuffle_class = class_new(gensym("shuffle~"), (t_newmethod)shuffle_new, 0,
+ sizeof(t_shuffle), 0,0);
+
+ class_addmethod(shuffle_class, nullfn, gensym("signal"), 0);
+ class_addmethod(shuffle_class, (t_method) shuffle_dsp, gensym("dsp"), 0);
+
+ class_addfloat(shuffle_class,shuffle_float);
+}
+
+