From ca2bce5efde0b5b296806df0c426f88d874eb530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 13 Mar 2006 15:59:40 +0000 Subject: added the missing files from Gem's MarkEx svn path=/trunk/externals/markex/; revision=4698 --- GEM.LICENSE.TERMS | 226 ++++++------------------------------------------------ Makefile | 23 ++++-- abs~.c | 2 +- hsv2rgb.c | 125 ++++++++++++++++++++++++++++++ reson~.c | 2 +- rgb2hsv.c | 118 ++++++++++++++++++++++++++++ vector+.c | 66 ++++++++++++++++ vector-.c | 67 ++++++++++++++++ vector0x2a.c | 71 +++++++++++++++++ vector0x2f.c | 67 ++++++++++++++++ vectorabs.c | 60 +++++++++++++++ vectorpack.c | 62 +++++++++++++++ 12 files changed, 675 insertions(+), 214 deletions(-) create mode 100644 hsv2rgb.c create mode 100644 rgb2hsv.c create mode 100644 vector+.c create mode 100644 vector-.c create mode 100644 vector0x2a.c create mode 100644 vector0x2f.c create mode 100644 vectorabs.c create mode 100644 vectorpack.c diff --git a/GEM.LICENSE.TERMS b/GEM.LICENSE.TERMS index 878e741..59bc1f9 100644 --- a/GEM.LICENSE.TERMS +++ b/GEM.LICENSE.TERMS @@ -1,204 +1,22 @@ -GEM - Graphics Environment for Multimedia -Copyright (C) 1997-2000 Mark Danks -Copyright (C) Günter Geiger -Copyright (C) 2001-2002 IOhannes m zmölnig - -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. - -In the official GEM distribution, the GNU General Public License is -in the file GnuGPL.LICENSE - ---------------------------------------------------------- - - ACKNOWLEDGMENTS - ---------------------------------------------------------- -Not all of the source code provided here has entirely been written by me. -I would like to point at the great openGL-tutorials at http://nehe.gamedev.net -Since these are tutorials, there is no copyright notice here. -Some of the pix_fx code is borrowed from effecTV by Kentarou Fukuchi et al. -at http://effectv.sourceforge.net released under the Gnu GPL. -Future releases might also incorporate the FreeJ-tool by Jaromil -at http://freej.dyne.org/ released under the Gnu GPL. - - ---------------------------------------------------------- - - OTHER COPYRIGHT NOTICES - ---------------------------------------------------------- - - -This file contains all of the licenses from the various libraries which -are included in GEM. If there is no license associated with a -library, then the author has not included one or not required that the -full license be included. - -All of the files and documentation for the various libraries in the -"Gemlibs" portion of GEM are copyrighted by their respective authors -and not by Mark Danks/Guenter Geiger/IOhannes m zmoelnig. All copyright notices are included in the -respective library directories, GemLibs/*, and this file. -The "GemLibs" portion of GEM consists of - -libTiff: - Author: Sam Leffner - sam@engr.sgi.com - ftp://ftp.sgi.com/graphics/tiff/ - Copyright (c) 1988-1996 Sam Leffler - Copyright (c) 1991-1996 Silicon Graphics, Inc. - see license below - -fstimage: - Masayuki Matsumoto - sgi image loader. - matumot@dst.nk-exa.co.jp - Copyright (C) 1995 Masayuki Mastumoto - Modified so that it doesn't exit on error. - Added support for reading grayscale, rgb, and rgba images - Mark Danks - 1998 - -libjpeg: - Author: Independent JPEG Group - jpeg-info@uunet.uu.net - ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/ - Copyright (C) 1991-1996, Thomas G. Lane. - -Glut: - Author: Mark Kilgard - http://reality.sgi.com/mjk_asd/ - Copyright 1996 by Evans & Sutherland Computer Corporation. - -GLTT: - Author: Stephane Rehel - rehel@worldnet.fr - http://home.worldnet.fr/~rehel/gltt/gltt.html - Copyright (C) 1991 Stephane Rehel - This is covered under the GNU Library General Public License, - Version 2 or greater. - -Freetype: - Authors: David Turner, Robert Wilhelm, and Werner Lemberg - turner@enst.fr - robert@physiol.med.tu-muenchen.de - a7971428@unet.univie.ac.at - http://www.physiol.med.tu-muenchen.de/~robert/freetype.html - Copyright 1996,1997 by David Turner, Robert Wilhelm, and Werner Lemberg - -libmpeg: - Authors: MPEG Software Simulation Group - mssg@mpeg.org - http://www.mpeg.org/MSSG/ - Copyright (c) 1996 MPEG Software Simulation Group - -Wintab: - Author: Rick Poyner, LCS/Telegraphics - wintab@pointing.com - Copyright 1991-1995 by LCS/Telegraphics. - see license below - -libOrb: - Author: John Stone - j.stone@acm.org - http://www.umr.edu/~johns/projects/liborb/ - Copyright (c) 1997-1998 John E. Stone - see license below - -particle: - Author: David McAllister - davemc@cs.unc.edu - http://www.cs.unc.edu/~davemc/Particle/ - Copyright (c) 1998 David K. McAllister - ----------------------------------------------------------------------------- -libTiff: - Author: Sam Leffner - sam@engr.sgi.com - ftp://ftp.sgi.com/graphics/tiff/ - Copyright (c) 1988-1996 Sam Leffler - Copyright (c) 1991-1996 Silicon Graphics, Inc. - -Copyright (c) 1988-1996 Sam Leffler -Copyright (c) 1991-1996 Silicon Graphics, Inc. - -Permission to use, copy, modify, distribute, and sell this software and -its documentation for any purpose is hereby granted without fee, provided -that (i) the above copyright notices and this permission notice appear in -all copies of the software and related documentation, and (ii) the names of -Sam Leffler and Silicon Graphics may not be used in any advertising or -publicity relating to the software without the specific, prior written -permission of Sam Leffler and Silicon Graphics. - -THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -OF THIS SOFTWARE. - - ----------------------------------------------------------------------------- -Wintab: - Author: Rick Poyner, LCS/Telegraphics - wintab@pointing.com - - The Wintab specification is intended to be an open standard. The - Wintab Programmer's Kit is an aid to understanding the Wintab - standard and implementing Wintab-compliant applications. As such, - the text and information contained herein may be freely used, copied, - or distributed without compensation or licensing restrictions. - - The Wintab Programmer's Kit is copyright 1991-1995 by - LCS/Telegraphics. - - LCS/Telegraphics does not assume any liability for damages resulting - from the use of the information contained herein. - ----------------------------------------------------------------------------- -libOrb: - -/* - * Copyright (c) 1997, 1998 John E. Stone (j.stone@acm.org) - * All rights reserved. - * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John E. Stone - * 4. 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. - */ +GEM - Graphics Environment for Multimedia +Copyright (C) 1997-2000 Mark Danks +Copyright (C) Günter Geiger +Copyright (C) 2001-2002 IOhannes m zmölnig + +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. + +In the official GEM distribution, the GNU General Public License is +in the file GnuGPL.LICENSE + diff --git a/Makefile b/Makefile index 5039f93..a4c67d2 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ -CC=gcc +current: + echo make pd_darwin, pd_linux -current: pd_darwin + +SOURCES=$(sort $(filter %.c, $(wildcard *.c))) + +OTARGETS = $(SOURCES:.c=.o) # ----------------------- DARWIN ----------------------- -# replace this line with the one above, since this one has been hacked up -pd_darwin: alternate.pd_darwin gem_average.pd_darwin gem_change.pd_darwin gem_counter.pd_darwin invert.pd_darwin multiselect.pd_darwin oneshot.pd_darwin randomF.pd_darwin strcat.pd_darwin tripleLine.pd_darwin tripleRand.pd_darwin +TARGETS = $(SOURCES:.c=.pd_darwin) .SUFFIXES: .pd_darwin @@ -15,15 +18,17 @@ DARWINCFLAGS = -DMACOSX -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \ DARWININCLUDE = -I/usr/local/lib/pd/include -I../../pd/src -I /usr/local/include -.c.pd_darwin: +$(TARGETS): %.pd_darwin : %.c $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c $(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o -lc -lm rm $*.o +pd_darwin: $(TARGETS) + # ----------------------- LINUX ----------------------- -pd_linux: alternate.pd_linux gem_average.pd_linux gem_change.pd_linux gem_counter.pd_linux invert.pd_linux multiselect.pd_linux oneshot.pd_linux randomF.pd_linux strcat.pd_linux tripleLine.pd_linux tripleRand.pd_linux +TARGETS = $(SOURCES:.c=.pd_linux) .SUFFIXES: .pd_linux @@ -33,12 +38,14 @@ LINUXCFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \ LINUXINCLUDE = -I/usr/local/lib/pd/include -I../../pd/src -.c.pd_linux: +$(TARGETS): %.pd_linux : %.c $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm + $(LD) -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm strip --strip-unneeded $*.pd_linux rm $*.o +pd_linux: $(TARGETS) + # ----------------------- CLEAN ----------------------- clean: ; rm -f *.pd_* *.o *~ diff --git a/abs~.c b/abs~.c index 3078139..99ef457 100644 --- a/abs~.c +++ b/abs~.c @@ -35,7 +35,7 @@ static void abs_dsp(t_abs *x, t_signal **sp) dsp_add(abs_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } -static void *abs_new() +static void *abs_new(void) { t_abs *x = (t_abs *)pd_new(abs_class); outlet_new(&x->x_obj, &s_signal); diff --git a/hsv2rgb.c b/hsv2rgb.c new file mode 100644 index 0000000..03fc316 --- /dev/null +++ b/hsv2rgb.c @@ -0,0 +1,125 @@ +//////////////////////////////////////////////////////// +// +// GEM - Graphics Environment for Multimedia +// +// mark@danks.org +// +// Copyright (c) 1997-1999 Mark Danks. +// For information on usage and redistribution, and for a DISCLAIMER OF ALL +// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. +// +///////////////////////////////////////////////////////// + +#include "m_pd.h" +#include + +inline float FLOAT_CLAMP(float x) { return((x > 1.f) ? 1.f : ( (x < 0.f) ? 0.f : x)); } + +///////////////////////////////////////////////////////// +// +// hsv2rgb +// +///////////////////////////////////////////////////////// +// instance structure +static t_class *hsv2rgb_class; + +typedef struct _hsv2rgb +{ + t_object x_obj; // obligatory object header + t_outlet *t_out1; // the outlet +}t_hsv2rgb; + +static void hsv2rgb_float(t_hsv2rgb *x, t_floatarg h, t_floatarg s, t_floatarg v) +{ + t_atom argv[3]; + float r=0, g=0, b=0; + + h = FLOAT_CLAMP(h); + s = FLOAT_CLAMP(s); + v = FLOAT_CLAMP(v); + + // convert hue to degrees + h *= 360.f; + + if (s == 0.0) // black and white + { + r = g = b = v; + } + else + { + if (h == 360.0) // 360 == 0 degrees + h = 0.0f; + h /= 60.0f; // hue is now [0, 6] + { + int i = (int)floor(h); + float f = h - i; // f is the fractional part of h + float p = v * (1 - s); + float q = v * (1 - s * f); + float t = v * (1 - s * (1 - f)); + + switch (i) + { + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + case 5: + r = v; + g = p; + b = q; + break; + } + } + } + SETFLOAT(&argv[0], r); + SETFLOAT(&argv[1], g); + SETFLOAT(&argv[2], b); + outlet_list(x->t_out1, &s_list, 3, argv); +} + +static void hsv2rgb_list(t_hsv2rgb *x, t_symbol *sym, int argc, t_atom *argv) +{ + if (argc >= 3) + { + float h = atom_getfloat(&argv[0]); + float s = atom_getfloat(&argv[1]); + float v = atom_getfloat(&argv[2]); + hsv2rgb_float(x, h, s, v); + } +} + +static void *hsv2rgb_new(void) // init vals in struct +{ + t_hsv2rgb *x = (t_hsv2rgb *)pd_new(hsv2rgb_class); + x->t_out1 = outlet_new(&x->x_obj, 0); + return (x); +} + +void hsv2rgb_setup(void) +{ + hsv2rgb_class = class_new(gensym("hsv2rgb"), (t_newmethod)hsv2rgb_new, 0, + sizeof(t_hsv2rgb), CLASS_DEFAULT, A_NULL); + class_addlist(hsv2rgb_class, (t_method)hsv2rgb_list); +} + diff --git a/reson~.c b/reson~.c index 26aa245..7ff7a5b 100644 --- a/reson~.c +++ b/reson~.c @@ -143,7 +143,7 @@ void *sigreson_new(t_floatarg f, t_floatarg g) return (x); } -void reson_tilde_setup() +void reson_tilde_setup(void) { sigreson_class = class_new(gensym("reson~"), (t_newmethod)sigreson_new, (t_method)sigreson_ff, sizeof(t_sigreson), 0, diff --git a/rgb2hsv.c b/rgb2hsv.c new file mode 100644 index 0000000..9bc4f78 --- /dev/null +++ b/rgb2hsv.c @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////// +// +// GEM - Graphics Environment for Multimedia +// +// mark@danks.org +// +// Copyright (c) 1997-1999 Mark Danks. +// For information on usage and redistribution, and for a DISCLAIMER OF ALL +// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. +// +///////////////////////////////////////////////////////// + +#include "m_pd.h" +#include + +inline float FLOAT_CLAMP(float x) { return((x > 1.f) ? 1.f : ( (x < 0.f) ? 0.f : x)); } + +static inline float TRI_MAX(float v1, float v2, float v3) +{ if (v1 > v2 && v1 > v3) return(v1); + if (v2 > v3) return(v2); + return(v3); +} + +static inline float TRI_MIN(float v1, float v2, float v3) +{ if (v1 < v2 && v1 < v3) return(v1); + if (v2 < v3) return(v2); + return(v3); +} + +///////////////////////////////////////////////////////// +// +// rgb2hsv +// +///////////////////////////////////////////////////////// +// instance structure +static t_class *rgb2hsv_class; + +typedef struct _rgb2hsv +{ + t_object x_obj; /* obligatory object header */ + t_outlet *t_out1; /* the outlet */ +}t_rgb2hsv; + +static void rgb2hsv_float(t_rgb2hsv *x, t_floatarg r, t_floatarg g, t_floatarg b) +{ + t_atom argv[3]; + + float h=0, s, v; + + r = FLOAT_CLAMP(r); + g = FLOAT_CLAMP(g); + b = FLOAT_CLAMP(b); + float max = TRI_MAX(r, g, b); + float min = TRI_MIN(r, g, b); + v = max; // the value + + // calculate saturation + if (max != 0.0f) + s = (max - min) / max; + else + s = 0.0f; + + if (s == 0.0f) + { + h = 0.0f; // hue is undefined if no saturation + } + // chromatic case - calculate hue + else + { + float delta = max - min; + if (r == max) // between magenta and cyan + h = (g - b) / delta; + else if (g == max) // between yellow and magenta + h = 2.0f + (b - r) / delta; + else if (b == max) // between cyan and yellow + h = 4.0f + (r - g) / delta; + + // convert hue to degrees + h *= 60.0f; + // make sure hue is nonnegative + if (h < 0.0) + h += 360.f; + // normalize hue + h /= 360.f; + } + + SETFLOAT(&argv[0], h); + SETFLOAT(&argv[1], s); + SETFLOAT(&argv[2], v); + + outlet_list(x->t_out1, &s_list, 3, argv); +} + +static void rgb2hsv_list(t_rgb2hsv *x, t_symbol *s, int argc, t_atom *argv) +{ + if (argc >= 3) + { + float r = atom_getfloat(&argv[0]); + float g = atom_getfloat(&argv[1]); + float b = atom_getfloat(&argv[2]); + rgb2hsv_float(x, r, g, b); + } +} + +static void *rgb2hsv_new(void) // init vals in struct +{ + t_rgb2hsv *x = (t_rgb2hsv *)pd_new(rgb2hsv_class); + x->t_out1 = outlet_new(&x->x_obj, 0); + return (x); +} + +void rgb2hsv_setup(void) +{ + rgb2hsv_class = class_new(gensym("rgb2hsv"), (t_newmethod)rgb2hsv_new, 0, + sizeof(t_rgb2hsv), CLASS_DEFAULT, A_NULL); + + class_addlist(rgb2hsv_class, (t_method)rgb2hsv_list); +} diff --git a/vector+.c b/vector+.c new file mode 100644 index 0000000..9e7a193 --- /dev/null +++ b/vector+.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +// -------------------------- vector+ ------------------------------ + +// instance structure +static t_class *vectorPlus_class; + +typedef struct _vectorPlus +{ + t_object x_obj; + t_float x_add; + t_atom *m_list; + int m_num; + t_outlet *t_out1; // the outlet +} t_vectorPlus; + +static void doVectorPlus(t_vectorPlus *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if (argc > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * argc); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + temp += x->x_add; + SETFLOAT((&x->m_list[i]), temp); + } + outlet_list(x->t_out1, &s_list, argc, x->m_list); +} + +static void *vectorPlus_new(t_floatarg n) +{ + t_vectorPlus *x = (t_vectorPlus *)pd_new(vectorPlus_class); + x->x_add = (float)n; + floatinlet_new(&x->x_obj, &x->x_add); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 3; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +static void vectorPlus_setup(void) +{ + vectorPlus_class = class_new(gensym("vector+"), (t_newmethod)vectorPlus_new, 0, + sizeof(t_vectorPlus), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)vectorPlus_new, gensym("v+"), A_DEFFLOAT, 0); + class_addmethod(vectorPlus_class, (t_method)doVectorPlus, + &s_list, A_GIMME, A_NULL); +} + +void setup_vector0x2b(void){ + vectorPlus_setup(); +} + +void setup_v0x2b(void){ + vectorPlus_setup(); +} diff --git a/vector-.c b/vector-.c new file mode 100644 index 0000000..dd0f8a3 --- /dev/null +++ b/vector-.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +/* -------------------------- vector- ------------------------------ */ + +/* instance structure */ +static t_class *vectorMinus_class; + +typedef struct _vectorMinus +{ + t_object x_obj; + t_float x_minus; + t_atom *m_list; + int m_num; + t_outlet *t_out1; /* the outlet */ +} t_vectorMinus; + +static void doVectorMinus(t_vectorMinus *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if (argc > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * argc); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + temp -= x->x_minus; + SETFLOAT((&x->m_list[i]), temp); + } + outlet_list(x->t_out1, &s_list, argc, x->m_list); +} + +static void *vectorMinus_new(t_floatarg n) +{ + t_vectorMinus *x = (t_vectorMinus *)pd_new(vectorMinus_class); + x->x_minus = (float)n; + floatinlet_new(&x->x_obj, &x->x_minus); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 3; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +static void vectorMinus_setup(void) +{ + vectorMinus_class = class_new(gensym("vector-"), (t_newmethod)vectorMinus_new, 0, + sizeof(t_vectorMinus), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)vectorMinus_new, gensym("v-"), A_DEFFLOAT, 0); + class_addmethod(vectorMinus_class, (t_method)doVectorMinus, + &s_list, A_GIMME, A_NULL); +} + + +void setup_vector0x2d(void){ + vectorMinus_setup(); +} + +void setup_v0x2d(void){ + vectorMinus_setup(); +} diff --git a/vector0x2a.c b/vector0x2a.c new file mode 100644 index 0000000..4709fd7 --- /dev/null +++ b/vector0x2a.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +/* -------------------------- vector* ------------------------------ */ + +/* instance structure */ +static t_class *vectorMult_class; + +typedef struct _vectorMult +{ + t_object x_obj; + t_float x_mult; + t_atom *m_list; + int m_num; + t_outlet *t_out1; /* the outlet */ +} t_vectorMult; + +static void doVectorMult(t_vectorMult *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if (argc > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * argc); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + temp *= x->x_mult; + SETFLOAT((&x->m_list[i]), temp); + } + outlet_list(x->t_out1, &s_list, argc, x->m_list); +} + +static void *vectorMult_new(t_floatarg n) +{ + t_vectorMult *x = (t_vectorMult *)pd_new(vectorMult_class); + x->x_mult = (float)n; + floatinlet_new(&x->x_obj, &x->x_mult); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 3; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +static void vectorMult_setup(void) +{ + vectorMult_class = class_new(gensym("vector*"), (t_newmethod)vectorMult_new, 0, + sizeof(t_vectorMult), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)vectorMult_new, gensym("v*"), A_DEFFLOAT, 0); + class_addmethod(vectorMult_class, (t_method)doVectorMult, + &s_list, A_GIMME, A_NULL); +} + +void setup_vector0x2a(void){ + vectorMult_setup(); +} +void vector0x2a_setup(void){ + vectorMult_setup(); +} +void setup_v0x2a(void){ + vectorMult_setup(); +} +void v0x2a_setup(void){ + vectorMult_setup(); +} diff --git a/vector0x2f.c b/vector0x2f.c new file mode 100644 index 0000000..f75cade --- /dev/null +++ b/vector0x2f.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +/* -------------------------- vector/ ------------------------------ */ + +/* instance structure */ +static t_class *vectorDiv_class; + +typedef struct _vectorDiv +{ + t_object x_obj; + t_float x_div; + t_atom *m_list; + int m_num; + t_outlet *t_out1; /* the outlet */ +} t_vectorDiv; + +static void doVectorDiv(t_vectorDiv *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if (argc > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * argc); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + temp /= x->x_div; + SETFLOAT((&x->m_list[i]), temp); + } + outlet_list(x->t_out1, &s_list, argc, x->m_list); +} + +static void *vectorDiv_new(t_floatarg n) +{ + t_vectorDiv *x = (t_vectorDiv *)pd_new(vectorDiv_class); + x->x_div = (float)n; + floatinlet_new(&x->x_obj, &x->x_div); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 3; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +static void vectorDiv_setup(void) +{ + vectorDiv_class = class_new(gensym("vector/"), (t_newmethod)vectorDiv_new, 0, + sizeof(t_vectorDiv), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)vectorDiv_new, gensym("v/"), A_DEFFLOAT, 0); + class_addmethod(vectorDiv_class, (t_method)doVectorDiv, + &s_list, A_GIMME, A_NULL); +} + + +void setup_vector0x2f(void){ + vectorDiv_setup(); +} + +void setup_v0x2f(void){ + vectorDiv_setup(); +} diff --git a/vectorabs.c b/vectorabs.c new file mode 100644 index 0000000..a099f5f --- /dev/null +++ b/vectorabs.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +/* -------------------------- vectorabs ------------------------------ */ + +/* instance structure */ +static t_class *vectorAbs_class; + +typedef struct _vectorAbs +{ + t_object x_obj; + t_atom *m_list; + int m_num; + t_outlet *t_out1; /* the outlet */ +} t_vectorAbs; + +static void doVectorAbs(t_vectorAbs *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if (argc > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * argc); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + if (temp < 0.f) + temp = temp * -1.f; + SETFLOAT((&x->m_list[i]), temp); + } + outlet_list(x->t_out1, &s_list, argc, x->m_list); +} + +static void *vectorAbs_new(void) +{ + t_vectorAbs *x = (t_vectorAbs *)pd_new(vectorAbs_class); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 3; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +void vectorabs_setup(void) +{ + vectorAbs_class = class_new(gensym("vectorabs"), (t_newmethod)vectorAbs_new, 0, + sizeof(t_vectorAbs), 0, A_NULL); + class_addcreator((t_newmethod)vectorAbs_new, gensym("vabs"), A_NULL); + class_addmethod(vectorAbs_class, (t_method)doVectorAbs, + &s_list, A_GIMME, A_NULL); +} + +void vabs_setup(void){ + vectorabs_setup(); +} diff --git a/vectorpack.c b/vectorpack.c new file mode 100644 index 0000000..4a77235 --- /dev/null +++ b/vectorpack.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + + +/* -------------------------- vectorpack ------------------------------ */ + +static t_class *vectorPack_class; + +typedef struct _vectorPack +{ + t_object x_obj; + t_float x_val; + t_atom *m_list; + int m_num; + t_outlet *t_out1; /* the outlet */ +} t_vectorPack; + +static void doVectorPack(t_vectorPack *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + if ((argc + 1) > x->m_num) + { + x->m_list = (t_atom *)resizebytes(x->m_list, sizeof(t_atom) * x->m_num, sizeof(t_atom) * (argc + 1)); + x->m_num = argc; + } + for (i = 0; i < argc; i++) + { + float temp = atom_getfloat(&argv[i]); + SETFLOAT((&x->m_list[i]), temp); + } + SETFLOAT((&x->m_list[argc]), x->x_val); + outlet_list(x->t_out1, &s_list, (argc + 1), x->m_list); +} + +static void *vectorPack_new(t_floatarg n) +{ + t_vectorPack *x = (t_vectorPack *)pd_new(vectorPack_class); + x->x_val = (float)n; + floatinlet_new(&x->x_obj, &x->x_val); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->m_num = 4; + x->m_list = (t_atom *)getbytes(sizeof(t_atom) * x->m_num); + return (x); +} + +void vectorpack_setup(void) +{ + vectorPack_class = class_new(gensym("vectorpack"), (t_newmethod)vectorPack_new, 0, + sizeof(t_vectorPack), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)vectorPack_new, gensym("vpack"), A_DEFFLOAT, 0); + class_addmethod(vectorPack_class, (t_method)doVectorPack, + &s_list, A_GIMME, A_NULL); +} + +void vpack_setup(void){ + vectorpack_setup(); +} -- cgit v1.2.1