aboutsummaryrefslogtreecommitdiff
path: root/line3
diff options
context:
space:
mode:
Diffstat (limited to 'line3')
-rwxr-xr-xline3/line3-help.pd61
-rwxr-xr-xline3/line3.c178
-rwxr-xr-xline3/makefile97
3 files changed, 336 insertions, 0 deletions
diff --git a/line3/line3-help.pd b/line3/line3-help.pd
new file mode 100755
index 0000000..77a9a5d
--- /dev/null
+++ b/line3/line3-help.pd
@@ -0,0 +1,61 @@
+#N canvas 256 172 683 616 10;
+#X obj 33 279 line3;
+#X msg 32 44 0 1000;
+#X msg 43 66 127 1000;
+#N canvas 0 0 450 300 graph3 0;
+#X array line3 100 float 2;
+#X coords 0 1 99 -1 200 140 1;
+#X restore 306 174 graph;
+#X obj 33 394 t f b;
+#X obj 63 440 + 1;
+#X obj 63 418 f;
+#X obj 63 466 % 100;
+#X obj 62 163 random 127;
+#X obj 62 114 metro 300;
+#X msg 62 186 \$1 1000;
+#X obj 62 91 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 149 279 line;
+#N canvas 0 0 450 300 graph1 0;
+#X array line 100 float 2;
+#X coords 0 1 99 -1 200 140 1;
+#X restore 306 314 graph;
+#X obj 33 525 tabwrite line3;
+#X obj 149 526 tabwrite line;
+#X text 290 7 line3;
+#N canvas 0 0 450 300 nothing 0;
+#X obj 29 22 inlet;
+#X obj 29 52 outlet;
+#X connect 0 0 1 0;
+#X restore 33 218 pd nothing;
+#X obj 80 139 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 168 40 line3 is compatible with line \, but the transition
+is made with a 3d order polynome. coeficiant of this polynome are adjusted
+to have the continuity of the output variation speed.;
+#X obj 33 317 - 63.5;
+#X obj 149 318 - 63.5;
+#X obj 149 342 / 63.5;
+#X obj 33 340 / 63.5;
+#X connect 0 0 20 0;
+#X connect 1 0 17 0;
+#X connect 2 0 17 0;
+#X connect 4 0 14 0;
+#X connect 4 1 6 0;
+#X connect 5 0 7 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 1;
+#X connect 7 0 14 1;
+#X connect 7 0 15 1;
+#X connect 8 0 10 0;
+#X connect 9 0 8 0;
+#X connect 10 0 17 0;
+#X connect 11 0 9 0;
+#X connect 12 0 21 0;
+#X connect 17 0 0 0;
+#X connect 17 0 12 0;
+#X connect 18 0 8 0;
+#X connect 20 0 23 0;
+#X connect 21 0 22 0;
+#X connect 22 0 15 0;
+#X connect 23 0 4 0;
diff --git a/line3/line3.c b/line3/line3.c
new file mode 100755
index 0000000..2a6e813
--- /dev/null
+++ b/line3/line3.c
@@ -0,0 +1,178 @@
+// line3
+// based on miller puckette line object (so licence / copyright comes from pure data)
+// compatible with line, but with a 3d order polynome.
+// there is continuity of the variation speed
+
+/*
+This software is copyrighted by Miller Puckette and others. The following
+terms (the "Standard Improved BSD License") apply to all files associated with
+the software unless explicitly disclaimed in individual files:
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+3. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+// Cyrille Henry 01 2005
+
+
+#include "m_pd.h"
+
+static t_class *line3_class;
+
+typedef struct _line3
+{
+ t_object x_obj;
+ t_clock *x_clock;
+ double x_targettime;
+ t_float x_targetval,setderiv, a, b;
+ double x_prevtime;
+ t_float x_setval;
+ int x_gotinlet;
+ t_float x_grain;
+ double x_1overtimediff;
+ double x_in1val;
+} t_line3;
+
+void line3_tick(t_line3 *x)
+{
+ double tmp, t;
+ double timenow = clock_getsystime();
+ double msectogo = - clock_gettimesince(x->x_targettime);
+ if (msectogo < 1E-9)
+ {
+ outlet_float(x->x_obj.ob_outlet, x->x_targetval);
+ }
+ else
+ {
+ t = (timenow - x->x_prevtime);
+
+ tmp = x->a * t * t * t + x->b * t * t + x->setderiv * t + x->x_setval;
+
+ outlet_float(x->x_obj.ob_outlet, tmp);
+ clock_delay(x->x_clock,
+ (x->x_grain > msectogo ? msectogo : x->x_grain));
+ }
+}
+
+void line3_float(t_line3 *x, t_float f)
+{
+ double timenow = clock_getsystime();
+ if (x->x_gotinlet && x->x_in1val > 0)
+ {
+ if (timenow > x->x_targettime)
+ {
+ x->x_setval = x->x_targetval;
+ x->setderiv = 0;
+ }
+ else
+ {
+ x->x_setval = x->a * (timenow - x->x_prevtime) * (timenow - x->x_prevtime) * (timenow - x->x_prevtime) + x->b * (timenow - x->x_prevtime) * (timenow - x->x_prevtime) + x->setderiv * (timenow - x->x_prevtime) + x->x_setval;
+
+ x->setderiv = 3 * x->a * (timenow - x->x_prevtime) * (timenow - x->x_prevtime) + 2 * x->b * (timenow - x->x_prevtime) + x->setderiv;
+
+ }
+
+ x->x_prevtime = timenow;
+ x->x_targettime = clock_getsystimeafter(x->x_in1val);
+ x->x_targetval = f;
+ x->x_1overtimediff = 1./ (x->x_targettime - timenow);
+
+ x->a = -2 * (x->x_targetval - x->x_setval) * x->x_1overtimediff;
+ x->a += x->setderiv;
+ x->a *= x->x_1overtimediff;
+ x->a *= x->x_1overtimediff;
+
+ x->b = 3 * (x->x_targetval - x->x_setval) * x->x_1overtimediff;
+ x->b -= 2 * x->setderiv;
+ x->b *= x->x_1overtimediff;
+
+ line3_tick(x);
+ x->x_gotinlet = 0;
+
+ clock_delay(x->x_clock, (x->x_grain > x->x_in1val ? x->x_in1val : x->x_grain));
+ }
+ else
+ {
+ clock_unset(x->x_clock);
+ x->x_targetval = x->x_setval = f;
+ outlet_float(x->x_obj.ob_outlet, f);
+ }
+ x->x_gotinlet = 0;
+}
+
+void line3_ft1(t_line3 *x, t_floatarg g)
+{
+ x->x_in1val = g;
+ x->x_gotinlet = 1;
+}
+
+void line3_stop(t_line3 *x)
+{
+ x->x_targetval = x->x_setval;
+ clock_unset(x->x_clock);
+}
+
+void line3_set(t_line3 *x, t_floatarg f)
+{
+ clock_unset(x->x_clock);
+ x->x_targetval = x->x_setval = f;
+ x->setderiv = 0;
+}
+
+void line3_free(t_line3 *x)
+{
+ clock_free(x->x_clock);
+}
+
+void *line3_new(t_floatarg f, t_floatarg grain)
+{
+ t_line3 *x = (t_line3 *)pd_new(line3_class);
+ x->x_targetval = x->x_setval = f;
+ x->x_gotinlet = 0;
+ x->setderiv = 0;
+ x->x_1overtimediff = 1;
+ x->x_clock = clock_new(x, (t_method)line3_tick);
+ x->x_targettime = x->x_prevtime = clock_getsystime();
+ if (grain <= 0) grain = 20;
+ x->x_grain = grain;
+ outlet_new(&x->x_obj, gensym("float"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
+ return (x);
+}
+
+void line3_setup(void)
+{
+ line3_class = class_new(gensym("line3"), (t_newmethod)line3_new,
+ (t_method)line3_free, sizeof(t_line3), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(line3_class, (t_method)line3_ft1,
+ gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(line3_class, (t_method)line3_stop,
+ gensym("stop"), 0);
+ class_addmethod(line3_class, (t_method)line3_set,
+ gensym("set"), A_FLOAT, 0);
+ class_addfloat(line3_class, (t_method)line3_float);
+}
diff --git a/line3/makefile b/line3/makefile
new file mode 100755
index 0000000..9493e3f
--- /dev/null
+++ b/line3/makefile
@@ -0,0 +1,97 @@
+current:
+ echo make pd_linux, pd_nt, pd_irix5, or pd_irix6
+
+clean: ; rm -f *.pd_linux *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: line3.dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I\tcl\include /I\pds\win32\pd36\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ \pds\win32\pd36\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$*_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: line3.pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+
+SGIINCLUDE = -I../../src/
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 6.x -----------------------
+
+pd_irix6: line3.pd_irix6
+
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+.c.pd_irix6:
+ cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -IPA -n32 -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: line3.pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXINCLUDE = -I../../src/
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm $*.o
+
+# ----------------------- Mac OS X (Darwin) -----------------------
+
+
+pd_darwin: line3.pd_darwin
+
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -DUNIX -DMACOSX -O2 \
+ -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+# where is your m_pd.h ???
+DARWININCLUDE = -I/. -I../pd/src -I../pd/obj
+
+.c.pd_darwin:
+ cc $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c
+ cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o ../$*.pd_darwin
+ ln -s $*/$*.pd_darwin ..
+
+
+