pax_global_header00006660000000000000000000000064140246230770014517gustar00rootroot0000000000000052 comment=95777602dff8ae074b7a47a9db7fecda5d94281d ggee-0.28/000077500000000000000000000000001402462307700123575ustar00rootroot00000000000000ggee-0.28/AUTHORS000066400000000000000000000010041402462307700134220ustar00rootroot00000000000000 Guenter Geiger with the help of many people, pd Miller Puckette piperead and pipewrite d13 sfplay Winfried Ritsch mixer and others opt@test.at suggestions and testing klaus@xdv.org vbap Ville Pulkki filters math Robert Bristow-Johnson and several others which I may have forgotten to mention, please notify me if you feel you should be included. ggee-0.28/CHANGES000066400000000000000000000060371402462307700133600ustar00rootroot000000000000000.1 First compilation, changed object names to include "~" 0.2 Added basic fof~ object 0.3 added Windows nt support (no sfread yet) 0.4 added the format message to streamout~ (will be autodetected by streamin~). improved fof~ (offset bug, signal frequency) added adsr~ object. 0.5 fixed deadlock bug in streamin~ - streamout~ added 8bit format, fixed makefile flags for alpha (-mieee) added host message and default arguments to streamout~ 0.6 added sfwrite object compilation support for Windows added state object (savestate) added slider object 0.7 envgen~ prototype bugfixes in sfread (multichannel, added loop switch) initialization bug in state object, added support for saving with symbols toddle object (was here in 0.6 already) 0.8 state - in order to prevent overwriting of states, the save messages stays only valid for 2 seconds now. state - initialization bug slider - made slider thicker envgen - added freeze message to envgen, fixed bug in duration setting delete points when deleting widget, reorganized durations structure, fixed bug during object instantiation. 0.9 envgen is a message object now, which sends messages to a line~ implemented state for envgen. 0.10 added stk object. 0.11 - 0.12 fixed bug in ticker (moving when on) added several objects serial (speeks the Micosoft Mouse protocol) rtout (for sending realtime (raw) midi messages) locals, localr (sending messages locally) 1/x~ , 1/x ... simple shortcuts for the inverse fasor~ ( a phasor which changes it's frequency only on phase 0) sfplay ... from Winfried Ritsch unwonk .. an unpack which sends it's rest through the last outlet atan2~ ... the signal arctan to figure out phase values. This is very slow. 0.14 - slider: now has a width argument, thanks to dieter@rhiz.org fixed the "drawing when hidden" bug. - readserial: several updates for the MicroTouch ThruGlass controller - log~, exp~, .. just what they say, very bad performers .... - envgen memory bug fixed. - sfread fixed segfault when open fails during play 0.15 - added different filter objects, which create lists suitable for biquad. - again several other minor bugfixes - first implementation of a dynamic mixer object - added wave header for sfwrite, improved performance 0.16 - renamed ggext to ggee, new compilation scheme which produces single externals - speed improvments for sfread~ 0.17 - fixed build problem for "make ggext" 0.18 0.19 - rewrote selections for envgen. - added (endoffile) bang to sfplay if file is not found 0.20 - fixed shell external 0.21 - added patch from to serialize - fixed pipe exhaustion problem in shell 0.22 - removed the GUI Objects Slider, HSlider, toddle, ticker 0.23 - updated the stk external to use stk 3.2 0.24 - moved moog~ to filters, improved stability. 0.25 - big GUI revival with face lifting 0.26 - fixed for packaging for Debian ggee-0.28/LICENSE.txt000066400000000000000000000032111402462307700141770ustar00rootroot00000000000000This software is copyrighted by Guenter Geiger and others. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. RESTRICTED RIGHTS: Use, duplication or disclosure by the government is subject to the restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software Clause as DFARS 252.227-7013 and FAR 52.227-19. ggee-0.28/Makefile000066400000000000000000000041611402462307700140210ustar00rootroot00000000000000#!/usr/bin/make -f # Makefile to the 'ggee' library for Pure Data. # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build # settings and rules (https://github.com/pure-data/pd-lib-builder). lib.name = ggee # special file that does not provide a class lib.setup.sources = # all other C and C++ files in subdirs are source files per class # (alternatively, enumerate them by hand) class.sources = \ control/constant.c \ control/rl.c \ control/serial_ms.c \ control/sl.c \ control/getdir.c \ control/rtout.c \ control/serial_mt.c \ control/stripdir.c \ control/inv.c \ control/serial_bird.c \ control/shell.c \ control/unserialize.c \ control/qread.c \ control/serialize.c \ control/sinh.c \ control/unwonk.c \ experimental/fofsynth~.c \ experimental/tabwrite4~.c \ experimental/pvocfreq.c \ filters/bandpass.c \ filters/highpass.c \ filters/hlshelf.c \ filters/lowshelf.c \ filters/notch.c \ filters/equalizer.c \ filters/highshelf.c \ filters/lowpass.c \ filters/moog~.c \ gui/button.c \ gui/image.c \ gui/sliderh.c \ gui/ticker.c \ gui/envgen.c \ gui/gcanvas.c \ gui/slider.c \ gui/state.c \ gui/toddle.c \ signal/atan2~.c \ signal/mixer~.c \ signal/sfwrite~.c \ signal/streamin~.c \ signal/streamout~.c \ $(nada) #class.sources += \ # gui/fatom.c datafiles = \ $(wildcard */*-help.pd) \ LICENSE.txt \ README.txt \ gui/state.list \ gui/logo100.gif \ ggee-meta.pd \ $(nada) datadirs = define forWindows ldlibs = -lwsock32 endef #cflags = -DVERSION=$(lib.version) ################################################################################ ### pdlibbuilder ############################################################### ################################################################################ # This Makefile is based on the Makefile from pd-lib-builder written by # Katja Vetter. You can get it from: # https://github.com/pure-data/pd-lib-builder PDLIBBUILDER_DIR=./pd-lib-builder include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder ggee-0.28/README.txt000066400000000000000000000011441402462307700140550ustar00rootroot00000000000000 ggee is a library by Guenter Geiger with five sections: control, experimental, filters, gui, and signal. * objects for controlling things: constant rl serial_ms sl getdir rtout serial_mt stripdir inv serial_bird shell unserialize qread serialize sinh unwonk * experimental synths: fofsynth~ tabwrite4~ pvocfreq * objects for controlling filters: bandpass highpass hlshelf lowshelf notch equalizer highshelf lowpass moog~ * GUI objects: button fatom image sliderh ticker envgen gcanvas slider state toddle * manipulating signals: atan2~ mixer~ sfwrite~ streamin~ streamout~ Guenter Geiger ggee-0.28/VERSION000066400000000000000000000000051402462307700134220ustar00rootroot000000000000000.28 ggee-0.28/control/000077500000000000000000000000001402462307700140375ustar00rootroot00000000000000ggee-0.28/control/constant-help.pd000066400000000000000000000024331402462307700171450ustar00rootroot00000000000000#N canvas 295 289 450 300 10; #N canvas 952 360 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 65 INLET_0 bang; #X text 12 85 OUTLET_0 float; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION get the value of the constants pi \, 2pi \, or e; #X restore 392 272 pd META; #X text 22 22 get the value of the constants pi \, 2pi \, or e; #X obj 28 63 loadbang; #X floatatom 195 141 10 0 0 0 - - -; #X obj 195 119 constant pi; #X floatatom 275 141 10 0 0 0 - - -; #X obj 275 119 constant 2pi; #X floatatom 355 141 10 0 0 0 - - -; #X obj 355 119 constant e; #X floatatom 48 199 10 0 0 0 - - -; #X floatatom 128 199 10 0 0 0 - - -; #X floatatom 218 199 10 0 0 0 - - -; #X obj 48 177 constant PI; #X obj 128 177 constant M_PI; #X obj 218 177 constant TWOPI; #X floatatom 28 265 10 0 0 0 - - -; #X obj 28 243 constant; #X text 34 220 It defaults to the value of pi:; #X connect 2 0 4 0; #X connect 2 0 6 0; #X connect 2 0 12 0; #X connect 2 0 13 0; #X connect 2 0 14 0; #X connect 2 0 8 0; #X connect 2 0 16 0; #X connect 4 0 3 0; #X connect 6 0 5 0; #X connect 8 0 7 0; #X connect 12 0 9 0; #X connect 13 0 10 0; #X connect 14 0 11 0; #X connect 16 0 15 0; ggee-0.28/control/constant.c000066400000000000000000000031071402462307700160350ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ constant ----------------------------- */ #ifndef M_PI #define M_PI 3.141593f #endif static t_class *constant_class; typedef struct _constant { t_object x_obj; t_float x_constant; } t_constant; void constant_bang(t_constant *x) { outlet_float(x->x_obj.ob_outlet, x->x_constant); } static void *constant_new(t_symbol* s) { t_constant *x = (t_constant *)pd_new(constant_class); if (s == &s_) x->x_constant = M_PI; else if (!strcmp(s->s_name,"pi")) x->x_constant = M_PI; else if (!strcmp(s->s_name,"2pi")) x->x_constant = 2*M_PI; else if (!strcmp(s->s_name,"e")) x->x_constant = exp(1.0); else if (!strcmp(s->s_name,"M_PI")) x->x_constant = M_PI; else if (!strcmp(s->s_name,"PI")) x->x_constant = M_PI; else if (!strcmp(s->s_name,"TWOPI")) x->x_constant = 2*M_PI; else pd_error(x, "Unsupported constant '%s'", s->s_name); outlet_new(&x->x_obj, &s_float); return (x); } void constant_setup(void) { constant_class = class_new(gensym("constant"), (t_newmethod)constant_new, 0, sizeof(t_constant), 0, A_DEFSYMBOL, 0); class_addbang(constant_class,constant_bang); } ggee-0.28/control/cvs.pd000066400000000000000000000013771402462307700151670ustar00rootroot00000000000000#N canvas 420 4 512 424 10; #X obj 13 338 shell; #X obj 57 386 print; #X msg 13 116 cvs -q update; #X obj 13 361 route ?; #X text 10 97 Click to see changes; #X msg 195 126 fixed_bug_in_shell; #X msg 31 273 cvs commit -m \$1; #X msg 194 152 another_useless_bugfix; #X text 191 100 Click one of these to commit; #X text 13 9 PD CVS access; #X text 118 9 (Yes \, its crazy); #X text 10 57 You will be asked for your password in the console; #X msg 195 185 added_the_cvs_patch; #X text 203 247 Add a new file to the repository; #X msg 202 270 control/cvs.pd; #X msg 52 307 cvs add \$1; #X connect 0 0 3 0; #X connect 2 0 0 0; #X connect 3 1 1 0; #X connect 5 0 6 0; #X connect 6 0 0 0; #X connect 7 0 6 0; #X connect 12 0 6 0; #X connect 14 0 15 0; #X connect 15 0 0 0; ggee-0.28/control/getdir-help.pd000066400000000000000000000021501402462307700165660ustar00rootroot00000000000000#N canvas 0 26 460 383 10; #X obj 177 95 getdir; #X msg 177 57 bang; #X obj 176 133 print; #X text 17 21 get the directory that this patch is operating in:; #X text 18 165 You can also get the path of the parent patch \, if this patch is an object embedded in another patch. You use the argument to set how many levels up to go:; #X msg 99 212 bang; #X obj 98 288 print; #X obj 99 250 getdir 1; #X msg 294 209 bang; #X obj 293 285 print; #X obj 294 247 getdir 2; #X text 18 331 If there is no parent at that level \, it returns the directory as if there was no argument \, i.e. level 0; #N canvas 407 106 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION get the directory this patch is operating in; #X text 12 65 INLET_0 bang; #X text 12 85 OUTLET_0 symbol; #X text 12 5 KEYWORDS control patchfile_op filesystem; #X restore 410 362 pd META; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 5 0 7 0; #X connect 7 0 6 0; #X connect 8 0 10 0; #X connect 10 0 9 0; ggee-0.28/control/getdir.c000066400000000000000000000023401402462307700154600ustar00rootroot00000000000000/* (C) 2005 Guenter Geiger */ #include "m_pd.h" // HACK !!! struct _glist { t_object gl_obj; /* header in case we're a glist */ t_gobj *gl_list; /* the actual data */ struct _gstub *gl_stub; /* safe pointer handler */ int gl_valid; /* incremented when pointers might be stale */ struct _glist *gl_owner; /* parent glist, supercanvas, or 0 if none */ }; // END HACK !!! typedef struct getdir { t_object x_ob; t_canvas * x_canvas; t_outlet* x_outlet; int x_level; } t_getdir; static void getdir_bang(t_getdir *x) { int i = x->x_level; t_canvas* last = x->x_canvas; while (i>0) { i--; if (last->gl_owner) last = last->gl_owner; } outlet_symbol(x->x_outlet,canvas_getdir(last)); } t_class *getdir_class; static void *getdir_new(t_floatarg level) { t_getdir *x = (t_getdir *)pd_new(getdir_class); x->x_canvas = canvas_getcurrent(); x->x_outlet = outlet_new(&x->x_ob, &s_); x->x_level = level; return (void *)x; } void getdir_setup(void) { getdir_class = class_new(gensym("getdir"), (t_newmethod)getdir_new, 0, sizeof(t_getdir), 0, A_DEFFLOAT,0); class_addbang(getdir_class, getdir_bang); } ggee-0.28/control/inv-help.pd000066400000000000000000000020721402462307700161070ustar00rootroot00000000000000#N canvas 202 49 506 289 10; #X floatatom 32 76 0 0 0 0 - - -; #X floatatom 32 137 0 0 0 0 - - -; #X obj 188 93 sig~ 220; #X floatatom 188 74 0 0 0 0 - - -; #X obj 188 150 1/x~; #X obj 188 192 clip~ -1 1; #X obj 181 222 dac~; #X text 25 267 (C) Guenter Geiger; #X obj 188 111 phasor~; #X obj 188 129 +~ 1; #X obj 188 173 -~ 0.5; #X text 184 54 the signal version doesnt look useful to me; #X text 34 54 To make life easier; #X text 32 12 1/x takes the inverse of the input; #X obj 32 107 inv; #N canvas 408 102 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION perform 1/x using float from inlet; #X text 12 65 INLET_0 float; #X text 12 85 OUTLET_0 float; #X text 12 5 KEYWORDS control; #X restore 387 267 pd META; #X connect 0 0 14 0; #X connect 2 0 8 0; #X connect 3 0 2 0; #X connect 4 0 10 0; #X connect 5 0 6 0; #X connect 5 0 6 1; #X connect 8 0 9 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 14 0 1 0; ggee-0.28/control/inv.c000066400000000000000000000030451402462307700150010ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include typedef struct inv { t_object x_obj; } t_inv; static t_class *inv_class; static void *inv_new(void) { t_inv *x = (t_inv *)pd_new(inv_class); outlet_new(&x->x_obj, gensym("signal")); return (x); } static t_int *inv_perform(t_int *w) /* not static; also used in d_fft.c */ { float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); t_int n = *(t_int *)(w+3); while (n--) { *out++ = 1/ *in++; } return (w + 4); } static void inv_dsp(t_inv *x, t_signal **sp) { dsp_add(inv_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } void inv_tilde_setup(void) { inv_class = class_new(gensym("inv~"), (t_newmethod)inv_new, 0, sizeof(t_inv), 0, 0); class_addcreator(inv_new,gensym("1/x~"),0); class_addmethod(inv_class, nullfn, gensym("signal"), 0); class_addmethod(inv_class, (t_method)inv_dsp, gensym("dsp"), 0); } typedef struct scalarinv { t_object x_obj; } t_scalarinv; static t_class *scalarinv_class; static void *scalarinv_new(void) { t_scalarinv *x = (t_scalarinv *)pd_new(scalarinv_class); outlet_new(&x->x_obj, gensym("float")); return (x); } static void scalarinv_float(t_scalarinv *x,t_float val) { outlet_float(x->x_obj.ob_outlet,1.0f/val); } void inv_setup(void) { scalarinv_class = class_new(gensym("inv"), (t_newmethod)scalarinv_new, 0, sizeof(t_scalarinv), 0, 0); class_addcreator(scalarinv_new,gensym("1/x"),0); class_addfloat(scalarinv_class, (t_method)scalarinv_float); } ggee-0.28/control/qread-help.pd000066400000000000000000000006511402462307700164100ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 140 126 qread; #X text 54 47 placeholder help patch; #N canvas 405 114 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 85 OUTLET_0; #X text 12 65 INLET_0; #X text 12 45 DESCRIPTION; #X text 12 5 KEYWORDS control; #X restore 387 267 pd META; ggee-0.28/control/qread.c000066400000000000000000000047121402462307700153030ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include /* ------------------------ qread ----------------------------- */ #include static t_class *qread_class; #define MAXLINE 255 typedef struct _qread { t_object x_obj; FILE* x_file; int x_size; t_clock* x_clock; t_glist * x_glist; int x_num; t_symbol* x_name; } t_qread; static void qread_open(t_qread *x,t_symbol *filename) { char fname[MAXPDSTRING]; if (filename == &s_) { post("sfread: open without filename"); return; } canvas_makefilename((void*)glist_getcanvas(x->x_glist), filename->s_name, fname, MAXPDSTRING); /* close the old file */ if (x->x_file) fclose(x->x_file); if (!(x->x_file = fopen(fname,"r"))) { error("can't open %s",fname); return; } } void qread_next(t_qread *x) { int i; float delay; char name[MAXLINE]; t_atom at[20]; int ac=0; t_floatarg ff; if (!x->x_file) return; fscanf(x->x_file,"%f",&delay); if (feof(x->x_file)) { clock_unset(x->x_clock); return; } fscanf(x->x_file,"%s",name); #ifdef DEBUG post("next: name = %s delay = %f",name,delay); #endif for (i=0;i<=x->x_num && !feof(x->x_file);i++) { fscanf(x->x_file,"%f",&ff); SETFLOAT(at+i,ff); } ac = i-1; fscanf(x->x_file,";"); clock_delay(x->x_clock,delay); outlet_list(x->x_obj.ob_outlet, gensym(name), ac, at); } static void qread_bang(t_qread *x) { if (!x->x_file) return; fseek(x->x_file,0,SEEK_SET); clock_delay(x->x_clock,0); #ifdef DEBUG post("bang"); #endif } static void qread_stop(t_qread *x) { clock_unset(x->x_clock); } static void *qread_new(t_floatarg n) { t_qread *x = (t_qread *)pd_new(qread_class); outlet_new(&x->x_obj, &s_float); x->x_name = gensym("qread"); x->x_glist = (t_glist*) canvas_getcurrent(); x->x_clock = clock_new(x, (t_method)qread_next); x->x_file = NULL; x->x_num = n; return (x); } void qread_setup(void) { qread_class = class_new(gensym("qread"), (t_newmethod)qread_new, 0, sizeof(t_qread), 0,A_DEFFLOAT,A_NULL); class_addbang(qread_class,qread_bang); class_addmethod(qread_class,(t_method)qread_next,gensym("next"),A_NULL); class_addmethod(qread_class,(t_method)qread_open,gensym("open"),A_SYMBOL,A_NULL); class_addmethod(qread_class,(t_method)qread_stop,gensym("stop"),A_NULL); } ggee-0.28/control/rl-help.pd000066400000000000000000000020511402462307700157250ustar00rootroot00000000000000#N canvas 0 31 450 206 10; #X text 40 131 (C) Guenter Geiger; #N canvas 46 242 494 344 META 0; #X text 12 105 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 85 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION receive local to this canvas; #X text 12 65 OUTLET_0 anything; #X text 12 5 KEYWORDS signal nonlocal canvas_op; #X restore 377 170 pd META; #X text 40 28 receive local to this canvas; #X obj 270 53 rl; #X obj 301 55 sl; #X floatatom 268 90 5 0 0 0 - - -; #X floatatom 303 31 5 0 0 0 - - -; #N canvas 440 128 395 247 local-send-and-receive-for-subpatches 0; #X obj 68 77 rl; #X obj 117 57 sl; #X floatatom 117 22 5 0 0 0 - - -; #X floatatom 68 118 5 0 0 0 - - -; #X connect 0 0 3 0; #X connect 2 0 1 0; #X restore 170 130 pd local-send-and-receive-for-subpatches; #X obj 154 68 receivelocal foo; #X obj 67 97 sendlocal foo; #X floatatom 172 96 5 0 0 0 - - -; #X floatatom 74 58 5 0 0 0 - - -; #X connect 3 0 5 0; #X connect 6 0 4 0; #X connect 8 0 10 0; #X connect 11 0 9 0; ggee-0.28/control/rl.c000066400000000000000000000040751402462307700146260ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* -------------------- lreceive ------------------------------ */ static t_class *lreceive_class; typedef struct _lreceive { t_object x_obj; t_symbol *x_sym; } t_lreceive; static void lreceive_bang(t_lreceive *x) { outlet_bang(x->x_obj.ob_outlet); } static void lreceive_float(t_lreceive *x, t_float f) { outlet_float(x->x_obj.ob_outlet, f); } static void lreceive_symbol(t_lreceive *x, t_symbol *s) { outlet_symbol(x->x_obj.ob_outlet, s); } static void lreceive_pointer(t_lreceive *x, t_gpointer *gp) { outlet_pointer(x->x_obj.ob_outlet, gp); } static void lreceive_list(t_lreceive *x, t_symbol *s, int argc, t_atom *argv) { outlet_list(x->x_obj.ob_outlet, s, argc, argv); } static void lreceive_anything(t_lreceive *x, t_symbol *s, int argc, t_atom *argv) { outlet_anything(x->x_obj.ob_outlet, s, argc, argv); } static void *lreceive_new(t_symbol *s) { t_lreceive *x = (t_lreceive *)pd_new(lreceive_class); char mysym[MAXPDSTRING]; sprintf(mysym,"%s%p",s->s_name,canvas_getcurrent()); x->x_sym = gensym(mysym); pd_bind(&x->x_obj.ob_pd, x->x_sym); outlet_new(&x->x_obj, 0); return (x); } static void lreceive_free(t_lreceive *x) { pd_unbind(&x->x_obj.ob_pd, x->x_sym); } void rl_setup(void) { lreceive_class = class_new(gensym("receivelocal"), (t_newmethod)lreceive_new, (t_method)lreceive_free, sizeof(t_lreceive), CLASS_NOINLET, A_SYMBOL, 0); class_addcreator((t_newmethod)lreceive_new, gensym("rl"), A_DEFSYM, 0); class_addbang(lreceive_class, lreceive_bang); class_addfloat(lreceive_class, (t_method)lreceive_float); class_addsymbol(lreceive_class, lreceive_symbol); class_addpointer(lreceive_class, lreceive_pointer); class_addlist(lreceive_class, lreceive_list); class_addanything(lreceive_class, lreceive_anything); post("Warning: receivelocal (rl) is deprecated, please use \"receive $0-var\" instead"); } ggee-0.28/control/rtout-help.pd000066400000000000000000000006201402462307700164650ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 140 126 rtout; #X text 54 47 placeholder help patch; #N canvas 405 114 494 344 META 0; #X text 12 105 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 85 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION; #X text 12 65 INLET_0; #X text 12 5 KEYWORDS control; #X restore 387 267 pd META; ggee-0.28/control/rtout.c000066400000000000000000000015001402462307700153540ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include /* -------------------------- rtout -------------------------- */ void sys_putmidimess(int portno, int a, int b, int c); static t_class *rtout_class; typedef struct _rtout { t_object x_obj; t_float x_rt; t_float x_channel; } t_rtout; static void *rtout_new(t_floatarg channel) { t_rtout *x = (t_rtout *)pd_new(rtout_class); if (channel <= 0) channel = 1; x->x_channel = channel; return (x); } static void rtout_float(t_rtout *x, t_float f) { int binchan = (int) x->x_channel - 1; sys_putmidimess((binchan>>4),(int) f,0,0); } void rtout_setup(void) { rtout_class = class_new(gensym("rtout"), (t_newmethod)rtout_new, 0, sizeof(t_rtout), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addfloat(rtout_class, rtout_float); } ggee-0.28/control/serial_bird-help.pd000066400000000000000000000031461402462307700175750ustar00rootroot00000000000000#N canvas 0 31 803 464 10; #N canvas 391 259 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 105 OUTLET_1; #X text 12 45 DESCRIPTION interpret the acsension Flock of Birds device. ; #X text 12 65 INLET_0 init poll start mode stop reset; #X text 12 85 OUTLET_0 list; #X text 12 5 KEYWORDS control filesystem needs_work (OUTLET_1?); #X restore 740 435 pd META; #X obj 69 256 serial_bird; #X msg 90 91 start; #X msg 82 57 poll; #X msg 406 99 mode position; #X msg 69 28 init; #X msg 406 82 mode positionangle; #X obj 69 279 unpack 1 2 3 4 5 6; #X floatatom 172 312 0 0 0 0 - - -; #X floatatom 151 333 0 0 0 0 - - -; #X floatatom 130 357 0 0 0 0 - - -; #X floatatom 89 325 0 0 0 0 - - -; #X floatatom 68 346 0 0 0 0 - - -; #X floatatom 47 370 0 0 0 0 - - -; #X text 407 25 The serial_bird object interprets the acsension Flock of Birds device.; #X text 406 53 The mode command sets the output mode (see FOB description for further information; #X text 106 26 Init initializes the serial device; #X text 117 52 poll stops streaming mode and outputs; #X text 117 62 one data set; #X text 128 91 start streaming mode with start; #X obj 172 256 serialctl /dev/ttyS0; #X msg 113 135 stop; #X msg 128 168 reset; #X connect 1 0 7 0; #X connect 2 0 1 0; #X connect 3 0 1 0; #X connect 4 0 1 0; #X connect 5 0 1 0; #X connect 6 0 1 0; #X connect 7 0 13 0; #X connect 7 1 12 0; #X connect 7 2 11 0; #X connect 7 3 10 0; #X connect 7 4 9 0; #X connect 7 5 8 0; #X connect 21 0 1 0; #X connect 22 0 1 0; ggee-0.28/control/serial_bird.c000066400000000000000000000165461402462307700164760ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #define DEBUG(x) /*#define DEBUG(x) x*/ static t_class *serial_bird_class; #define BIRD_DATA_START 0x80 #define BIRDCMD_MODE_POS 86 #define BIRD_BYTES_POS 6 #define BIRDCMD_MODE_POSANG 89 #define BIRD_BYTES_POSANG 12 #define BIRDCMD_MODE_POSMAT 90 #define BIRD_BYTES_POSMAT 24 #define BIRDCMD_MODE_POSQUAT 93 #define BIRD_BYTES_POSQUAT 14 #define BIRDCMD_MODE_QUAT 92 #define BIRD_BYTES_QUAT 8 #define BIRDCMD_STREAM 64 #define BIRDCMD_POINT 66 #define BIRD_GETDATA(x,y) ((float)((short)(y<<9 | x<<2))) #define MAXBUFFER 32 typedef struct _serial_bird { t_object x_obj; char x_c[MAXBUFFER]; t_int x_dataformat; t_int x_maxcount; t_int x_count; t_float x_posx; t_float x_posy; t_float x_posz; t_outlet *x_out2; } t_serial_bird; static void serial_bird_reset( t_serial_bird* x) { x->x_posx=0; x->x_posy=0; x->x_count = 0; outlet_float(x->x_obj.ob_outlet, x->x_posx); outlet_float(x->x_out2, x->x_posy); } static void serial_bird_float( t_serial_bird* x,t_floatarg f) { unsigned char c = (unsigned char) f; t_atom at[BIRD_BYTES_POSMAT]; t_int ac = 0; if (c&BIRD_DATA_START) { x->x_count=0; x->x_c[x->x_count] = c & 0x7f; } else x->x_c[x->x_count] = c; DEBUG(post("data %d in = %x, start = %d",x->x_count,c,c&BIRD_DATA_START);) if (x->x_count == x->x_maxcount-1) { switch (x->x_dataformat) { case BIRDCMD_MODE_POS: ac = 3; SETFLOAT(&at[0], 0.25*BIRD_GETDATA(x->x_c[0],x->x_c[1])); SETFLOAT(&at[1], 0.25*BIRD_GETDATA(x->x_c[2],x->x_c[3])); SETFLOAT(&at[2], 0.25*BIRD_GETDATA(x->x_c[4],x->x_c[5])); break; case BIRDCMD_MODE_POSANG: ac = 6; SETFLOAT(&at[0], 0.25*BIRD_GETDATA(x->x_c[0],x->x_c[1])); SETFLOAT(&at[1], 0.25*BIRD_GETDATA(x->x_c[2],x->x_c[3])); SETFLOAT(&at[2], 0.25*BIRD_GETDATA(x->x_c[4],x->x_c[5])); SETFLOAT(&at[3], BIRD_GETDATA(x->x_c[6],x->x_c[7])); SETFLOAT(&at[4], BIRD_GETDATA(x->x_c[8],x->x_c[9])); SETFLOAT(&at[5], BIRD_GETDATA(x->x_c[10],x->x_c[11])); break; case BIRDCMD_MODE_POSMAT: ac = 12; SETFLOAT(&at[0], BIRD_GETDATA(x->x_c[0],x->x_c[1])); SETFLOAT(&at[1], BIRD_GETDATA(x->x_c[2],x->x_c[3])); SETFLOAT(&at[2], BIRD_GETDATA(x->x_c[4],x->x_c[5])); SETFLOAT(&at[3], BIRD_GETDATA(x->x_c[6],x->x_c[7])); SETFLOAT(&at[4], BIRD_GETDATA(x->x_c[8],x->x_c[9])); SETFLOAT(&at[5], BIRD_GETDATA(x->x_c[10],x->x_c[11])); SETFLOAT(&at[6], BIRD_GETDATA(x->x_c[12],x->x_c[13])); SETFLOAT(&at[7], BIRD_GETDATA(x->x_c[14],x->x_c[15])); SETFLOAT(&at[8], BIRD_GETDATA(x->x_c[16],x->x_c[17])); SETFLOAT(&at[9], BIRD_GETDATA(x->x_c[18],x->x_c[19])); SETFLOAT(&at[10], BIRD_GETDATA(x->x_c[20],x->x_c[21])); SETFLOAT(&at[11], BIRD_GETDATA(x->x_c[22],x->x_c[23])); break; case BIRDCMD_MODE_POSQUAT: ac = 7; SETFLOAT(&at[0], BIRD_GETDATA(x->x_c[0],x->x_c[1])); SETFLOAT(&at[1], BIRD_GETDATA(x->x_c[2],x->x_c[3])); SETFLOAT(&at[2], BIRD_GETDATA(x->x_c[4],x->x_c[5])); SETFLOAT(&at[3], BIRD_GETDATA(x->x_c[6],x->x_c[7])); SETFLOAT(&at[4], BIRD_GETDATA(x->x_c[8],x->x_c[9])); SETFLOAT(&at[5], BIRD_GETDATA(x->x_c[10],x->x_c[11])); SETFLOAT(&at[6], BIRD_GETDATA(x->x_c[12],x->x_c[13])); break; case BIRDCMD_MODE_QUAT: ac = 4; SETFLOAT(&at[0], BIRD_GETDATA(x->x_c[0],x->x_c[1])); SETFLOAT(&at[1], BIRD_GETDATA(x->x_c[2],x->x_c[3])); SETFLOAT(&at[2], BIRD_GETDATA(x->x_c[4],x->x_c[5])); SETFLOAT(&at[3], BIRD_GETDATA(x->x_c[6],x->x_c[7])); break; } /* post("posx %d, posy %d",x->x_posx,x->x_posy);*/ outlet_list(x->x_obj.ob_outlet,&s_list, ac, at); } x->x_count = (++x->x_count)%(x->x_maxcount); } static void serial_bird_poll( t_serial_bird* x) { post("poll"); /* outlet_float(x->x_out2,(float)x->x_dataformat);*/ outlet_float(x->x_out2,(float)BIRDCMD_POINT); } static void serial_bird_mode( t_serial_bird* x,t_symbol* s) { post("mode"); /* outlet_float(x->x_out2,(float)x->x_dataformat);*/ if (!strcmp(s->s_name,"position")) { x->x_dataformat = BIRDCMD_MODE_POS; x->x_maxcount = BIRD_BYTES_POS; } if (!strcmp(s->s_name,"positionangle")) { x->x_dataformat = BIRDCMD_MODE_POSANG; x->x_maxcount = BIRD_BYTES_POSANG; } if (!strcmp(s->s_name,"positionmatrix")) { x->x_dataformat = BIRDCMD_MODE_POSMAT; x->x_maxcount = BIRD_BYTES_POSMAT; } if (!strcmp(s->s_name,"positionquat")) { x->x_dataformat = BIRDCMD_MODE_POSQUAT; x->x_maxcount = BIRD_BYTES_POSQUAT; } if (!strcmp(s->s_name,"quaternion")) { x->x_dataformat = BIRDCMD_MODE_QUAT; x->x_maxcount = BIRD_BYTES_QUAT; } outlet_float(x->x_out2,(float)x->x_dataformat); } static void serial_bird_init( t_serial_bird* x) { t_atom cmd[8]; SETFLOAT(cmd,14400.); outlet_anything(x->x_out2,gensym("speed"),1,cmd); SETFLOAT(cmd,0.); SETSYMBOL(cmd+1,gensym("CLOCAL")); SETSYMBOL(cmd+2,gensym("CREAD")); SETSYMBOL(cmd+3,gensym("CS8")); outlet_anything(x->x_out2,gensym("setcontrol"),4,cmd); SETFLOAT(cmd,0.); SETSYMBOL(cmd+1,gensym("IXOFF")); outlet_anything(x->x_out2,gensym("setinput"),2,cmd); SETFLOAT(cmd,0.); outlet_anything(x->x_out2,gensym("setlocal"),1,cmd); SETFLOAT(cmd,0.); SETFLOAT(cmd+1,20.); outlet_anything(x->x_out2,gensym("vtime"),2,cmd); SETSYMBOL(cmd,gensym("RTS")); SETFLOAT(cmd+1,0.); outlet_anything(x->x_out2,gensym("setlines"),2,cmd); SETSYMBOL(cmd,gensym("DTR")); SETFLOAT(cmd+1,1.); outlet_anything(x->x_out2,gensym("setlines"),2,cmd); /* start the polling on the serial device immediately */ outlet_anything(x->x_out2,gensym("start"),0,cmd); } static void serial_bird_start( t_serial_bird* x) { post("start"); /* outlet_float(x->x_out2,(float)x->x_dataformat);*/ outlet_float(x->x_out2,(float)BIRDCMD_STREAM); } static void serial_bird_stop( t_serial_bird* x) { post("stop"); outlet_float(x->x_out2,(float)BIRDCMD_POINT); } static void *serial_bird_new(t_symbol *s) { t_serial_bird *x = (t_serial_bird *)pd_new(serial_bird_class); x->x_count = 0; x->x_posx = 0; x->x_posy = 0; x->x_dataformat = BIRDCMD_MODE_POSANG; x->x_maxcount = BIRD_BYTES_POSANG; outlet_new(&x->x_obj, &s_float); x->x_out2 = outlet_new(&x->x_obj, &s_float); return x; } void serial_bird_setup(void) { serial_bird_class = class_new(gensym("serial_bird"), (t_newmethod)serial_bird_new, NULL, sizeof(t_serial_bird), 0,A_DEFSYM,0); class_addfloat(serial_bird_class,serial_bird_float); class_addmethod(serial_bird_class,(t_method) serial_bird_reset,gensym("reset"),0); class_addmethod(serial_bird_class,(t_method) serial_bird_init,gensym("init"),0); class_addmethod(serial_bird_class,(t_method) serial_bird_start,gensym("start"),0); class_addmethod(serial_bird_class,(t_method) serial_bird_stop,gensym("stop"),0); class_addmethod(serial_bird_class,(t_method) serial_bird_poll,gensym("poll"),0); class_addmethod(serial_bird_class,(t_method) serial_bird_mode,gensym("mode"),A_SYMBOL,NULL); } ggee-0.28/control/serial_ms-help.pd000066400000000000000000000022001402462307700172620ustar00rootroot00000000000000#N canvas 1 88 473 321 10; #X obj 251 180 print reading; #X msg 154 82 start; #X msg 155 100 stop; #X obj 59 157 serial_ms; #X text 35 19 decodes serial mice attached to the 1 serial port; #X text 35 268 (C) Guenter Geiger; #X msg 37 53 init; #X msg 245 98 setcontrol 0 CREAD CLOCAL CS7; #X msg 247 77 getlines; #X obj 59 180 unpack; #X floatatom 59 202 0 0 0 0 - - -; #X floatatom 90 202 0 0 0 0 - - -; #X msg 344 56 setlines RTS 1; #X msg 247 37 setlines DTR 0; #X msg 247 55 setlines RTS 0; #X msg 342 37 setlines DTR 1; #X msg 304 133 setlocal 0; #N canvas 405 114 494 344 META 0; #X text 12 155 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 135 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION decodes serial mice attached to the 1 serial port; #X text 12 95 OUTLET_0 list; #X text 12 115 OUTLET_1; #X text 12 75 INLET_0 init reset; #X text 12 4 KEYWORDS control user_input; #X restore 407 267 pd META; #X msg 70 100 reset; #X obj 155 123 serialctl /dev/ttyS0; #X connect 3 0 9 0; #X connect 6 0 3 0; #X connect 9 0 10 0; #X connect 9 1 11 0; #X connect 18 0 3 0; ggee-0.28/control/serial_ms.c000066400000000000000000000050071402462307700161630ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include static t_class *serial_ms_class; typedef struct _serial_ms { t_object x_obj; char x_c[4]; t_int x_count; t_int x_posx; t_int x_posy; t_outlet *x_out2; } t_serial_ms; static void serial_ms_reset( t_serial_ms* x) { x->x_posx=0; x->x_posy=0; x->x_count = 0; outlet_float(x->x_obj.ob_outlet, x->x_posx); outlet_float(x->x_out2, x->x_posy); } static void serial_ms_init( t_serial_ms* x) { t_atom cmd[8]; SETFLOAT(cmd,0.); SETSYMBOL(cmd+1,gensym("CLOCAL")); SETSYMBOL(cmd+2,gensym("CREAD")); SETSYMBOL(cmd+3,gensym("CS7")); /* SETSYMBOL(cmd+4,gensym("HUPCL")); */ outlet_anything(x->x_out2,gensym("setcontrol"),4,cmd); SETFLOAT(cmd,0.); SETSYMBOL(cmd+1,gensym("IGNBRK")); SETSYMBOL(cmd+2,gensym("IGNPAR")); outlet_anything(x->x_out2,gensym("setinput"),3,cmd); SETFLOAT(cmd,0.); SETFLOAT(cmd+1,1.); outlet_anything(x->x_out2,gensym("vtime"),2,cmd); SETFLOAT(cmd,1200.); outlet_anything(x->x_out2,gensym("speed"),1,cmd); SETSYMBOL(cmd,gensym("*n")); outlet_anything(x->x_out2,gensym("send"),1,cmd); SETSYMBOL(cmd,gensym("N")); outlet_anything(x->x_out2,gensym("send"),1,cmd); } static void serial_ms_float( t_serial_ms* x,t_floatarg f) { int dx,dy; t_atom at[2]; x->x_c[x->x_count] = (char) f; x->x_count = (++x->x_count)%3; if (x->x_count==2) { dx= (signed char)(((x->x_c[0] & 0x03) << 6) | (x->x_c[1] & 0x3F)); dy= (signed char)(((x->x_c[0] & 0x0C) << 4) | (x->x_c[2] & 0x3F)); x->x_posx += dx; x->x_posy += dy; /* post("posx %d, posy %d",x->x_posx,x->x_posy);*/ SETFLOAT(at,x->x_posx); SETFLOAT(at+1,x->x_posy); outlet_list(x->x_obj.ob_outlet,&s_list, 2, at); } } static void *serial_ms_new(t_symbol *s) { t_serial_ms *x = (t_serial_ms *)pd_new(serial_ms_class); x->x_count = 0; x->x_posx = 0; x->x_posy = 0; outlet_new(&x->x_obj, &s_float); x->x_out2 = outlet_new(&x->x_obj, &s_float); return x; } void serial_ms_setup(void) { serial_ms_class = class_new(gensym("serial_ms"), (t_newmethod)serial_ms_new, NULL, sizeof(t_serial_ms), 0,A_DEFSYM,0); class_addfloat(serial_ms_class,serial_ms_float); class_addmethod(serial_ms_class,(t_method) serial_ms_reset,gensym("reset"),0); class_addmethod(serial_ms_class, (t_method)serial_ms_init, gensym("init"),0); } ggee-0.28/control/serial_mt-help.pd000066400000000000000000000007061402462307700172740ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 140 126 serial_mt; #X text 54 47 placeholder help patch; #N canvas 405 114 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 105 OUTLET_1; #X text 12 65 INLET_0; #X text 12 85 OUTLET_0; #X text 12 45 DESCRIPTION; #X text 12 5 KEYWORDS control; #X restore 387 257 pd META; ggee-0.28/control/serial_mt.c000066400000000000000000000027451402462307700161720ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include static t_class *serial_mt_class; typedef struct _serial_mt { t_object x_obj; char x_c[4]; t_int x_count; t_int x_posx; t_int x_posy; t_outlet *x_out2; } t_serial_mt; static void serial_mt_reset( t_serial_mt* x) { x->x_posx=0; x->x_posy=0; x->x_count = 0; } static void serial_mt_float( t_serial_mt* x,t_floatarg f) { int dx,dy; x->x_c[x->x_count] = (char) f; x->x_count = (++x->x_count)%3; if (x->x_count==2) { dx= (signed char)(((x->x_c[0] & 0x03) << 6) | (x->x_c[1] & 0x3F)); dy= (signed char)(((x->x_c[0] & 0x0C) << 4) | (x->x_c[2] & 0x3F)); x->x_posx += dx; x->x_posy += dy; /* post("posx %d, posy %d",x->x_posx,x->x_posy); */ outlet_float(x->x_obj.ob_outlet, x->x_posx); outlet_float(x->x_out2, x->x_posy); } } static void *serial_mt_new(t_symbol *s) { t_serial_mt *x = (t_serial_mt *)pd_new(serial_mt_class); x->x_count = 0; x->x_posx = 0; x->x_posy = 0; outlet_new(&x->x_obj, &s_float); x->x_out2 = outlet_new(&x->x_obj, &s_float); return x; } void serial_mt_setup(void) { serial_mt_class = class_new(gensym("serial_mt"), (t_newmethod)serial_mt_new, NULL, sizeof(t_serial_mt), 0,A_DEFSYM,0); class_addfloat(serial_mt_class,serial_mt_float); class_addmethod(serial_mt_class,(t_method) serial_mt_reset,gensym("reset"),0); } ggee-0.28/control/serialctl-help.pd000066400000000000000000000045521402462307700173020ustar00rootroot00000000000000#N canvas 0 31 907 514 10; #X msg 202 243 getlines; #X msg 201 169 setlines RTS 0; #X msg 201 187 setlines RTS 1; #X msg 24 213 start; #X msg 24 195 stop; #X msg 515 231 vtime 0 20; #X msg 515 212 setlocal 0; #X msg 515 193 setcontrol 0 CS8 CLOCAL CREAD; #X msg 201 224 setlines DTR 1; #X msg 201 206 setlines DTR 0; #X text 12 489 (C) 2000 Guenter Geiger; #X text 32 22 [serialctl] reads from a Unix serial device. There are several ways how serial devices can be setup \, and [serialctl] provides access to these serial device settings. This makes it possible to interpret the data stream from a serial device either within pd itself \, or via a specially written external for the device attached to the serial port (see serial_bird and serial_ms).; #X msg 516 431 79 \, 75 \, 13; #X msg 517 451 OK \, 13; #X text 201 138 setlines set the serial port; #X text 199 151 lines (only acces to RTS and DTR is provided; #X text 23 153 start/stop; #X text 23 165 reading characters; #X text 23 177 from the device; #X text 510 69 setinput \, setcontrol \, setlocal \, vtime provide access to the termios status bits of the serial device. This is lowlevel configuration and is sometimes necessary.; #X text 512 296 set the baudrate; #X msg 514 348 makeraw; #X text 513 330 configure the device as "raw"; #X text 511 110 If a 0 is prepended to the flags \, the flags are reset before any bits are switched. All other commands set the corresponding bits to either 1 (e.g. CLOCAL) or 0 (!CLOCAL).; #X msg 516 250 listflags; #X msg 716 210 setinput list; #X text 511 151 the "list flag" lists all available flags.; #X text 514 412 data can be sent as symbols or as ASCII character code ; #X msg 716 230 setcontrol list; #X msg 717 191 setlocal list; #X msg 514 175 setinput 0 IXOFF; #X floatatom 590 314 0 0 0 0 - - -; #X msg 513 313 speed \$1; #X obj 24 455 print; #X floatatom 62 243 0 0 0 0 - - -; #X msg 73 277 send c; #N canvas 391 259 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 105 OUTLET_1; #X text 12 45 DESCRIPTION read from a Unix serial device; #X text 12 5 KEYWORDS control filesystem needs_work (object won't create) ; #X text 12 65 INLET_0; #X text 12 85 OUTLET_0; #X restore 838 481 pd META; #X obj 24 429 serialctl /dev/ttyS0; #X connect 31 0 32 0; ggee-0.28/control/serialctl.pd000066400000000000000000000036551402462307700163570ustar00rootroot00000000000000#N canvas 0 31 907 514 10; #X msg 202 243 getlines; #X msg 201 169 setlines RTS 0; #X msg 201 187 setlines RTS 1; #X msg 24 213 start; #X msg 24 195 stop; #X msg 515 231 vtime 0 20; #X msg 515 212 setlocal 0; #X msg 515 193 setcontrol 0 CS8 CLOCAL CREAD; #X msg 201 224 setlines DTR 1; #X msg 201 206 setlines DTR 0; #X text 12 489 (C) 2000 Guenter Geiger; #X text 32 22 serialin reads from a Unix serial device. There are several ways how serial devices can be setup \, and serialin provides access to these serial device settings. This makes it possible to interpret the data stream from a serial device either within pd itself \, or via a specially written external for the device attached to the serial port (see serial_bird and serial_ms).; #X msg 516 431 79 \, 75 \, 13; #X msg 517 451 OK \, 13; #X text 201 138 setlines set the serial port; #X text 199 151 lines (only acces to RTS and DTR is provided; #X text 23 153 start/stop; #X text 23 165 reading characters; #X text 23 177 from the device; #X text 510 69 setinput \, setcontrol \, setlocal \, vtime provide access to the termios status bits of the serial device. This is lowlevel configuration and is sometimes necessary.; #X text 512 296 set the baudrate; #X msg 514 348 makeraw; #X text 513 330 configure the device as "raw"; #X text 511 110 If a 0 is prepended to the flags \, the flags are reset before any bits are switched. All other commands set the corresponding bits to either 1 (e.g. CLOCAL) or 0 (!CLOCAL).; #X msg 516 250 listflags; #X msg 716 210 setinput list; #X text 511 151 the "list flag" lists all available flags.; #X text 514 412 data can be sent as symbols or as ASCII character code ; #X msg 716 230 setcontrol list; #X msg 717 191 setlocal list; #X msg 514 175 setinput 0 IXOFF; #X floatatom 590 314 0 0 0 0 - - -; #X msg 513 313 speed \$1; #X obj 24 455 print; #X floatatom 62 243 0 0 0 0 - - -; #X msg 73 277 send c; #X obj 24 429 serialctl /dev/ttyS0; #X connect 31 0 32 0; ggee-0.28/control/serialize-help.pd000066400000000000000000000012661402462307700173060ustar00rootroot00000000000000#N canvas 0 31 413 250 10; #X obj 34 106 serialize 4; #X obj 34 141 print; #X floatatom 34 69 0 0 0 0 - - -; #X text 30 195 (C) 2000 Guenter Geiger; #X text 30 39 serialize ... turn a stream of floats into a list; #N canvas 391 259 494 344 META 0; #X text 12 155 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 135 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control conversion; #X text 12 45 DESCRIPTION serialize ... turn a stream of floats into a list; #X text 12 75 INLET_0 float; #X text 12 95 INLET_1 float; #X text 12 115 OUTLET_0 list; #X restore 350 207 pd META; #X connect 0 0 1 0; #X connect 2 0 0 0; ggee-0.28/control/serialize.c000066400000000000000000000022621402462307700161740ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ serialize ----------------------------- */ #define MAX_ELEMENTS 256 static t_class *serialize_class; typedef struct _serialize { t_object x_obj; t_atom x_abuf[MAX_ELEMENTS]; t_int x_count; t_float x_elements; } t_serialize; void serialize_float(t_serialize *x,t_floatarg f) { SETFLOAT(&x->x_abuf[x->x_count],f); x->x_count++; if (x->x_count == x->x_elements) { outlet_list(x->x_obj.ob_outlet,0,x->x_count,x->x_abuf); x->x_count = 0; } } static void *serialize_new(t_floatarg f) { t_serialize *x = (t_serialize *)pd_new(serialize_class); outlet_new(&x->x_obj,&s_float); x->x_elements = f; x->x_count=0; if ((f <= 0) || (f > MAX_ELEMENTS)) x->x_elements = 1; floatinlet_new(&x->x_obj, &x->x_elements); return (x); } void serialize_setup(void) { serialize_class = class_new(gensym("serialize"), (t_newmethod)serialize_new, 0, sizeof(t_serialize),0, A_DEFFLOAT,0); class_addfloat(serialize_class,serialize_float); } ggee-0.28/control/shell-help.pd000066400000000000000000000033201402462307700164170ustar00rootroot00000000000000#N canvas 0 31 499 378 10; #X obj 35 100 shell; #X msg 35 65 ls; #X msg 360 97 date +%k%M; #X floatatom 360 141 4 0 0 0 - - -; #X obj 360 118 shell; #X obj 51 319 shell; #X msg 74 288 cvs commit -m fixed_bug_in_shell; #X msg 65 264 cvs -q update; #X msg 12 193 xedit; #X msg 36 213 /usr/bin/perl; #X text 343 79 Getting the time; #X obj 362 233 shell; #X text 345 194 Getting the date; #X symbolatom 362 274 0 0 0 0 - - -; #X msg 362 212 date +%Y.%m.%d; #X obj 362 253 symbol; #X obj 409 234 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X obj 65 126 print DONE; #X obj 35 147 print STDOUT; #X text 30 7 This object allows you to run commands in a UNIX shell. STDIN is received on the inlet. STDOUT is output on the left inlet \, STDERR is output to the Pd console. When execution is complete \, the right outlet is banged.; #X floatatom 61 234 5 0 0 0 - - -; #X floatatom 408 142 5 0 0 0 - - -; #X obj 408 161 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #N canvas 479 242 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control filesystem; #X text 12 65 INLET_0 anything; #X text 12 45 DESCRIPTION run commands in a UNIX shell; #X text 12 85 OUTLET_0 anything; #X text 12 105 OUTLET_1 float; #X restore 440 345 pd META; #X connect 0 0 18 0; #X connect 0 1 17 0; #X connect 1 0 0 0; #X connect 2 0 4 0; #X connect 4 0 3 0; #X connect 4 1 21 0; #X connect 6 0 5 0; #X connect 7 0 5 0; #X connect 8 0 5 0; #X connect 9 0 5 0; #X connect 11 0 15 0; #X connect 11 1 16 0; #X connect 14 0 11 0; #X connect 15 0 13 0; #X connect 20 0 5 0; #X connect 21 0 22 0; ggee-0.28/control/shell.c000066400000000000000000000143221402462307700153140ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* this doesn't run on Windows (yet?) */ #ifndef _WIN32 #include #include #include #include #include #include #include #include #include void sys_rmpollfn(int fd); void sys_addpollfn(int fd, void* fn, void *ptr); /* ------------------------ shell ----------------------------- */ #define INBUFSIZE 1024 static t_class *shell_class; static void drop_priority(void) { #if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param par; int p1 ,p2, p3; par.sched_priority = 0; sched_setscheduler(0,SCHED_OTHER,&par); #endif } typedef struct _shell { t_object x_obj; int x_echo; char *sr_inbuf; int sr_inhead; int sr_intail; void* x_binbuf; int fdpipe[2]; int fdinpipe[2]; int pid; int x_del; t_outlet* x_done; t_clock* x_clock; } t_shell; static int shell_pid; void shell_cleanup(t_shell* x) { sys_rmpollfn(x->fdpipe[0]); if (x->fdpipe[0]>0) close(x->fdpipe[0]); if (x->fdpipe[1]>0) close(x->fdpipe[1]); if (x->fdinpipe[0]>0) close(x->fdinpipe[0]); if (x->fdinpipe[1]>0) close(x->fdinpipe[1]); x->fdpipe[0] = -1; x->fdpipe[1] = -1; x->fdinpipe[0] = -1; x->fdinpipe[1] = -1; clock_unset(x->x_clock); } void shell_check(t_shell* x) { int ret; int status; ret = waitpid(x->pid,&status,WNOHANG); if (ret == x->pid) { shell_cleanup(x); if (WIFEXITED(status)) { outlet_float(x->x_done,WEXITSTATUS(status)); } else outlet_float(x->x_done,0); } else { if (x->x_del < 100) x->x_del+=2; /* increment poll times */ clock_delay(x->x_clock,x->x_del); } } void shell_bang(t_shell *x) { post("bang"); } /* snippet from pd's code */ static void shell_doit(void *z, t_binbuf *b) { t_shell *x = (t_shell *)z; int msg, natom = binbuf_getnatom(b); t_atom *at = binbuf_getvec(b); for (msg = 0; msg < natom;) { int emsg; for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA && at[emsg].a_type != A_SEMI; emsg++) ; if (emsg > msg) { int i; for (i = msg; i < emsg; i++) if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM) { pd_error(x, "netreceive: got dollar sign in message"); goto nodice; } if (at[msg].a_type == A_FLOAT) { if (emsg > msg + 1) outlet_list(x->x_obj.ob_outlet, 0, emsg-msg, at + msg); else outlet_float(x->x_obj.ob_outlet, at[msg].a_w.w_float); } else if (at[msg].a_type == A_SYMBOL) outlet_anything(x->x_obj.ob_outlet, at[msg].a_w.w_symbol, emsg-msg-1, at + msg + 1); } nodice: msg = emsg + 1; } } void shell_read(t_shell *x, int fd) { char buf[INBUFSIZE]; t_binbuf* bbuf = binbuf_new(); int i; int readto = (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); int ret; ret = read(fd, buf,INBUFSIZE-1); buf[ret] = '\0'; for (i=0;ifdpipe[0] = -1; close(fd); return; } else if (ret == 0) { post("EOF on socket %d\n", fd); sys_rmpollfn(fd); x->fdpipe[0] = -1; close(fd); return; } else { int natom; t_atom *at; binbuf_text(bbuf, buf, strlen(buf)); natom = binbuf_getnatom(bbuf); at = binbuf_getvec(bbuf); shell_doit(x,bbuf); } binbuf_free(bbuf); } static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at) { int i; char tmp[MAXPDSTRING]; int size = 0; if (x->fdinpipe[0] == -1) return; /* nothing to send to */ for (i=0;ifdinpipe[0],tmp,strlen(tmp)); } static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) { int i; char* argv[255]; t_symbol* sym; if (!strcmp(s->s_name,"send")) { post("send"); shell_send(x,s,ac,at); return; } argv[0] = s->s_name; if (x->fdpipe[0] != -1) { post("shell: old process still running"); kill(x->pid,SIGKILL); shell_cleanup(x); } if (pipe(x->fdpipe) < 0) { error("unable to create pipe"); return; } if (pipe(x->fdinpipe) < 0) { error("unable to create input pipe"); return; } sys_addpollfn(x->fdpipe[0],shell_read,x); if (!(x->pid = fork())) { /* reassign stdout */ dup2(x->fdpipe[1],1); dup2(x->fdinpipe[1],0); /* drop privileges */ drop_priority(); seteuid(getuid()); /* lose setuid priveliges */ #ifdef __APPLE__ for (i=1;i<=ac;i++) { argv[i] = getbytes(255); atom_string(at,argv[i],255); at++; } argv[i] = 0; execvp(s->s_name,argv); #else // changed linux part: use execvp() instead system() // see https://github.com/umlaeute/Gem/issues/224 for (i=1;i<=ac;i++) { argv[i] = getbytes(255); atom_string(at,argv[i],255); at++; } argv[i] = 0; execvp(s->s_name,argv); #endif /* __APPLE__ */ exit(0); } x->x_del = 4; clock_delay(x->x_clock,x->x_del); if (x->x_echo) outlet_anything(x->x_obj.ob_outlet, s, ac, at); } void shell_free(t_shell* x) { binbuf_free(x->x_binbuf); } static void *shell_new(void) { t_shell *x = (t_shell *)pd_new(shell_class); x->x_echo = 0; x->fdpipe[0] = -1; x->fdpipe[1] = -1; x->fdinpipe[0] = -1; x->fdinpipe[1] = -1; x->sr_inhead = x->sr_intail = 0; if (!(x->sr_inbuf = (char*) malloc(INBUFSIZE))) bug("t_shell");; x->x_binbuf = binbuf_new(); outlet_new(&x->x_obj, &s_list); x->x_done = outlet_new(&x->x_obj, &s_bang); x->x_clock = clock_new(x, (t_method) shell_check); return (x); } void shell_setup(void) { shell_class = class_new(gensym("shell"), (t_newmethod)shell_new, (t_method)shell_free,sizeof(t_shell), 0,0); class_addbang(shell_class,shell_bang); class_addanything(shell_class, shell_anything); } #endif /* _WIN32 */ ggee-0.28/control/sinh-help.pd000066400000000000000000000007011402462307700162510ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 140 126 sinh; #X text 54 47 placeholder help patch; #N canvas 477 250 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION; #X text 12 65 INLET_0 float; #X text 12 85 OUTLET_0 float; #X text 12 5 KEYWORDS control trigonometry; #X restore 380 265 pd META; ggee-0.28/control/sinh.c000066400000000000000000000014471402462307700151520ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include /* ------------------------ sinh ----------------------------- */ static t_class *sinh_class; typedef struct _sinh { t_object x_obj; } t_sinh; void sinh_bang(t_sinh *x) { post("bang"); } void sinh_float(t_sinh *x,t_floatarg f) { outlet_float(x->x_obj.ob_outlet,sinh(f)); } static void *sinh_new() { t_sinh *x = (t_sinh *)pd_new(sinh_class); outlet_new(&x->x_obj,&s_float); return (x); } void sinh_setup(void) { sinh_class = class_new(gensym("sinh"), (t_newmethod)sinh_new, 0, sizeof(t_sinh), 0,0); class_addbang(sinh_class,sinh_bang); class_addfloat(sinh_class,sinh_float); } ggee-0.28/control/sl-help.pd000066400000000000000000000020441402462307700157300ustar00rootroot00000000000000#N canvas 0 31 501 213 10; #X text 20 141 (C) Guenter Geiger; #N canvas 46 242 494 344 META 0; #X text 12 105 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 85 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS signal nonlocal canvas_op; #X text 12 45 DESCRIPTION send local to this canvas; #X text 12 65 INLET_0 anything; #X restore 440 183 pd META; #X obj 270 63 rl; #X obj 301 65 sl; #X floatatom 270 100 5 0 0 0 - - -; #X floatatom 301 41 5 0 0 0 - - -; #N canvas 352 127 450 300 local-send-and-receive-for-subpatches 0; #X obj 68 77 rl; #X obj 117 57 sl; #X floatatom 117 22 5 0 0 0 - - -; #X floatatom 68 118 5 0 0 0 - - -; #X connect 0 0 3 0; #X connect 2 0 1 0; #X restore 191 153 pd local-send-and-receive-for-subpatches; #X obj 152 78 receivelocal foo; #X obj 47 107 sendlocal foo; #X floatatom 152 106 5 0 0 0 - - -; #X floatatom 47 78 5 0 0 0 - - -; #X text 20 38 send local to this canvas; #X connect 2 0 4 0; #X connect 5 0 3 0; #X connect 7 0 9 0; #X connect 10 0 8 0; ggee-0.28/control/sl.c000066400000000000000000000035501402462307700146240ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* -------------------- lsend ------------------------------ */ static t_class *lsend_class; typedef struct _lsend { t_object x_obj; t_symbol *x_sym; } t_lsend; static void lsend_bang(t_lsend *x) { if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing); } static void lsend_float(t_lsend *x, t_float f) { if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f); } static void lsend_symbol(t_lsend *x, t_symbol *s) { if (x->x_sym->s_thing) pd_symbol(x->x_sym->s_thing, s); } static void lsend_pointer(t_lsend *x, t_gpointer *gp) { if (x->x_sym->s_thing) pd_pointer(x->x_sym->s_thing, gp); } static void lsend_list(t_lsend *x, t_symbol *s, int argc, t_atom *argv) { if (x->x_sym->s_thing) pd_list(x->x_sym->s_thing, s, argc, argv); } static void lsend_anything(t_lsend *x, t_symbol *s, int argc, t_atom *argv) { if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, s, argc, argv); } static void *lsend_new(t_symbol *s) { t_lsend *x = (t_lsend *)pd_new(lsend_class); char mysym[MAXPDSTRING]; sprintf(mysym,"%s%p",s->s_name,canvas_getcurrent()); x->x_sym = gensym(mysym); return (x); } void sl_setup(void) { lsend_class = class_new(gensym("sendlocal"), (t_newmethod)lsend_new, 0, sizeof(t_lsend), 0, A_DEFSYM, 0); class_addcreator((t_newmethod)lsend_new, gensym("sl"), A_DEFSYM, 0); class_addbang(lsend_class, lsend_bang); class_addfloat(lsend_class, lsend_float); class_addsymbol(lsend_class, lsend_symbol); class_addpointer(lsend_class, lsend_pointer); class_addlist(lsend_class, lsend_list); class_addanything(lsend_class, lsend_anything); post("Warning: sendlocal (sl) is deprecated, please use \"send $0-var\" instead"); } ggee-0.28/control/stripdir-help.pd000066400000000000000000000011411402462307700171470ustar00rootroot00000000000000#N canvas 0 26 412 258 10; #X obj 22 78 stripdir; #X symbolatom 22 48 0 0 0 0 - - -; #X obj 22 105 print; #X text 20 22 strips all leading directories from a path; #N canvas 129 173 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control symbol_op; #X text 12 45 DESCRIPTION strip all leading directories from a path ; #X text 12 65 INLET_0 symbol; #X text 12 85 OUTLET_0 symbol; #X restore 362 236 pd META; #X connect 0 0 2 0; #X connect 1 0 0 0; ggee-0.28/control/stripdir.c000066400000000000000000000016261402462307700160500ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ stripdir ----------------------------- */ static t_class *stripdir_class; typedef struct _stripdir { t_object x_obj; } t_stripdir; void stripdir_symbol(t_stripdir *x,t_symbol* s) { int len = strlen(s->s_name); while (len--) if (*(s->s_name + len) == '/') { outlet_symbol(x->x_obj.ob_outlet,gensym(s->s_name + len + 1)); break; } } static void *stripdir_new() { t_stripdir *x = (t_stripdir *)pd_new(stripdir_class); outlet_new(&x->x_obj, &s_float); return (x); } void stripdir_setup(void) { stripdir_class = class_new(gensym("stripdir"), (t_newmethod)stripdir_new, 0, sizeof(t_stripdir), 0,0); class_addsymbol(stripdir_class,stripdir_symbol); } ggee-0.28/control/unserialize-help.pd000066400000000000000000000011141402462307700176410ustar00rootroot00000000000000#N canvas 0 31 450 300 10; #X text 54 47 placeholder help patch; #X obj 144 165 print; #X floatatom 125 89 5 0 0 0 - - -; #X obj 140 126 unserialize 4; #N canvas 391 259 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control conversion; #X text 12 65 INLET_0 float; #X text 12 45 DESCRIPTION turn a stream of floats into a list; #X text 12 85 OUTLET_0 list; #X restore 390 260 pd META; #X connect 2 0 3 0; #X connect 3 0 1 0; ggee-0.28/control/unserialize.c000066400000000000000000000022441402462307700165370ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ unserialize ----------------------------- */ #define MAX_ELEMENTS 256 static t_class *unserialize_class; typedef struct _unserialize { t_object x_obj; t_atom x_abuf[MAX_ELEMENTS]; t_int x_count; t_int x_elements; } t_unserialize; void unserialize_float(t_unserialize *x,t_floatarg f) { SETFLOAT(&x->x_abuf[x->x_count],f); x->x_count++; if (x->x_count == x->x_elements) { outlet_list(x->x_obj.ob_outlet,0,x->x_count,x->x_abuf); x->x_count = 0; } } static void *unserialize_new(t_floatarg f) { t_unserialize *x = (t_unserialize *)pd_new(unserialize_class); outlet_new(&x->x_obj,&s_float); x->x_elements = f; x->x_count=0; if ((f <= 0) || (f > MAX_ELEMENTS)) x->x_elements = 1; return (x); } void unserialize_setup(void) { unserialize_class = class_new(gensym("unserialize"), (t_newmethod)unserialize_new, 0,sizeof(t_unserialize),0, A_DEFFLOAT,0); class_addfloat(unserialize_class,unserialize_float); } ggee-0.28/control/unwonk-help.pd000066400000000000000000000031041402462307700166310ustar00rootroot00000000000000#N canvas 0 31 418 418 10; #X obj 63 144 unwonk; #X obj 221 256 print; #X floatatom 49 185 0 0 0 0 - - -; #X floatatom 75 185 0 0 0 0 - - -; #X obj 154 189 unwonk 1 2 3; #X floatatom 129 233 0 0 0 0 - - -; #X floatatom 155 233 0 0 0 0 - - -; #X floatatom 181 233 0 0 0 0 - - -; #X msg 40 110 1 2 3 4 5 6 7 8; #X obj 40 277 unwonk 1 2 3 4 5 6 7 8 9; #X floatatom 37 320 0 0 0 0 - - -; #X floatatom 63 320 0 0 0 0 - - -; #X floatatom 89 320 0 0 0 0 - - -; #X floatatom 115 321 0 0 0 0 - - -; #X floatatom 141 321 0 0 0 0 - - -; #X floatatom 167 321 0 0 0 0 - - -; #X text 35 374 (C) 1999 Guenter Geiger; #X text 37 34 unwonk is an unpack which sends; #X text 35 69 instead of discarding them; #X text 37 51 unused elements to the last outlet; #N canvas 303 102 494 344 META 0; #X text 12 195 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 175 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control conversion; #X text 12 45 DESCRIPTION an unpack which sends unused elements to the last outlet instead of discarding them; #X text 12 75 INLET_0 list; #X text 12 95 OUTLET_0 float symbol; #X text 12 135 OUTLET_N float symbol; #X text 12 155 OUTLET_R list; #X text 12 115 OUTLET_1 float symbol; #X restore 353 384 pd META; #X connect 0 0 2 0; #X connect 0 1 3 0; #X connect 0 2 4 0; #X connect 4 0 5 0; #X connect 4 1 6 0; #X connect 4 2 7 0; #X connect 4 3 1 0; #X connect 8 0 0 0; #X connect 8 0 9 0; #X connect 9 0 10 0; #X connect 9 1 11 0; #X connect 9 2 12 0; #X connect 9 3 13 0; #X connect 9 4 14 0; #X connect 9 5 15 0; ggee-0.28/control/unwonk.c000066400000000000000000000052071402462307700155300ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include /* -------------------------- unwonk ------------------------------ */ static t_class *unwonk_class; typedef struct unwonkout { t_atomtype u_type; t_outlet *u_outlet; } t_unwonkout; typedef struct _unwonk { t_object x_obj; t_int x_n; t_unwonkout *x_vec; } t_unwonk; static void *unwonk_new(t_symbol *s, int argc, t_atom *argv) { t_unwonk *x = (t_unwonk *)pd_new(unwonk_class); t_atom defarg[2], *ap; t_unwonkout *u; int i; if (!argc) { argv = defarg; argc = 2; SETFLOAT(&defarg[0], 0); SETFLOAT(&defarg[1], 0); } x->x_n = argc + 1; x->x_vec = (t_unwonkout *)getbytes(x->x_n * sizeof(*x->x_vec)); for (i = 0, ap = argv, u = x->x_vec; i < argc; u++, ap++, i++) { t_atomtype type = ap->a_type; if (type == A_SYMBOL) { char c = *ap->a_w.w_symbol->s_name; if (c == 's') { u->u_type = A_SYMBOL; u->u_outlet = outlet_new(&x->x_obj, &s_symbol); } else if (c == 'p') { u->u_type = A_POINTER; u->u_outlet = outlet_new(&x->x_obj, &s_pointer); } else { if (c != 'f') error("unwonk: %s: bad type", ap->a_w.w_symbol->s_name); u->u_type = A_FLOAT; u->u_outlet = outlet_new(&x->x_obj, &s_float); } } else { u->u_type = A_FLOAT; u->u_outlet = outlet_new(&x->x_obj, &s_float); } } u->u_type = A_GIMME; u->u_outlet = outlet_new(&x->x_obj, &s_list); return (x); } static void unwonk_list(t_unwonk *x, t_symbol *s, int argc, t_atom *argv) { t_atom *ap; t_unwonkout *u; int i; int margc = argc; if (argc > x->x_n - 1) margc = x->x_n - 1; if (argc - margc > 0) { ap = argv + margc; u = x->x_vec + margc; outlet_list(u->u_outlet,0,argc - margc, ap); } for (i = margc, u = x->x_vec + i, ap = argv + i; u--, ap--, i--;) { t_atomtype type = u->u_type; if (type != ap->a_type) error("unwonk: type mismatch"); else if (type == A_FLOAT) outlet_float(u->u_outlet, ap->a_w.w_float); else if (type == A_SYMBOL) outlet_symbol(u->u_outlet, ap->a_w.w_symbol); else outlet_pointer(u->u_outlet, ap->a_w.w_gpointer); } } static void unwonk_free(t_unwonk *x) { freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec)); } void unwonk_setup(void) { unwonk_class = class_new(gensym("unwonk"), (t_newmethod)unwonk_new, (t_method)unwonk_free, sizeof(t_unwonk), 0, A_GIMME, 0); class_addlist(unwonk_class, unwonk_list); } ggee-0.28/experimental/000077500000000000000000000000001402462307700150545ustar00rootroot00000000000000ggee-0.28/experimental/Makefile.linux000066400000000000000000000014221402462307700176510ustar00rootroot00000000000000NAME=stk current: pd_linux # TARGETS += stk PDDIR = /usr/local/lib/pd INSTALLPATH = $(PDDIR)/extra VERSION = \"0.16\" # ----------------------- Linux ----------------------- pd_linux: $(NAME).pd_linux .SUFFIXES: .pd_linux LINUXCFLAGS = -ggdb -DPD -O3 -fPIC -funroll-loops -fomit-frame-pointer \ -W -Wshadow -Wno-unused -Wno-parentheses -Wno-switch LINUXINCLUDE = -I/usr/include -I/usr/local/include/stk .cpp.pd_linux: g++ $(LINUXCFLAGS) $(LINUXINCLUDE) -c $(NAME).cpp g++ -Wl,--export-dynamic -shared -o $(NAME).pd_linux $(NAME).o -lc -lstk strip --strip-unneeded $(NAME).pd_linux rm -f *.o # ------------------------------------------------------- clean: rm *.pd_linux install: cp $(NAME).pd_* $(INSTALLPATH) install -d $(PDDIR)/doc/5.reference/$(NAME)-help.pd ggee-0.28/experimental/README.stk000066400000000000000000000007771402462307700165470ustar00rootroot00000000000000 In order to compile the stk external you have to put the latest stk release (4.2.0) in this directory. * First compile stk if stk is compiled just do a make stk.pd_linux. Hint: You may have to set the rawwaves path in stk in so that the external can find them. See the STK INSTALL file for details. You do not have to specify a special audio API, as audio I/O is done through pd. The stk configure command should be something like this: ./configure RAWWAVE_PATH="/home/gary/rawwaves/" Guenter Geiger ggee-0.28/experimental/fofsynth~-help.pd000066400000000000000000000050371402462307700203720ustar00rootroot00000000000000#N canvas 1 88 828 646 10; #X floatatom 103 48 0 0 0 0 - - -; #X floatatom 226 82 0 0 0 0 - - -; #X floatatom 243 117 0 0 0 0 - - -; #X floatatom 260 179 0 0 0 0 - - -; #X obj 208 418 dac~; #X obj 209 237 fofsynth~; #X text 272 232 fofsynth~ is the same as fof~; #X text 101 31 fundamental frequency; #X text 257 82 formant frequency; #X text 273 116 raise time in percent; #X text 26 611 (C) Guenter Geiger 1999; #X obj 209 353 *~; #X obj 224 288 dbtorms; #X floatatom 224 267 0 0 0 0 - - -; #X obj 14 179 osc~; #X floatatom 14 136 0 0 0 0 - - -; #X obj 14 203 *~; #X obj 50 180 sig~ 3; #X floatatom 64 147 0 0 0 0 - - -; #X text 12 93 vibrato; #X text 11 113 freq; #X text 64 125 depth; #X obj 103 200 line~; #X obj 224 330 line~; #X obj 224 309 pack 100 300; #X obj 209 387 clip~ -1 1; #X msg 183 186 debug; #X msg 612 203 bang; #N canvas 0 0 450 300 (subpatch) 0; #X array array1 10240 float 0; #X coords 0 1 10240 -1 400 300 1; #X restore 411 307 graph; #X obj 612 284 tabwrite~ array1; #X msg 692 248 \; array1 resize 10240; #X msg 151 68 200; #X obj 542 268 *~; #X obj 557 240 sig~ 0.2; #X text 610 183 debug; #X text 319 5 fof~ in its default mode; #X text 298 17 =================================; #X text 291 180 fall time in % of period; #X floatatom 548 172 0 0 0 0 - - -; #X text 334 43 THIS IS STILL NOT REALLY FINISHED; #X msg 151 103 1; #X obj 14 158 sig~ 4; #X msg 154 144 200; #X msg 47 34 120; #X obj 103 181 pack 100 100; #N canvas 503 244 494 344 META 0; #X text 12 205 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 45 LICENSE Tcl/Tk; #X text 12 185 AUTHOR Guenter Geiger; #X text 12 65 DESCRIPTION this is still not really finished; #X text 12 85 INLET_0 debug float signal; #X text 12 105 INLET_1 float; #X text 12 125 INLET_2 float; #X text 12 145 INLET_3 float; #X text 12 165 OUTLET_0 signal; #X text 12 5 ALIAS fof~; #X text 12 25 KEYWORDS; #X restore 772 622 pd META; #X connect 0 0 44 0; #X connect 1 0 5 1; #X connect 2 0 5 2; #X connect 3 0 5 3; #X connect 5 0 11 0; #X connect 5 0 32 0; #X connect 11 0 25 0; #X connect 12 0 24 0; #X connect 13 0 12 0; #X connect 14 0 16 0; #X connect 15 0 41 0; #X connect 16 0 5 0; #X connect 17 0 16 1; #X connect 18 0 17 0; #X connect 22 0 5 0; #X connect 23 0 11 1; #X connect 24 0 23 0; #X connect 25 0 4 1; #X connect 25 0 4 0; #X connect 26 0 5 0; #X connect 27 0 29 0; #X connect 31 0 1 0; #X connect 32 0 29 0; #X connect 33 0 32 1; #X connect 38 0 33 0; #X connect 40 0 2 0; #X connect 41 0 14 0; #X connect 42 0 3 0; #X connect 43 0 0 0; #X connect 44 0 22 0; ggee-0.28/experimental/fofsynth~.c000066400000000000000000000201511402462307700172550ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ fofsynth~ ----------------------------- */ #ifndef _WIN32 void garray_usedindsp(t_garray *x); #endif #define DEBUG(a,b) if (x->debug) post(a,b); #define MAXGRAINS 1000 #define PD_PI 3.14159 static t_word* fofcos_table; static t_sample* halfcos_table; static t_sample* exp_table; static void cos_maketable(void) { int i; t_word *fp; t_sample phase, phsinc = (2. * PD_PI) / COSTABSIZE; if (fofcos_table) return; fofcos_table = (t_word *)getbytes(sizeof(t_word) * (COSTABSIZE+1)); for (i = COSTABSIZE + 1, fp = fofcos_table, phase = 0; i--; fp++, phase += phsinc) fp->w_float = cos(phase); } static void halfcos_maketable(void) { int i; t_sample *fp, phase, phsinc = (PD_PI) / COSTABSIZE; if (halfcos_table) return; halfcos_table = (t_sample *)getbytes(sizeof(t_sample) * (COSTABSIZE+1)); for (i = COSTABSIZE + 1, fp = halfcos_table, phase = PD_PI; i--; fp++, phase += phsinc) *fp = 0.5*(cos(phase) + 1.0); } static void exp_maketable(void) { int i; t_sample *fp, phase, phsinc = (2 * PD_PI) / COSTABSIZE; if (exp_table) return; exp_table = (t_sample *)getbytes(sizeof(t_sample) * (COSTABSIZE+1)); for (i = COSTABSIZE + 1, fp = exp_table, phase = 0; i--; fp++, phase += phsinc) *fp = exp(-phase); } static t_class *fofsynth_class; typedef struct _grain { struct _grain *next; t_float formph; /* 0 ... 1 */ t_float formphinc; t_float envph; int falling; } t_grain; typedef struct _fofsynth { t_object x_obj; /* it is possible to use 2 array, prob change this one int the future */ t_symbol* x_arrayname; /* template */ int x_npoints; t_word *x_vec; /* fof */ int debug; int maxgrains; int numgrains; float* x_envelope; /* the queue of grains */ t_grain* grainbase; t_grain* grainstart; t_grain* grainend; t_float fundph; /* 0 to 1; if 1 -> add a new grain */ t_float fundfreq; /* input parameter 1 */ t_float formfreq; /* input paramter 2 */ t_float risedur; /* input parameter 3 ( in % of total duration )*/ t_float falldur; /* input parameter 5 ( in % of total duration */ /* other */ int neednewgrain; } t_fofsynth; /* build a cyclic list */ static t_grain* grain_makecyclic(t_grain* base,int num) { t_grain* cur = base; while (--num) { cur->next = cur+1; cur++; } cur->next = base; return base; } static t_int *fofsynth_perform(t_int *w) { t_fofsynth* x = (t_fofsynth*) (w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); t_float totaldur = (x->risedur+ x->falldur)*0.01/ *in; t_sample srate = 44100.0; /*((t_signal*)w[2])->s_sr;*/ t_sample israte = 1.0/srate; t_float fundphase = x->fundph; t_float numperiods = totaldur*x->formfreq; t_float formphinc = (x->formfreq/srate); t_sample risinc; t_sample fallinc; t_grain* cur; risinc = (x->risedur == 0.0) ? 1.0 : 1.0/ (srate*totaldur*0.01*x->risedur); fallinc = (x->falldur == 0.0) ? 1.0 : 1.0/ (srate*totaldur*0.01*x->falldur); DEBUG(" fundph %3.2f",x->fundph); DEBUG(" fundfreq %3.2f",x->fundfreq); DEBUG(" formfreq %3.2f",x->formfreq); DEBUG(" risedur %3.2f %",x->risedur); DEBUG(" falldur %3.2f %",x->falldur); DEBUG(" totaldur %3.2f s",totaldur); DEBUG(" risinc %0.6f",risinc); DEBUG(" fallinc %0.6f",fallinc); DEBUG(" formant increase %3.2f",formphinc); DEBUG(" numgrains %d",x->numgrains); while (n--) { fundphase+=*++in*israte; *out = 0.0; if (x->neednewgrain) { /* new grain, they are deleted separetely */ t_grain* newgrain = x->grainend; /* DEBUG("new grain created",0); */ if (newgrain->next == x->grainstart) { post("fof: grain overflow"); x->neednewgrain = 0; } else { x->numgrains++; x->grainend = newgrain->next; newgrain->formphinc = formphinc; newgrain->falling = 0; newgrain->formph = newgrain->envph = 0.0; x->neednewgrain = 0; } } cur = x->grainstart; while (cur != x->grainend) { t_sample formphase = cur->formph; t_sample envelope; t_sample tph = (formphase - (t_sample)((int) formphase)); t_sample val = x->x_vec[(int) (tph * x->x_npoints)].w_float; /* Apply the envelope */ if (!cur->falling && (cur->envph <= 1.0)) { envelope = *(halfcos_table + (int) (cur->envph * COSTABSIZE)); cur->envph+=risinc; val *= envelope; } else if (!cur->falling) { cur->falling = 1; cur->envph = 0; } if (cur->falling) { envelope = *(exp_table + (int) (cur->envph * COSTABSIZE)); cur->envph+=fallinc; val *= envelope; } /* end of envelope code */ formphase+=cur->formphinc; cur->formph = formphase; if (formphase >= numperiods) { /* dead */ DEBUG("grain died",0); x->grainstart = cur->next; x->numgrains--;/* not needed */ } cur = cur->next; *out += val; } if (fundphase > 1.0) { fundphase -= 1.0; x->neednewgrain=1; } out++; } x->fundph=fundphase; x->debug = 0; return (w+5); } void fofsynth_usearray(t_symbol* s,int* points,t_word** vec) { t_garray *a; if (!(a = (t_garray *)pd_findbyclass(s, garray_class))) error("%s: no such array", s->s_name); else if (!garray_getfloatwords(a,points,vec)) error("%s: bad template for fof~", s->s_name); else garray_usedindsp(a); } static void fofsynth_dsp(t_fofsynth *x, t_signal **sp) { if (x->x_arrayname) fofsynth_usearray(x->x_arrayname,&x->x_npoints, &x->x_vec); else { x->x_npoints=COSTABSIZE; x->x_vec = fofcos_table; } dsp_add(fofsynth_perform, 4, x, sp[0]->s_vec,sp[1]->s_vec, sp[0]->s_n); } static void fofsynth_free(t_fofsynth *x) { freebytes(x->grainbase,sizeof(t_grain)*x->maxgrains); } static void fofsynth_debug(t_fofsynth* x) { x->debug = 1; } static void fofsynth_float(t_fofsynth* x,t_float f) { x->fundfreq = f > 0.0 ? f : -f; } static void *fofsynth_new(t_symbol* s,t_float a,t_float b,t_float c,t_float d) { int maxgrains = MAXGRAINS; t_fofsynth *x = (t_fofsynth *)pd_new(fofsynth_class); x->debug = 0; x->x_arrayname = s; if (s == &s_) x->x_arrayname = NULL; /* setup the grain queue */ x->grainbase = getbytes(sizeof(t_grain)*maxgrains); x->maxgrains = maxgrains; grain_makecyclic(x->grainbase,maxgrains); x->grainstart = x->grainbase; x->grainend = x->grainbase; x->numgrains = 0; /* some of them could be signals too */ floatinlet_new(&x->x_obj, &x->formfreq); floatinlet_new(&x->x_obj, &x->risedur); floatinlet_new(&x->x_obj, &x->falldur); x->fundph = 0.0; x->fundfreq = 200.0; x->formfreq = 600.0; x->risedur = 5.0; x->falldur = 140.0; if (a) x->fundfreq = a; if (b) x->formfreq = b; if (c) x->risedur = c; if (d) x->falldur = d; outlet_new(&x->x_obj, &s_signal); return (x); } void fofsynth_tilde_setup(void) { fofcos_table = NULL; halfcos_table = NULL; fofsynth_class = class_new(gensym("fof~"), (t_newmethod) fofsynth_new,(t_method) fofsynth_free, sizeof(t_fofsynth), 0,A_DEFSYM, A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); class_addcreator((t_newmethod)fofsynth_new,gensym("fofsynth~"),A_DEFSYM, A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); class_addmethod(fofsynth_class, nullfn, gensym("signal"), 0); class_addmethod(fofsynth_class, (t_method) fofsynth_dsp, gensym("dsp"), 0); class_addfloat(fofsynth_class, (t_method) fofsynth_float); class_addmethod(fofsynth_class,(t_method) fofsynth_debug, gensym("debug"),0); cos_maketable(); halfcos_maketable(); exp_maketable(); } ggee-0.28/experimental/pvocfreq-help.pd000066400000000000000000000005731402462307700201610ustar00rootroot00000000000000#N canvas 1 88 450 318 10; #X text 54 47 placeholder help patch; #N canvas 297 145 494 344 META 0; #X text 12 95 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 35 LICENSE Tcl/Tk; #X text 12 75 AUTHOR Guenter Geiger; #X text 12 55 DESCRIPTION; #X text 12 15 KEYWORDS signal; #X restore 396 288 pd META; #X obj 140 126 shuffle~; ggee-0.28/experimental/pvocfreq.c000066400000000000000000000037021402462307700170470ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #ifdef _MSC_VER #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); } ggee-0.28/experimental/stk-help.pd000066400000000000000000000030321402462307700171260ustar00rootroot00000000000000#N canvas 0 26 450 387 10; #X obj 151 263 stk BeeThree; #X obj 142 307 dac~; #X msg 14 84 print; #X text 13 66 Learn about the different instruments:; #X floatatom 240 248 5 0 0 0 - - -; #X msg 48 121 38 0.5; #X msg 15 121 38 1; #X msg 95 121 38 0.25; #X msg 147 121 38 0.1; #X text 14 102 Notes and velocity; #X text 238 231 velocity (0-1); #X msg 18 225 control 1 \$1; #X floatatom 18 209 5 0 0 0 - - -; #X text 16 196 change different control channels (see stk docs); #X text 17 361 (C) 1999-2004 Guenter Geiger; #X text 12 15 stk - external to access the instrument from Perry Cooks Synthesis Toolkit; #X msg 18 276 aftertouch \$1; #X msg 19 324 pitchbend \$1; #X floatatom 18 261 5 0 0 0 - - -; #X floatatom 19 310 5 0 0 0 - - -; #X text 17 248 aftertouch; #X text 18 296 pitchbend; #N canvas 335 203 494 344 META 0; #X text 12 155 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 135 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION external to access the instrument from Perry Cook's Synthesis Toolkit; #X text 12 75 INLET_0 list print control aftertouch pitchbend; #X text 12 95 INLET_1 float; #X text 12 115 OUTLET_0 signal; #X restore 402 366 pd META; #X connect 0 0 1 0; #X connect 0 0 1 1; #X connect 2 0 0 0; #X connect 4 0 0 1; #X connect 5 0 0 0; #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; #X connect 11 0 0 0; #X connect 12 0 11 0; #X connect 16 0 0 0; #X connect 17 0 0 0; #X connect 18 0 16 0; #X connect 19 0 17 0; ggee-0.28/experimental/stk.cpp000066400000000000000000000102531402462307700163620ustar00rootroot00000000000000#include #ifdef NT #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* STK includes */ #include "stk.h" /* ------------------------ stk ----------------------------- */ static t_class *stk_class; typedef struct _stk { t_object x_obj; Instrmnt *instrument; t_float x_velo; } t_stk; char* stk_instruments[255]; void stk_print(t_stk* x) { int i=0; while (strncmp(stk_instruments[i],"LastInst",8)) { post("%s",stk_instruments[i]); i++; } } #define DI(name) if ((stk_instruments[i++] = #name) && !strcmp(s->s_name, #name )) \ { x->instrument = new name;} #define DI2(name,y) if ((stk_instruments[i++] = #name) && !strcmp(s->s_name, #name )) \ { x->instrument = new name(y);} static void stk_set_instrument(t_stk* x,t_symbol* s) { int i = 0; x->instrument = NULL; DI2(Clarinet,10.0); DI2(BlowHole,10.0); DI2(Saxofony,10.0); DI2(Flute,10.0); DI2(Brass,10.0); DI(BlowBotl); DI2(Bowed,10.0); DI2(Plucked,5.0); DI2(StifKarp,5.0); DI2(Sitar,5.0); DI2(Mandolin,5.0); DI(Rhodey); DI(Wurley); DI(TubeBell); DI(HevyMetl); DI(PercFlut); DI(BeeThree); DI(FMVoices); DI(VoicForm); DI(Moog); DI(Simple); DI(Drummer); DI(BandedWG); DI(Shakers); DI(ModalBar); // DI2(Mesh2D,10, 10); DI(Resonate); DI(Whistle); if (!x->instrument) error("No such instrument %s",s->s_name); stk_instruments[i] = "LastInst"; } static void stk_bang(t_stk *x) { post("bang"); } static t_int *stk_perform(t_int *w) { t_stk* x = (t_stk*)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); while (n--) { *out++ = x->instrument->tick(); } return (w+4); } static void stk_dsp(t_stk *x, t_signal **sp) { dsp_add(stk_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } static void stk_noteOn(t_stk *x,t_float f) { x->instrument->noteOn(f,x->x_velo); } static void stk_noteOff(t_stk *x) { x->instrument->noteOff(0); } static void stk_control(t_stk *x,t_floatarg f1,t_floatarg f2) { x->instrument->controlChange((int)f1,f2); } static void stk_control1(t_stk *x,t_floatarg f1) { x->instrument->controlChange(1,f1); } static void stk_control2(t_stk *x,t_floatarg f1) { x->instrument->controlChange(2,f1); } static void stk_control3(t_stk *x,t_floatarg f1) { x->instrument->controlChange(3,f1); } static void stk_control4(t_stk *x,t_floatarg f1) { x->instrument->controlChange(4,f1); } static void stk_aftertouch(t_stk *x,t_floatarg f1) { x->instrument->controlChange(128,f1); } static void stk_pitchbend(t_stk *x,t_floatarg f1) { x->instrument->setFrequency(f1); } static void stk_float(t_stk* x,t_floatarg f) { if (f > 20) stk_noteOn(x,f); else stk_noteOff(x); } static void *stk_new(t_symbol* s) { t_stk *x = (t_stk *)pd_new(stk_class); stk_set_instrument(x,s); if (x->instrument == NULL) { post("stk: %s no such instrument",s->s_name); return NULL; } floatinlet_new(&x->x_obj, &x->x_velo); x->x_velo = 0.1; outlet_new(&x->x_obj, gensym("signal")); return (x); } extern "C" { void stk_setup(void) { stk_class = class_new(gensym("stk"), (t_newmethod)stk_new, 0, sizeof(t_stk), 0,A_DEFSYM,A_NULL); class_addmethod(stk_class, nullfn, gensym("signal"), A_NULL); class_addmethod(stk_class, (t_method) stk_dsp, gensym("dsp"), A_NULL); class_addbang(stk_class,stk_bang); class_addfloat(stk_class,stk_float); class_addmethod(stk_class,(t_method) stk_control,gensym("control"),A_DEFFLOAT,A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_control1,gensym("control1"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_control2,gensym("control2"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_control3,gensym("control3"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_control4,gensym("control4"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_aftertouch,gensym("aftertouch"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_pitchbend,gensym("pitchbend"),A_DEFFLOAT,A_NULL); class_addmethod(stk_class,(t_method) stk_print,gensym("print"),A_NULL); } } ggee-0.28/experimental/stk.h000066400000000000000000000033711402462307700160320ustar00rootroot00000000000000#ifdef __linux__ #define __OS_LINUX__ #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include //#include #include #include #include #include #include #include #include #include #include #include #include #include ggee-0.28/experimental/tabwrite4~-help.pd000066400000000000000000000006651402462307700204410ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 140 126 tabwrite4~; #X text 54 47 placeholder help patch; #N canvas 459 118 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 45 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 85 INLET_0; #X text 12 105 OUTLET_0; #X text 12 65 DESCRIPTION; #X text 12 25 KEYWORDS signal array; #X restore 390 270 pd META; ggee-0.28/experimental/tabwrite4~.c000066400000000000000000000113261402462307700173260ustar00rootroot00000000000000 #include #include #include // fprintf /* ------------------------- tabwrite4~ -------------------------- */ static t_class *tabwrite4_tilde_class; typedef struct _tabwrite4_tilde { t_object x_obj; int x_phase; int x_npoints; t_word *x_vec; t_symbol *x_arrayname; t_float x_f; t_sample x_1; t_sample x_2; t_sample x_3; t_sample x_4; float x_index; } t_tabwrite4_tilde; static void *tabwrite4_tilde_new(t_symbol *s) { t_tabwrite4_tilde *x = (t_tabwrite4_tilde *)pd_new(tabwrite4_tilde_class); x->x_phase = 0x7fffffff; x->x_arrayname = s; x->x_f = 0; x->x_1 = 0.; x->x_2 = 0.; x->x_3 = 0.; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); //outlet_new(&x->x_obj, &s_signal); return (x); } static void tabwrite4_tilde_redraw(t_tabwrite4_tilde *x) { t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class); if (!a) bug("tabwrite4_tilde_redraw"); else garray_redraw(a); } static t_int *tabwrite4_tilde_perform(t_int *w) { t_tabwrite4_tilde *x = (t_tabwrite4_tilde *)(w[1]); t_sample *in1 = (t_sample *)(w[2]); t_sample *in2 = (t_sample *)(w[3]); int n = (int)(w[4]); t_sample* end2 = in2 + n; t_word *buf = x->x_vec; t_sample a,b,c,d; t_sample findex = *in2; t_sample frac; int iindex = (int)findex; int wraparound = 0; int maxindex = x->x_npoints-1; if (!buf) return (w+5); b = x->x_1; c = x->x_2; d = x->x_3; while (n--) { float cminusb; findex = *in2++; #if 0 while ((int)findex > iindex) { iindex++; buf[iindex].w_float=buf[iindex-1].w_float; } #endif iindex = (int)findex; // post("iindex %d, findex %f",iindex,findex); if (in2 < end2 && findex > *in2) { wraparound = 1; //post("wraparound"); } a=b; b=c; c=d; d = *in1++; frac = findex - iindex; iindex +=64; // one blocksize and 4 points if (iindex < 0) { iindex += maxindex+1; } else if (iindex > maxindex) { iindex -= maxindex; } cminusb = c-b; buf[iindex].w_float = b + frac * ( cminusb - 0.1666667f * (1.-frac) * ( (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b) ) ); } //post("written to %d",iindex); x->x_1 = b; x->x_2 = c; x->x_3 = d; #if 0 buf[maxindex-2].w_float = buf[maxindex-3].w_float*0.5; buf[maxindex-1].w_float = buf[maxindex-2].w_float*0.5; buf[maxindex].w_float = buf[maxindex-1].w_float*0.5; buf[2].w_float = buf[3].w_float*0.5; buf[1].w_float = buf[2].w_float*0.5; buf[0].w_float = buf[1].w_float*0.5; #endif if (wraparound) tabwrite4_tilde_redraw(x); return (w+5); } void tabwrite4_tilde_set(t_tabwrite4_tilde *x, t_symbol *s) { t_garray *a; x->x_arrayname = s; if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) { if (*s->s_name) pd_error(x, "tabwrite4~: %s: no such array", x->x_arrayname->s_name); x->x_vec = 0; } else if (!garray_getfloatwords(a, &x->x_npoints, &x->x_vec)) { pd_error(x, "%s: bad template for tabwrite4~", x->x_arrayname->s_name); x->x_vec = 0; } else garray_usedindsp(a); } static void tabwrite4_tilde_dsp(t_tabwrite4_tilde *x, t_signal **sp) { tabwrite4_tilde_set(x, x->x_arrayname); dsp_add(tabwrite4_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void tabwrite4_tilde_bang(t_tabwrite4_tilde *x) { x->x_phase = 0; } static void tabwrite4_tilde_start(t_tabwrite4_tilde *x, t_floatarg f) { x->x_phase = (f > 0 ? f : 0); } static void tabwrite4_tilde_stop(t_tabwrite4_tilde *x) { if (x->x_phase != 0x7fffffff) { tabwrite4_tilde_redraw(x); x->x_phase = 0x7fffffff; } } void tabwrite4_tilde_setup(void) { tabwrite4_tilde_class = class_new(gensym("tabwrite4~"), (t_newmethod)tabwrite4_tilde_new, 0, sizeof(t_tabwrite4_tilde), 0, A_DEFSYM, 0); CLASS_MAINSIGNALIN(tabwrite4_tilde_class, t_tabwrite4_tilde, x_f); class_addmethod(tabwrite4_tilde_class, (t_method)tabwrite4_tilde_dsp, gensym("dsp"), 0); class_addmethod(tabwrite4_tilde_class, (t_method)tabwrite4_tilde_set, gensym("set"), A_SYMBOL, 0); class_addmethod(tabwrite4_tilde_class, (t_method)tabwrite4_tilde_stop, gensym("stop"), 0); class_addmethod(tabwrite4_tilde_class, (t_method)tabwrite4_tilde_start, gensym("start"), A_DEFFLOAT, 0); class_addbang(tabwrite4_tilde_class, tabwrite4_tilde_bang); } ggee-0.28/filters/000077500000000000000000000000001402462307700140275ustar00rootroot00000000000000ggee-0.28/filters/bandpass-help.pd000066400000000000000000000025571402462307700171060ustar00rootroot00000000000000#N canvas 0 26 423 419 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 76 12 Bandpass coefficients for biquad~; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 176 119 0 0 0 0 - - -; #X floatatom 267 119 0 0 0 0 - - -; #X obj 267 142 trigger bang float; #X obj 113 216 biquad~; #X obj 113 156 noise~; #X obj 102 258 dac~; #X obj 179 74 hsl 128 17 20 20000 1 0 empty empty frequency 5 9 0 10 -203904 -1 -1 0 0; #X obj 270 97 hsl 128 17 0 100 0 0 empty empty bandwidth 5 9 0 10 -261682 -1 -1 0 1; #X obj 176 185 bandpass; #N canvas 433 26 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION bandpass forefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 OUTLET_0 list; #X restore 372 396 pd META; #X connect 5 0 13 0; #X connect 6 0 7 0; #X connect 7 0 13 0; #X connect 7 1 13 1; #X connect 8 0 10 1; #X connect 8 0 10 0; #X connect 9 0 8 0; #X connect 11 0 5 0; #X connect 12 0 6 0; #X connect 13 0 8 0; ggee-0.28/filters/bandpass.c000066400000000000000000000036221402462307700157710ustar00rootroot00000000000000 /* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- bandpass ----------------------------*/ static t_class *bandpass_class; void bandpass_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float alpha = e_alpha(x->x_bw* 0.01,omega); t_float b1 = 0.; t_float b0 = alpha; t_float b2 = -alpha; t_float a0 = 1 + alpha; t_float a1 = -2.*cos(omega); t_float a2 = 1 - alpha; /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("bandpass: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void bandpass_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; bandpass_bang(x); } static void *bandpass_new(t_floatarg f,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); /* floatinlet_new(&x->x_obj, &x->x_gain); */ floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; return (x); } void bandpass_setup(void) { bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(bandpass_class,bandpass_bang); class_addfloat(bandpass_class,bandpass_float); } ggee-0.28/filters/equalizer-help.pd000066400000000000000000000033301402462307700173020ustar00rootroot00000000000000#N canvas 0 26 456 417 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 96 109 0 0 0 0 - - -; #X floatatom 157 109 0 0 0 0 - - -; #X obj 157 132 trigger bang float; #X obj 43 206 biquad~; #X obj 43 146 noise~; #X obj 99 64 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 5400 0; #X obj 160 87 hsl 128 17 0 100 0 1 empty empty gain 5 9 0 10 -204786 -1 -1 6300 0; #X obj 34 266 dac~; #X obj 43 234 *~ 0.1; #X floatatom 297 109 0 0 0 0 - - -; #X obj 297 132 trigger bang float; #X obj 300 87 hsl 128 17 0 100 0 1 empty empty bandwidth 5 9 0 10 -261682 -1 -1 9100 0; #X text 71 26 ==============================================; #X text 76 12 Parametric Equalizer coefficients for biquad~; #X obj 96 175 equalizer 5000 70 8; #N canvas 466 26 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION parametric equalizer coefficients for biquad~ ; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 list; #X restore 406 396 pd META; #X connect 3 0 17 0; #X connect 4 0 5 0; #X connect 5 0 17 0; #X connect 5 1 17 1; #X connect 6 0 11 0; #X connect 7 0 6 0; #X connect 8 0 3 0; #X connect 9 0 4 0; #X connect 11 0 10 0; #X connect 11 0 10 1; #X connect 12 0 13 0; #X connect 13 0 17 0; #X connect 13 1 17 2; #X connect 14 0 12 0; #X connect 17 0 6 0; ggee-0.28/filters/equalizer.c000066400000000000000000000037141402462307700162010ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- equ ----------------------------*/ static t_class *equ_class; void equ_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float alpha = e_alpha(x->x_bw*0.01,omega); t_float b0 = 1 + alpha*e_A(x->x_gain); t_float b1 = -2.*cos(omega); t_float b2 = 1 - alpha*e_A(x->x_gain); t_float a0 = 1 + alpha/e_A(x->x_gain); t_float a1 = -2.*cos(omega); t_float a2 = 1 - alpha/e_A(x->x_gain); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("equ: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void equ_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; equ_bang(x); } static void *equ_new(t_floatarg f,t_floatarg g,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(equ_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); floatinlet_new(&x->x_obj, &x->x_gain); floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; if (g != 0.) x->x_gain = g; return (x); } void equalizer_setup(void) { equ_class = class_new(gensym("equalizer"), (t_newmethod)equ_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(equ_class,equ_bang); class_addfloat(equ_class,equ_float); } ggee-0.28/filters/filters.h000066400000000000000000000025771402462307700156630ustar00rootroot00000000000000/* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #ifndef __GGEE_FILTERS_H__ #define __GGEE_FILTERS_H__ #ifndef M_PI #define M_PI 3.141593f #endif #include #define LN2 0.69314718 #define e_A(g) (pow(10,(g/40.))) #define e_omega(f,r) (2.0*M_PI*f/r) #define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega))) #define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1))) typedef struct _rbjfilter { t_object x_obj; t_float x_rate; t_float x_freq; t_float x_gain; t_float x_bw; } t_rbjfilter; static int check_stability(t_float fb1, t_float fb2, t_float ff1, t_float ff2, t_float ff3) { float discriminant = fb1 * fb1 + 4 * fb2; if (discriminant < 0) /* imaginary roots -- resonant filter */ { /* they're conjugates so we just check that the product is less than one */ if (fb2 >= -1.0f) goto stable; } else /* real roots */ { /* check that the parabola 1 - fb1 x - fb2 x^2 has a vertex between -1 and 1, and that it's nonnegative at both ends, which implies both roots are in [1-,1]. */ if (fb1 <= 2.0f && fb1 >= -2.0f && 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0) goto stable; } return 0; stable: return 1; } #endif ggee-0.28/filters/filtgain.pd000066400000000000000000000031731402462307700161550ustar00rootroot00000000000000#N canvas 178 144 702 459 10; #X obj 38 342 biquad~; #X obj 38 316 osc~ 220; #X obj 118 340 env~; #X floatatom 38 297; #X obj 38 419 dac~; #X obj 193 428 tabwrite array1; #X obj 325 400 int; #X obj 350 401 + 1; #X msg 296 399 0; #X obj 193 410 float; #X obj 218 372 t b f; #X obj 38 398 *~; #X obj 61 399 dbtorms; #X floatatom 368 359; #X obj 296 418 sel 500; #X obj 38 277 * 40; #X obj 325 380 metro 10; #X obj 325 359 r paint; #X obj 61 381 r volume; #X obj 38 7 inlet; #X floatatom 194 368; #X floatatom 279 360; #X obj 118 360 - 100; #X obj 118 382 * 0.01; #X graph graph2 0 -1 500 1 148 253 648 113; #X array array1 500 float; #X pop; #X msg 273 272 5000; #X msg 273 82 5000; #X msg 398 82 10000; #X msg 398 272 10000; #X msg 173 83 1000; #X msg 173 271 1000; #X text 105 6 subpatch used in filter externals see; #X obj 347 12 bandpass; #X obj 414 13 notch; #X obj 470 14 lowpass; #X obj 522 13 highpass; #X obj 522 35 equalizer; #X obj 347 34 highshelf; #X obj 414 34 lowshelf; #X obj 470 34 hlshelf; #X connect 0 0 2 0; #X connect 0 0 11 0; #X connect 1 0 0 0; #X connect 2 0 22 0; #X connect 3 0 1 0; #X connect 6 0 7 0; #X connect 6 0 10 0; #X connect 6 0 14 0; #X connect 6 0 15 0; #X connect 7 0 6 1; #X connect 8 0 6 0; #X connect 9 0 5 0; #X connect 10 0 9 0; #X connect 10 1 5 1; #X connect 11 0 4 0; #X connect 11 0 4 1; #X connect 12 0 11 1; #X connect 13 0 16 1; #X connect 14 0 8 0; #X connect 15 0 3 0; #X connect 16 0 6 0; #X connect 17 0 16 0; #X connect 18 0 12 0; #X connect 19 0 0 0; #X connect 20 0 5 0; #X connect 21 0 5 1; #X connect 22 0 23 0; #X connect 23 0 9 1; #X connect 26 0 25 0; #X connect 27 0 28 0; #X connect 29 0 30 0; ggee-0.28/filters/highpass-help.pd000066400000000000000000000026431402462307700171150ustar00rootroot00000000000000#N canvas 0 26 421 418 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 176 119 0 0 0 0 - - -; #X floatatom 267 119 0 0 0 0 - - -; #X obj 267 142 trigger bang float; #X obj 113 216 biquad~; #X obj 113 156 noise~; #X obj 179 74 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 10100 0; #X obj 270 97 hsl 128 17 0 100 0 1 empty empty bandwidth 5 9 0 10 -261682 -1 -1 6200 0; #X obj 176 185 highpass; #X obj 104 276 dac~; #X text 76 12 Highpass coefficients for biquad~; #X obj 113 244 *~ 0.1; #N canvas 317 264 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION highpass coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 OUTLET_0 list; #X restore 372 397 pd META; #X connect 4 0 11 0; #X connect 5 0 6 0; #X connect 6 0 11 0; #X connect 6 1 11 1; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 11 0 7 0; #X connect 14 0 12 0; #X connect 14 0 12 1; ggee-0.28/filters/highpass.c000066400000000000000000000036361402462307700160110ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- highpass ----------------------------*/ static t_class *highpass_class; void highpass_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float alpha = e_alpha(x->x_bw* 0.01,omega); t_float b1 = -(1 + cos(omega)); t_float b0 = -b1/2.; t_float b2 = b0; t_float a0 = 1 + alpha; t_float a1 = -2.*cos(omega); t_float a2 = 1 - alpha; /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("highpass: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void highpass_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; highpass_bang(x); } static void *highpass_new(t_floatarg f,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(highpass_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); /* floatinlet_new(&x->x_obj, &x->x_gain); */ floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; return (x); } void highpass_setup(void) { highpass_class = class_new(gensym("highpass"), (t_newmethod)highpass_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(highpass_class,highpass_bang); class_addfloat(highpass_class,highpass_float); } ggee-0.28/filters/highshelf-help.pd000066400000000000000000000032661402462307700172520ustar00rootroot00000000000000#N canvas 0 26 456 417 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 96 109 0 0 0 0 - - -; #X floatatom 157 109 0 0 0 0 - - -; #X obj 157 132 trigger bang float; #X obj 43 206 biquad~; #X obj 43 146 noise~; #X obj 99 64 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 5100 0; #X obj 160 87 hsl 128 17 0 100 0 1 empty empty gain 5 9 0 10 -204786 -1 -1 2800 0; #X obj 34 266 dac~; #X obj 43 234 *~ 0.1; #X floatatom 297 109 0 0 0 0 - - -; #X obj 297 132 trigger bang float; #X obj 300 87 hsl 128 17 0 100 0 1 empty empty slope 5 9 0 10 -261682 -1 -1 6600 0; #X text 76 12 Highshelf coefficients for biquad~; #X obj 96 175 highshelf 5000 70 100; #N canvas 241 249 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION highshelf coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 list; #X restore 407 396 pd META; #X connect 4 0 17 0; #X connect 5 0 6 0; #X connect 6 0 17 0; #X connect 6 1 17 1; #X connect 7 0 12 0; #X connect 8 0 7 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 12 0 11 0; #X connect 12 0 11 1; #X connect 13 0 14 0; #X connect 14 0 17 0; #X connect 14 1 17 2; #X connect 15 0 13 0; #X connect 17 0 7 0; ggee-0.28/filters/highshelf.c000066400000000000000000000042561402462307700161430ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- highshelf ----------------------------*/ static t_class *highshelf_class; void highshelf_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float A = e_A(x->x_gain); t_float cs = cos(omega); t_float sn = sin(omega); t_float beta = e_beta(A,x->x_bw* 0.01); t_float b0 = A*((A+1) + (A-1)*cs + beta*sn); t_float b1 =-2.*A*((A-1) + (A+1)*cs); t_float b2 = A*((A+1) + (A-1)*cs - beta*sn); t_float a0 = ((A+1) - (A-1)*cs + beta*sn); t_float a1 = 2.*((A-1) - (A+1)*cs); t_float a2 = ((A+1) - (A-1)*cs - beta*sn); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("highshelf: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void highshelf_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; highshelf_bang(x); } static void *highshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(highshelf_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); floatinlet_new(&x->x_obj, &x->x_gain); floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; if (g != 0.) x->x_gain = g; return (x); } void highshelf_setup(void) { highshelf_class = class_new(gensym("highshelf"), (t_newmethod)highshelf_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(highshelf_class,highshelf_bang); class_addfloat(highshelf_class,highshelf_float); } ggee-0.28/filters/hlshelf-help.pd000066400000000000000000000045531402462307700167360ustar00rootroot00000000000000#N canvas 0 26 789 387 10; #X text 7 351 (C) Guenter Geiger 2000; #X text 211 298 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 208 248 The hlshelf object creates filter coefficients for the biquad~ filter. The three shelfs of the filter are controlled through the gains \, the boundaries of the areas through f-low and f-high; #X text 37 12 high-low shelf coefficients for biquad~; #X text 31 26 ========================================; #X floatatom 488 101 0 0 0 0 - - -; #X floatatom 349 101 0 0 0 0 - - -; #X obj 349 123 trigger bang float; #X obj 45 223 biquad~; #X obj 45 163 noise~; #X obj 491 81 hsl 128 17 20 20000 1 1 empty empty frequency-low 5 9 0 10 -203904 -1 -1 4400 0; #X obj 352 81 hsl 128 17 0 100 0 1 empty empty gain2 5 9 0 10 -204786 -1 -1 9100 0; #X obj 36 283 dac~; #X obj 45 251 *~ 0.1; #X obj 129 192 hlshelf 30 50 70 500 5000; #X obj 488 123 trigger bang float; #X floatatom 628 101 0 0 0 0 - - -; #X obj 631 81 hsl 128 17 20 20000 1 1 empty empty frequency-high 5 9 0 10 -204800 -1 -1 8800 0; #X obj 628 123 trigger bang float; #X floatatom 209 101 0 0 0 0 - - -; #X obj 209 123 trigger bang float; #X obj 212 81 hsl 128 17 0 100 0 1 empty empty gain1 5 9 0 10 -204786 -1 -1 9200 0; #X floatatom 69 100 0 0 0 0 - - -; #X obj 72 80 hsl 128 17 0 100 0 1 empty empty gain0 5 9 0 10 -204786 -1 -1 2300 0; #X obj 129 140 bang; #N canvas 450 258 494 344 META 0; #X text 12 205 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 185 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION high-low shelf coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 INLET_3 float; #X text 12 145 INLET_4 float; #X text 12 165 OUTLET_0 float; #X restore 739 366 pd META; #X connect 5 0 15 0; #X connect 6 0 7 0; #X connect 7 0 24 0; #X connect 7 1 14 2; #X connect 8 0 13 0; #X connect 9 0 8 0; #X connect 10 0 5 0; #X connect 11 0 6 0; #X connect 13 0 12 0; #X connect 13 0 12 1; #X connect 14 0 8 0; #X connect 15 0 24 0; #X connect 15 1 14 3; #X connect 16 0 18 0; #X connect 17 0 16 0; #X connect 18 0 24 0; #X connect 18 1 14 4; #X connect 19 0 20 0; #X connect 20 0 24 0; #X connect 20 1 14 1; #X connect 21 0 19 0; #X connect 22 0 14 0; #X connect 23 0 22 0; #X connect 24 0 14 0; ggee-0.28/filters/hlshelf.c000066400000000000000000000120151402462307700156170ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ hlshelf ----------------------------- */ #ifndef M_PI #define M_PI 3.141593f #endif #define SRATE 44100.0 #define MAX_GAIN 120.0f static t_class *hlshelf_class; typedef struct _hlshelf { t_object x_obj; float s_rate; float s_gain0; float s_gain1; float s_gain2; float s_ltransfq; float s_htransfq; float s_lradians; float s_hradians; } t_hlshelf; int hlshelf_check_stability(t_float fb1, t_float fb2, t_float ff1, t_float ff2, t_float ff3) { float discriminant = fb1 * fb1 + 4 * fb2; if (discriminant < 0) /* imaginary roots -- resonant filter */ { /* they're conjugates so we just check that the product is less than one */ if (fb2 >= -1.0f) goto stable; } else /* real roots */ { /* check that the parabola 1 - fb1 x - fb2 x^2 has a vertex between -1 and 1, and that it's nonnegative at both ends, which implies both roots are in [1-,1]. */ if (fb1 <= 2.0f && fb1 >= -2.0f && 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0) goto stable; } return 0; stable: return 1; } void hlshelf_check(t_hlshelf *x) { if(x->s_gain0 - x->s_gain1 > MAX_GAIN) { x->s_gain0 = x->s_gain1 + MAX_GAIN; post("setting gain0 to %f",x->s_gain0); } if(x->s_gain1 > MAX_GAIN) { x->s_gain1 = MAX_GAIN; post("setting gain1 to %f",x->s_gain1); } if(x->s_gain2 - x->s_gain1 > MAX_GAIN) { x->s_gain2 = x->s_gain1 + MAX_GAIN; post("setting gain2 to %f",x->s_gain2); } /* constrain: 0 <= x->s_ltransfq < x->s_htransfq. */ x->s_ltransfq = (x->s_ltransfq < x->s_htransfq) ? x->s_ltransfq : x->s_htransfq - 0.5f; if (x->s_ltransfq < 0) x->s_ltransfq = 0.0f; x->s_lradians = M_PI * x->s_ltransfq / x->s_rate; x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate)); } void hlshelf_bang(t_hlshelf *x) { t_atom at[6]; float c0, c1, c2, d0, d1, d2; /* output coefs */ float a1, a2, b1, b2, g1, g2; /* temp coefs */ double xf; hlshelf_check(x); /* low shelf */ xf = 0.5 * 0.115129255 * (double)(x->s_gain0 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */ if(xf < -200.) /* exp(x) -> 0 */ { a1 = 1.0f; b1 = -1.0f; g1 = 0.0f; } else { double t = tan(x->s_lradians); double e = exp(xf); double r = t / e; double kr = t * e; a1 = (r - 1) / (r + 1); b1 = (kr - 1) / (kr + 1); g1 = (kr + 1) / (r + 1); } /* high shelf */ xf = 0.5 * 0.115129255 * (double)(x->s_gain2 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */ if(xf < -200.) /* exp(x) -> 0 */ { a2 = -1.0f; b2 = 1.0f; g2 = 0.0f; } else { double t = tan(x->s_hradians); double e = exp(xf); double r = t / e; double kr = t * e; a2 = (1 - r) / (1 + r); b2 = (1 - kr) / (1 + kr); g2 = (1 + kr) / (1 + r); } /* form product */ c0 = g1 * g2 * (float)(exp((double)(x->s_gain1) * 0.05f * 2.302585093f)); ; c1 = a1 + a2; c2 = a1 * a2; d0 = 1.0f; d1 = b1 + b2; d2 = b1 * b2; if (!hlshelf_check_stability(-c1/d0,-c2/d0,d0/d0,d1/d0,d2/d0)) { post("hlshelf: filter unstable -> resetting"); c0=1.;c1=0.;c2=0.; d0=1.;d1=0.;d2=0.; } SETFLOAT(at,-c1/d0); SETFLOAT(at+1,-c2/d0); SETFLOAT(at+2,d0/d0); SETFLOAT(at+3,d1/d0); SETFLOAT(at+4,d2/d0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void hlshelf_float(t_hlshelf *x,t_floatarg f) { x->s_gain0 = f; hlshelf_bang(x); } static void *hlshelf_new(t_symbol* s,t_int argc, t_atom* at) { t_hlshelf *x = (t_hlshelf *)pd_new(hlshelf_class); t_float k0 = atom_getfloat(at); t_float k1 = atom_getfloat(at+1); t_float k2 = atom_getfloat(at+2); t_float f1 = atom_getfloat(at+3); t_float f2 = atom_getfloat(at+4); f1 = atom_getfloat(at); f2 = atom_getfloat(at); if ((f1 == 0.0f && f2 == 0.0f) || f1 > f2){ /* all gains = 0db */ f1 = 150.0f; f2 = 5000.0f; } if (f1 < 0) f1 = 0.0f; if (f2 > SRATE) f2 = .5f*SRATE; x->s_rate = SRATE; /* srate default */ x->s_gain0 = k0; x->s_gain1 = k1; x->s_gain2 = k2; x->s_ltransfq = 0.0f; x->s_htransfq = SRATE/2; x->s_lradians = M_PI * x->s_ltransfq / x->s_rate; x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate)); floatinlet_new(&x->x_obj, &x->s_gain1); floatinlet_new(&x->x_obj, &x->s_gain2); floatinlet_new(&x->x_obj, &x->s_ltransfq); floatinlet_new(&x->x_obj, &x->s_htransfq); outlet_new(&x->x_obj, &s_list); return (x); } void hlshelf_setup(void) { hlshelf_class = class_new(gensym("hlshelf"), (t_newmethod)hlshelf_new, 0, sizeof(t_hlshelf), 0, A_GIMME, 0); class_addbang(hlshelf_class,hlshelf_bang); class_addfloat(hlshelf_class,hlshelf_float); } ggee-0.28/filters/lowpass-help.pd000066400000000000000000000026371402462307700170020ustar00rootroot00000000000000#N canvas 0 26 423 417 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 176 119 0 0 0 0 - - -; #X floatatom 267 119 0 0 0 0 - - -; #X obj 267 142 trigger bang float; #X obj 113 216 biquad~; #X obj 113 156 noise~; #X obj 179 74 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 8000 0; #X obj 270 97 hsl 128 17 0 100 0 1 empty empty bandwidth 5 9 0 10 -261682 -1 -1 6400 0; #X obj 104 276 dac~; #X obj 113 244 *~ 0.1; #X text 76 12 Lowpass coefficients for biquad~; #X obj 176 185 lowpass; #N canvas 244 258 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION lowpass coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 OUTLET_0 list; #X restore 373 396 pd META; #X connect 4 0 14 0; #X connect 5 0 6 0; #X connect 6 0 14 0; #X connect 6 1 14 1; #X connect 7 0 12 0; #X connect 8 0 7 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 12 0 11 0; #X connect 12 0 11 1; #X connect 14 0 7 0; ggee-0.28/filters/lowpass.c000066400000000000000000000036141402462307700156670ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- lowpass ----------------------------*/ static t_class *lowpass_class; void lowpass_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float alpha = e_alpha(x->x_bw*0.01,omega); t_float b1 = 1 - cos(omega); t_float b0 = b1/2.; t_float b2 = b0; t_float a0 = 1 + alpha; t_float a1 = -2.*cos(omega); t_float a2 = 1 - alpha; /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("lowpass: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void lowpass_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; lowpass_bang(x); } static void *lowpass_new(t_floatarg f,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(lowpass_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); /* floatinlet_new(&x->x_obj, &x->x_gain); */ floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; return (x); } void lowpass_setup(void) { lowpass_class = class_new(gensym("lowpass"), (t_newmethod)lowpass_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(lowpass_class,lowpass_bang); class_addfloat(lowpass_class,lowpass_float); } ggee-0.28/filters/lowshelf-help.pd000066400000000000000000000032631402462307700171310ustar00rootroot00000000000000#N canvas 0 26 456 417 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 96 109 0 0 0 0 - - -; #X floatatom 157 109 0 0 0 0 - - -; #X obj 157 132 trigger bang float; #X obj 43 206 biquad~; #X obj 43 146 noise~; #X obj 99 64 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 5100 0; #X obj 160 87 hsl 128 17 0 100 0 1 empty empty gain 5 9 0 10 -204786 -1 -1 2800 0; #X obj 34 266 dac~; #X obj 43 234 *~ 0.1; #X text 76 12 Lowshelf coefficients for biquad~; #X floatatom 297 109 0 0 0 0 - - -; #X obj 297 132 trigger bang float; #X obj 300 87 hsl 128 17 0 100 0 1 empty empty slope 5 9 0 10 -261682 -1 -1 6600 0; #X obj 96 175 lowshelf 4000 50 100; #N canvas 243 238 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION lowshelf coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 list; #X restore 405 396 pd META; #X connect 4 0 17 0; #X connect 5 0 6 0; #X connect 6 0 17 0; #X connect 6 1 17 1; #X connect 7 0 12 0; #X connect 8 0 7 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 12 0 11 0; #X connect 12 0 11 1; #X connect 14 0 15 0; #X connect 15 0 17 0; #X connect 15 1 17 2; #X connect 16 0 14 0; #X connect 17 0 7 0; ggee-0.28/filters/lowshelf.c000066400000000000000000000042371402462307700160240ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- lowshelf ----------------------------*/ static t_class *lowshelf_class; void lowshelf_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float A = e_A(x->x_gain); t_float cs = cos(omega); t_float sn = sin(omega); t_float beta = e_beta(A,x->x_bw*0.01); t_float b0 = A*((A+1) - (A-1)*cs + beta*sn); t_float b1 = 2.*A*((A-1) - (A+1)*cs); t_float b2 = A*((A+1) - (A-1)*cs - beta*sn); t_float a0 = ((A+1) + (A-1)*cs + beta*sn); t_float a1 = -2.*((A-1) + (A+1)*cs); t_float a2 = ((A+1) + (A-1)*cs - beta*sn); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("lowshelf: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void lowshelf_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; lowshelf_bang(x); } static void *lowshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(lowshelf_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); floatinlet_new(&x->x_obj, &x->x_gain); floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; if (g != 0.) x->x_gain = g; return (x); } void lowshelf_setup(void) { lowshelf_class = class_new(gensym("lowshelf"), (t_newmethod)lowshelf_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(lowshelf_class,lowshelf_bang); class_addfloat(lowshelf_class,lowshelf_float); } ggee-0.28/filters/moog~-help.pd000066400000000000000000000026671402462307700164540ustar00rootroot00000000000000#N canvas 0 26 343 328 10; #X obj 186 210 moog~; #X obj 178 288 dac~; #X floatatom 226 163 5 0 0 0 - - -; #X floatatom 183 104 5 0 0 0 - - -; #X floatatom 25 113 5 0 0 0 - - -; #X obj 238 237 env~; #X floatatom 238 257 5 0 0 0 - - -; #X obj 186 257 *~ 0.1; #X msg 182 163 reset; #X obj 116 105 +~ 1; #X floatatom 116 63 5 0 0 0 - - -; #X floatatom 180 128 5 0 0 0 - - -; #X obj 116 146 +~ 100; #X obj 116 84 osc~ 0.25; #X obj 116 125 *~ 2000; #X obj 226 182 sig~ 3; #X obj 25 139 phasor~ 110; #X msg 249 52 \; pd dsp 1 \;; #X text 17 7 A signal controlled "moog" resonant lowpass; #X text 272 163 Q (1-4); #X text 61 46 resonance freq modulation; #N canvas 284 271 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS signal; #X text 12 45 DESCRIPTION a signal controlled moog resonant lowpass ; #X text 12 65 INLET_0 reset signal; #X text 12 85 INLET_1 signal; #X text 12 105 INLET_2 signal; #X text 12 125 OUTLET_0 signal; #X restore 294 308 pd META; #X connect 0 0 5 0; #X connect 0 0 7 0; #X connect 2 0 15 0; #X connect 3 0 14 1; #X connect 4 0 16 0; #X connect 5 0 6 0; #X connect 7 0 1 0; #X connect 7 0 1 1; #X connect 8 0 0 0; #X connect 9 0 14 0; #X connect 10 0 13 0; #X connect 11 0 12 1; #X connect 12 0 0 1; #X connect 13 0 9 0; #X connect 14 0 12 0; #X connect 15 0 0 2; #X connect 16 0 0 0; ggee-0.28/filters/moog~.c000066400000000000000000000074251402462307700153420ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include "math.h" #include /* ----------------------------- moog ----------------------------- */ static t_class *moog_class; typedef struct _moog { t_object x_obj; t_pd in2; t_float x_1,x_2,x_3,x_4; t_float y_1,y_2,y_3,y_4; } t_moog; static void moog_reset(t_moog *x) { x->x_1 = x->x_2 = x->x_3 = x->x_4 = 0.0; x->y_1 = x->y_2 = x->y_3 = x->y_4 = 0.0; } static void *moog_new(t_symbol *s, int argc, t_atom *argv) { if (argc > 1) post("moog~: extra arguments ignored"); { t_moog *x = (t_moog *)pd_new(moog_class); outlet_new(&x->x_obj, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); inlet_new(&x->x_obj, &x->in2, &s_signal, &s_signal); moog_reset(x); return (x); } } static t_float calc_k(t_float f,t_float k) { if (k>4.) k =4.; if (k < 0.) k = 0.; if (f <= 3800) return k; k = k - 0.5*((f-3800)/4300); return k; } t_int *moog_perform(t_int *w) { t_moog* x = (t_moog*) (w[1]); t_float *in1 = (t_float *)(w[2]); t_float *p = (t_float *)(w[3]); t_float *k = (t_float *)(w[4]); t_float *out = (t_float *)(w[5]); int n = (int)(w[6]); float in; float pt,pt1; float x1 = x->x_1; float x2 = x->x_2; float x3 = x->x_3; float x4 = x->x_4; float ys1 = x->y_1; float ys2 = x->y_2; float ys3 = x->y_3; float ys4 = x->y_4; while (n--) { if (*p > 8140) *p = 8140.; *k = calc_k(*p,*k); pt =*p; pt1=(pt+1)*0.76923077; in = *in1++ - *k*ys4; ys1 = (pt1)*in + 0.3*x1 - pt*ys1; x1 = in; ys2 = (pt1)*ys1 + 0.3*x2 - pt*ys2; x2 = ys1; ys3 = (pt1)*ys2 + 0.3 *x3 - pt*ys3; x3 = ys2; ys4 = (pt1)*ys3 + 0.3*x4 - pt*ys4; x4 = ys3; *out++ = ys4; } x->y_1 = ys1; x->y_2 = ys2; x->y_3 = ys3; x->y_4 = ys4; x->x_1 = x1; x->x_2 = x2; x->x_3 = x3; x->x_4 = x4; return (w+7); } #define CLIP(x) x = ((x) > 1.0 ? (1.0) : (x)) t_int *moog_perf8(t_int *w) { t_moog* x = (t_moog*) (w[1]); t_float *in1 = (t_float *)(w[2]); t_float *p = (t_float *)(w[3]); t_float *k = (t_float *)(w[4]); t_float *out = (t_float *)(w[5]); int n = (int)(w[6]); t_float x1 = x->x_1; t_float x2 = x->x_2; t_float x3 = x->x_3; t_float x4 = x->x_4; t_float ys1 = x->y_1; t_float ys2 = x->y_2; t_float ys3 = x->y_3; t_float ys4 = x->y_4; t_float temp,temp2; t_float pt,pt1; t_float in; while (n--) { if (*p > 8140.) *p = 8140.; *k = calc_k(*p,*k); pt =*p* 0.01*0.0140845 - 0.9999999f; pt1=(pt+1.0)*0.76923077; in = *in1++ - *k*ys4; ys1 = pt1*(in + 0.3*x1) - pt*ys1; x1 = in; ys2 = pt1*(ys1 + 0.3*x2) - pt*ys2; x2 = ys1; ys3 = pt1*(ys2 + 0.3*x3) - pt*ys3; x3 = ys2; ys4 = pt1*(ys3 + 0.3*x4) - pt*ys4; x4 = ys3; *out++ = ys4; p++;k++; } x->y_1 = ys1; x->y_2 = ys2; x->y_3 = ys3; x->y_4 = ys4; x->x_1 = x1; x->x_2 = x2; x->x_3 = x3; x->x_4 = x4; return (w+7); } void dsp_add_moog(t_moog *x, t_sample *in1, t_sample *in2, t_sample *in3, t_sample *out, int n) { if (n&7) dsp_add(moog_perform, 6,(t_int)x, in1,in2,in3, out, n); else dsp_add(moog_perf8, 6,(t_int) x, in1, in2, in3, out, n); } static void moog_dsp(t_moog *x, t_signal **sp) { dsp_add_moog(x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,sp[0]->s_n); } void moog_tilde_setup(void) { moog_class = class_new(gensym("moog~"), (t_newmethod)moog_new, 0, sizeof(t_moog), 0, A_GIMME, 0); class_addmethod(moog_class, nullfn, gensym("signal"), 0); class_addmethod(moog_class, (t_method)moog_reset, gensym("reset"), 0); class_addmethod(moog_class, (t_method)moog_dsp, gensym("dsp"), A_NULL); } ggee-0.28/filters/notch-help.pd000066400000000000000000000026321402462307700164200ustar00rootroot00000000000000#N canvas 0 26 422 415 10; #X text 63 298 These filters are all controlled by a bandwidth which is expressed in octaves. A bandwidth of 100 is equivalent to one octave. ; #X text 70 26 ===================================; #X text 63 340 Attention \, only the left inlet triggers new coefficients for biquad~; #X text 8 388 (C) Guenter Geiger 2000; #X floatatom 176 119 0 0 0 0 - - -; #X floatatom 267 119 0 0 0 0 - - -; #X obj 267 142 trigger bang float; #X obj 113 216 biquad~; #X obj 113 156 noise~; #X obj 179 74 hsl 128 17 20 20000 1 1 empty empty frequency 5 9 0 10 -203904 -1 -1 8800 0; #X obj 270 97 hsl 128 17 0 300 0 1 empty empty bandwidth 5 9 0 10 -261682 -1 -1 12700 0; #X obj 104 276 dac~; #X obj 113 244 *~ 0.1; #X text 76 12 Notch coefficients for biquad~; #X obj 176 185 notch; #N canvas 232 266 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION notch coefficients for biquad~; #X text 12 65 INLET_0 float; #X text 12 85 INLET_1 float; #X text 12 105 OUTLET_0 list; #X restore 372 395 pd META; #X connect 4 0 14 0; #X connect 5 0 6 0; #X connect 6 0 14 0; #X connect 6 1 14 1; #X connect 7 0 12 0; #X connect 8 0 7 0; #X connect 9 0 4 0; #X connect 10 0 5 0; #X connect 12 0 11 0; #X connect 12 0 11 1; #X connect 14 0 7 0; ggee-0.28/filters/notch.c000066400000000000000000000035471402462307700153170ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* These filter coefficients computations are taken from http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt written by Robert Bristow-Johnson */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "filters.h" /* ------------------- notch ----------------------------*/ static t_class *notch_class; void notch_bang(t_rbjfilter *x) { t_atom at[5]; t_float omega = e_omega(x->x_freq,x->x_rate); t_float alpha = e_alpha(x->x_bw* 0.01,omega); t_float b1 = -2.*cos(omega); t_float b0 = 1; t_float b2 = b0; t_float a0 = 1 + alpha; t_float a1 = -2.*cos(omega); t_float a2 = 1 - alpha; /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { post("notch: filter unstable -> resetting"); a0=1.;a1=0.;a2=0.; b0=1.;b1=0.;b2=0.; } SETFLOAT(at,-a1/a0); SETFLOAT(at+1,-a2/a0); SETFLOAT(at+2,b0/a0); SETFLOAT(at+3,b1/a0); SETFLOAT(at+4,b2/a0); outlet_list(x->x_obj.ob_outlet,&s_list,5,at); } void notch_float(t_rbjfilter *x,t_floatarg f) { x->x_freq = f; notch_bang(x); } static void *notch_new(t_floatarg f,t_floatarg bw) { t_rbjfilter *x = (t_rbjfilter *)pd_new(notch_class); x->x_rate = 44100.0; outlet_new(&x->x_obj,&s_float); /* floatinlet_new(&x->x_obj, &x->x_gain); */ floatinlet_new(&x->x_obj, &x->x_bw); if (f > 0.) x->x_freq = f; if (bw > 0.) x->x_bw = bw; return (x); } void notch_setup(void) { notch_class = class_new(gensym("notch"), (t_newmethod)notch_new, 0, sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); class_addbang(notch_class,notch_bang); class_addfloat(notch_class,notch_float); } ggee-0.28/ggee-meta.pd000066400000000000000000000004461402462307700145430ustar00rootroot00000000000000#N canvas 10 72 200 200 10; #N canvas 268 162 371 165 META 0; #X text 12 11 NAME ggee; #X text 11 92 AUTHOR Guenter Geiger; #X text 10 114 LICENSE TCL/TK; #X text 11 70 VERSION 0.28; #X text 11 34 DESCRIPTION collection of Pd object classes written by Guenter Geiger; #X restore 10 10 pd META; ggee-0.28/gui/000077500000000000000000000000001402462307700131435ustar00rootroot00000000000000ggee-0.28/gui/button-help.pd000066400000000000000000000014641402462307700157360ustar00rootroot00000000000000#N canvas 0 26 382 351 10; #X obj 41 115 button OK; #X obj 77 249 print; #X obj 118 128 button Hit_me_with_your_rhythm_stick; #X msg 118 181 yes I will; #X obj 118 83 button OK; #X text 17 21 Button \, a bang with a label (no pics yet); #X text 26 314 (C) dosmildos Guenter Geiger; #X text 17 41 button \, _ are made into spaces; #N canvas 186 148 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 115 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION button with a label that sends a bang when pressed; #X text 12 75 INLET_0 bang; #X text 12 95 OUTLET_0 bang; #X text 12 5 KEYWORDS control GUI; #X restore 332 326 pd META; #X connect 0 0 1 0; #X connect 2 0 3 0; #X connect 3 0 1 0; #X connect 4 0 2 0; ggee-0.28/gui/button.c000066400000000000000000000216261402462307700146310ustar00rootroot00000000000000#include #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #ifndef IOWIDTH #define IOWIDTH 4 #endif typedef struct _button { t_object x_obj; t_atom a_pos; t_glist * x_glist; int x_rect_width; int x_rect_height; t_symbol* x_sym; t_symbol* x_text; int x_height; int x_width; } t_button; /* widget helper functions */ #define DEBUG(x) static void draw_inlets(t_button *x, t_glist *glist, int firsttime, int nin, int nout) { int n = nin; int nplus, i; nplus = (n == 1 ? 1 : n-1); DEBUG(post("draw inlet");) for (i = 0; i < n; i++) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxo%d\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1, x, i); else sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1); } n = nout; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxi%d\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist), onset + IOWIDTH, text_ypix(&x->x_obj, glist)+5, x, i); else sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist), onset + IOWIDTH, text_ypix(&x->x_obj, glist)+5); } DEBUG(post("draw inlet end");) } static void draw_handle(t_button *x, t_glist *glist, int firsttime) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2); if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxhandle\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4, x); else sys_vgui(".x%lx.c coords %lxhandle %d %d %d %d\n", glist_getcanvas(glist), x, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4); } static void create_widget(t_button *x, t_glist *glist) { char text[MAXPDSTRING]; int len,i; t_canvas *canvas=glist_getcanvas(glist); x->x_rect_width = x->x_width+10; x->x_rect_height = x->x_height*20+12; strncpy(text,x->x_text->s_name,MAXPDSTRING); len = strlen(text); for (i=0;ix_height,text, x); } static void button_drawme(t_button *x, t_glist *glist, int firsttime) { t_canvas *canvas=glist_getcanvas(glist); DEBUG(post("drawme %d",firsttime);) if (firsttime) { DEBUG(post("glist %lx canvas %lx",x->x_glist,canvas);) // if (x->x_glist != canvas) { create_widget(x,glist); x->x_glist = canvas; // } sys_vgui(".x%lx.c create window %d %d -anchor nw -window .x%lx.c.s%lx -tags %lxS\n", canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x->x_glist,x,x); } else { sys_vgui(".x%lx.c coords %lxS \ %d %d\n", canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } draw_inlets(x, glist, firsttime, 1,1); // draw_handle(x, glist, firsttime); } static void button_erase(t_button* x,t_glist* glist) { int n; DEBUG(post("erase");) sys_vgui("destroy .x%lx.c.s%lx\n",glist_getcanvas(glist),x); sys_vgui(".x%lx.c delete %lxS\n",glist_getcanvas(glist), x); /* inlets and outlets */ sys_vgui(".x%lx.c delete %lxi%d\n",glist_getcanvas(glist),x,0); sys_vgui(".x%lx.c delete %lxo%d\n",glist_getcanvas(glist),x,0); sys_vgui(".x%lx.c delete %lxhandle\n",glist_getcanvas(glist),x,0); } /* ------------------------ button widgetbehaviour----------------------------- */ static void button_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_button* s = (t_button*)z; width = s->x_rect_width; height = s->x_rect_height; *xp1 = text_xpix(&s->x_obj, owner); *yp1 = text_ypix(&s->x_obj, owner) - 1; *xp2 = text_xpix(&s->x_obj, owner) + width; *yp2 = text_ypix(&s->x_obj, owner) + height; } static void button_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_button *x = (t_button *)z; DEBUG(post("displace");) x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; if (glist_isvisible(glist)) { sys_vgui(".x%lx.c coords %lxSEL %d %d %d %d\n", glist_getcanvas(glist), x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2); button_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } DEBUG(post("displace end");) } static void button_select(t_gobj *z, t_glist *glist, int state) { t_button *x = (t_button *)z; if (state) { sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lxSEL -outline blue\n", glist_getcanvas(glist), text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2, x); } else { sys_vgui(".x%lx.c delete %lxSEL\n", glist_getcanvas(glist), x); } } static void button_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void button_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void button_vis(t_gobj *z, t_glist *glist, int vis) { t_button* s = (t_button*)z; DEBUG(post("vis: %d",vis);) if (vis) { button_drawme(s, glist, 1); } else { button_erase(s,glist); sys_unqueuegui(z); } } static void button_save(t_gobj *z, t_binbuf *b); t_widgetbehavior button_widgetbehavior; void button_size(t_button* x,t_floatarg w,t_floatarg h) { x->x_width = w; x->x_height = h; } void button_color(t_button* x,t_symbol* col) { /* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang .. so color black does the same as bang, but doesn't forward the bang */ } static void button_bang(t_button* x) { sys_vgui(".x%lx.c.s%lx flash\n",x->x_glist,x); outlet_bang(x->x_obj.ob_outlet); } static void button_b(t_button* x) { outlet_bang(x->x_obj.ob_outlet); } static void button_save(t_gobj *z, t_binbuf *b) { t_button *x = (t_button *)z; binbuf_addv(b, "ssiiss", gensym("#X"), gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix , atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_text); binbuf_addv(b, ";"); } static t_class *button_class; static void *button_new(t_symbol* text) { t_button *x = (t_button *)pd_new(button_class); char buf[256]; x->x_glist = (t_glist*)NULL; x->x_width = 30; x->x_height = 1; if (text == &s_) x->x_text = gensym("OK"); else x->x_text = text; /* TODO .. ask the button for its width */ x->x_width += strlen(x->x_text->s_name)*5.2; sprintf(buf,"button%lx", (long unsigned int)x); x->x_sym = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_sym); /* pipe startup code to tk */ sys_vgui("proc button_cb%lx {} {pdsend {%s b}}\n", x, buf); outlet_new(&x->x_obj, &s_float); return (x); } void button_setup(void) { button_class = class_new(gensym("button"), (t_newmethod)button_new, 0, sizeof(t_button),0,A_DEFSYM,0); class_addbang(button_class, (t_method)button_bang); class_addmethod(button_class, (t_method)button_b,gensym("b"),0); button_widgetbehavior.w_getrectfn= button_getrect, button_widgetbehavior.w_displacefn= button_displace, button_widgetbehavior.w_selectfn= button_select, button_widgetbehavior.w_activatefn= button_activate, button_widgetbehavior.w_deletefn= button_delete, button_widgetbehavior.w_visfn= button_vis, #if PD_MINOR_VERSION < 37 button_widgetbehavior.w_savefn= button_save, #endif button_widgetbehavior.w_clickfn= NULL, #if PD_MINOR_VERSION < 37 button_widgetbehavior.w_propertiesfn= NULL, #endif class_setwidget(button_class,&button_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(button_class,&button_save); #endif } ggee-0.28/gui/envgen-help.pd000066400000000000000000000070521402462307700157040ustar00rootroot00000000000000#N canvas 0 26 433 454 10; #X obj 101 192 envgen 203 123 1 0 ; #X text 21 6 envgen:; #X text 22 27 Envelope generator. This external delivers value for line~ if it is banged. When numbers are sent to its input it delivers the corresponding value of the envelope; #X msg 79 135 bang; #X text 21 75 arguments; #X text 51 84 xsize ysize xmax ymax send_symbol receive_symbol ... ; #X obj 124 158 metro 2000; #X obj 124 134 tgl 15 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 1 ; #X obj 192 138 hsl 128 15 20 2000 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 0 1; #X msg 345 183 \; pd dsp 1; #N canvas 0 22 462 312 guts 0; #X obj 151 62 osc~ 250; #X obj 151 101 *~; #X obj 241 101 *~; #X obj 241 61 noise~; #X obj 177 172 *~; #X obj 133 150 line~; #X obj 188 235 dac~; #X obj 215 188 hsl 128 15 0.01 1 1 0 empty empty master_amplitude -2 -6 0 8 -262144 -1 -1 0 1; #X obj 254 11 inlet; #X obj 393 18 inlet; #X obj 157 15 inlet; #X obj 6 8 inlet; #X obj 196 207 *~ 0.6; #X connect 0 0 1 0; #X connect 1 0 4 1; #X connect 2 0 4 1; #X connect 3 0 2 0; #X connect 4 0 12 0; #X connect 5 0 4 0; #X connect 7 0 12 1; #X connect 8 0 1 1; #X connect 9 0 2 1; #X connect 10 0 0 0; #X connect 11 0 5 0; #X connect 12 0 6 1; #X connect 12 0 6 0; #X restore 168 380 pd guts; #X obj 183 353 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1; #X obj 206 353 tgl 15 1 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1; #X obj 170 329 hsl 128 15 100 1000 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 0 1; #N canvas 95 30 517 478 all 0; #X obj 43 276 envgen 203 123 1 0 ; #X msg 83 169 motion 4 4; #X msg 57 74 duration 5000; #X msg 15 14 bang; #X msg 81 127 release; #X msg 42 43 0 50 1 50; #X text 109 44 reset to default; #X text 53 15 output data; #X text 149 74 set the duration in milliseconds (ms); #X obj 165 220 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 0 1; #X msg 68 102 sustain 5000; #X obj 41 414 print ENVGEN_TIMED_OUTPUT; #X text 155 169 move selected point (values are x and y amounts in pixels); #X connect 0 0 11 0; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 3 0 0 0; #X connect 4 0 0 0; #X connect 5 0 0 0; #X connect 9 0 0 0; #X connect 10 0 0 0; #X restore 145 413 pd all messages; #X text 45 413 For more info:; #N canvas 122 39 527 491 saving 0; #X obj 73 134 envgen 203 123 1 0 ; #X msg 71 26 bang; #X msg 105 73 dump; #X obj 277 278 list prepend set; #X obj 277 299 list trim; #X msg 195 95 0 50 1 50; #X text 262 96 reset to default; #X text 115 19 a bang outputs the data on the left inlet as separate messages and times them properly to work with [line~]; #X text 126 60 outputs all of the data as a list on the right outlet ; #X text 21 427 This message box will then save the data. Click to send it back to [envgen]; #X obj 71 278 print ENVGEN_LEFT; #X msg 12 333; #X connect 0 0 10 0; #X connect 0 1 3 0; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 3 0 4 0; #X connect 4 0 11 0; #X connect 5 0 0 0; #X connect 11 0 0 0; #X restore 258 413 pd saving state; #N canvas 445 185 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI storage; #X text 12 45 DESCRIPTION envelope generator; #X text 12 65 INLET_0 bang list float duration sustain release motion dump; #X text 12 85 OUTLET_0 list; #X text 12 105 OUTLET_1 list; #X restore 382 433 pd META; #X connect 0 0 10 0; #X connect 3 0 0 0; #X connect 6 0 0 0; #X connect 7 0 6 0; #X connect 8 0 6 1; #X connect 11 0 10 2; #X connect 12 0 10 3; #X connect 13 0 10 1; ggee-0.28/gui/envgen.c000066400000000000000000000225461402462307700146020ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #define DEBUG(x) //#define DEBUG(x) x /* ------------------------ envgen ----------------------------- */ #define NONE 0 #define ATTACK 1 #define SUSTAIN -1 #define STATES 100 #include "envgen.h" #include "w_envgen.h" static t_class *envgen_class; #define OUT_LIST(x,nr,a) \ outlet_list(x->x_obj.ob_outlet,&s_list,nr,(t_atom*)&a);\ if (x->s_sym != &s_ && x->s_sym->s_thing) pd_list(x->s_sym->s_thing, &s_list, nr, (t_atom*)&a); char dumpy[2000]; /* initialize envelope with argument vector */ #include /* envgen crashes frequently when reallocating memory .... I really don't know why, it crashes during resizebytes, which means it is unable to realloc() the memory ????? the pointer seems to be ok, I don't know what else could cause the problem. for the moment we prevent from reallocating by setting the STATES variable to 100 */ void envgen_resize(t_envgen* x,int ns) { DEBUG(post("envgen_resize");); if (ns > x->args) { int newargs = ns*sizeof(t_float); x->duration = resizebytes(x->duration,x->args*sizeof(t_float),newargs); x->finalvalues = resizebytes(x->finalvalues,x->args*sizeof(t_float),newargs); x->args = ns; } } void envgen_totaldur(t_envgen* x,t_float dur) { DEBUG(post("envgen_totaldur");); int i; float f = dur/x->duration[x->last_state]; if (dur < 10) { pd_error(x, "envgen: duration too small %f",dur); return; } for (i=1;i<=x->last_state;i++) x->duration[i]*=f; } static void envgen_dump(t_envgen* e) { DEBUG(post("envgen_dump");); t_atom argv[50]; int argc= 0; t_atom* a = argv; int i; SETFLOAT(a,e->finalvalues[0]);argc++; for (i=1;i <= e->last_state;i++) { SETFLOAT(argv+argc,e->duration[i] - e->duration[i-1]); argc++; SETFLOAT(argv+argc,e->finalvalues[i]); argc++; } outlet_list(e->out2,&s_list,argc,(t_atom*)&argv); } void envgen_init(t_envgen *x,int argc,t_atom* argv) { DEBUG(post("envgen_init");); t_float* dur; t_float* val; t_float tdur = 0; if (!argc) return; x->duration[0] = 0; x->last_state = argc>>1; envgen_resize(x,argc>>1); dur = x->duration; val = x->finalvalues; if (argc) { *val = atom_getfloat(argv++); *dur = 0.0; } dur++;val++;argc--; for (;argc > 0;argc--) { tdur += atom_getfloat(argv++); DEBUG(post("dur =%f",tdur);); *dur++ = tdur; argc--; if (argc > 0) *val++ = atom_getfloat(argv++); else *val++ = 0; DEBUG(post("val =%f",*(val-1));); } } void envgen_list(t_envgen *x,t_symbol* s, int argc,t_atom* argv) { DEBUG(post("envgen_list");); envgen_init(x,argc,argv); if (glist_isvisible(x->w.glist)) { envgen_drawme(x, x->w.glist, 0); } } void envgen_setresize(t_envgen *x, t_floatarg f) { DEBUG(post("envgen_setresize");); x->resizeable = f; } void envgen_float(t_envgen *x, t_floatarg f) { DEBUG(post("envgen_float");); int state = 0; float val; while (x->duration[state] < f && state < x->last_state) state++; if (state == 0 || f >= x->duration[x->last_state]) { val = x->finalvalues[state]*(x->max-x->min); outlet_float(x->x_obj.ob_outlet,f); if (x->s_sym != &s_) pd_float(x->s_sym->s_thing, f); return; } val = x->finalvalues[state-1] + (f - x->duration[state-1])* (x->finalvalues[state] - x->finalvalues[state-1])/ (x->duration[state] - x->duration[state-1]); val *= (x->max - x->min); outlet_float(x->x_obj.ob_outlet,val); if (x->s_sym != &s_) pd_float(x->s_sym->s_thing, val); } void envgen_bang(t_envgen *x) { DEBUG(post("envgen_bang");); t_atom a[2]; SETFLOAT(a,x->finalvalues[NONE]); SETFLOAT(a+1,0); OUT_LIST(x,2,a); /* we don't force the first value anymore, so the first value is actually with what we have left off at the end ... this reduces clicks */ x->x_state = ATTACK; x->x_val = x->finalvalues[NONE]; SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min)); SETFLOAT(a+1,x->duration[x->x_state]); OUT_LIST(x,2,a); clock_delay(x->x_clock,x->duration[x->x_state]); } void envgen_release(t_envgen* x) { DEBUG(post("envgen_release");); t_atom a[2]; float del = x->duration[x->x_state] - x->duration[x->x_state-1]; if (x->x_state <= x->sustain_state) { x->x_state = x->sustain_state+1; /* skip sustain state */ clock_delay(x->x_clock,del); SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min)); SETFLOAT(a+1,del); OUT_LIST(x,2,a); } } static void envgen_sustain(t_envgen *x, t_floatarg f) { DEBUG(post("envgen_sustain");); if (f > 0 && f < x->last_state) x->sustain_state = f; else pd_error(x,"sustain value not betweem 0 and %f, ignoring message", x->last_state); } static void envgen_tick(t_envgen* x) { DEBUG(post("envgen_tick");); t_atom a[2]; x->x_state++; if (x->x_state <= x->last_state && x->x_state != x->sustain_state) { float del = x->duration[x->x_state] - x->duration[x->x_state-1]; clock_delay(x->x_clock,del); SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min)); SETFLOAT(a+1,del); OUT_LIST(x,2,a); } // else // clock_unset(x->x_clock); } static void envgen_freeze(t_envgen* x, t_floatarg f) { DEBUG(post("envgen_freeze");); x->x_freeze = f; } static void bindsym(t_pd* x,t_symbol* o,t_symbol* s) { DEBUG(post("bindsym");); if (o != &s_) pd_unbind(x,o); o = s; pd_bind(x,s); } static void envgen_free(t_envgen* x) { clock_free(x->x_clock); } static void *envgen_new(t_symbol *s,int argc,t_atom* argv) { DEBUG(post("envgen_new");); t_envgen *x = (t_envgen *)pd_new(envgen_class); x->args = STATES; x->finalvalues = getbytes( x->args*sizeof(t_float)); x->duration = getbytes( x->args*sizeof(t_float)); DEBUG(post("finalvalues %lx",x->finalvalues);); /* widget */ x->w.grabbed = 0; x->resizing = 0; x->resizeable = 1; x->w.glist = (t_glist*) canvas_getcurrent(); x->w.width = 200; if (argc) x->w.width = atom_getfloat(argv++),argc--; x->w.height = 140; if (argc) x->w.height = atom_getfloat(argv++),argc--; x->max = 1.0; if (argc) x->max = atom_getfloat(argv++),argc--; x->min = 0.0; if (argc) x->min = atom_getfloat(argv++),argc--; x->r_sym = &s_; if (argc) { t_symbol* n; n = atom_getsymbol(argv++); bindsym(&x->x_obj.ob_pd,x->r_sym,n); x->r_sym = n; argc--; } // post("recv %s",x->r_sym->s_name); x->s_sym = &s_; if (argc) x->s_sym = atom_getsymbol(argv++),argc--; // post("send %s",x->s_sym->s_name); if (argc) envgen_init(x,argc,argv); else { t_atom a[5]; SETFLOAT(a,0); SETFLOAT(a+1,50); SETFLOAT(a+2,1); SETFLOAT(a+3,50); SETFLOAT(a+4,0); envgen_init(x,5,a); } x->x_val = 0.0; x->x_state = NONE; x->sustain_state = SUSTAIN; x->x_freeze = 0; outlet_new(&x->x_obj, &s_float); x->out2 = outlet_new(&x->x_obj, &s_float); x->x_clock = clock_new(x, (t_method) envgen_tick); return (x); } void envgen_motion(t_envgen *x, t_floatarg dx, t_floatarg dy); void envgen_click(t_envgen *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt); void envgen_key(t_envgen *x, t_floatarg f); t_widgetbehavior envgen_widgetbehavior; void envgen_setup(void) { DEBUG(post("envgen_setup");); envgen_class = class_new(gensym("envgen"), (t_newmethod)envgen_new, (t_method) envgen_free, sizeof(t_envgen), 0, A_GIMME, 0); class_addfloat(envgen_class, envgen_float); class_addbang(envgen_class,envgen_bang); class_addlist(envgen_class,envgen_list); class_addmethod(envgen_class,(t_method)envgen_sustain,gensym("sustain"),A_FLOAT,A_NULL); class_addmethod(envgen_class, (t_method)envgen_motion, gensym("motion"), A_FLOAT, A_FLOAT, 0); class_addmethod(envgen_class, (t_method)envgen_key, gensym("key"), A_FLOAT, 0); class_addmethod(envgen_class,(t_method)envgen_totaldur,gensym("duration"),A_FLOAT,NULL); class_addmethod(envgen_class,(t_method)envgen_freeze,gensym("freeze"),A_FLOAT,NULL); class_addmethod(envgen_class,(t_method)envgen_setresize,gensym("resize"),A_FLOAT,A_NULL); class_addmethod(envgen_class,(t_method)envgen_release,gensym("release"),A_NULL); envgen_widgetbehavior.w_getrectfn = envgen_getrect; envgen_widgetbehavior.w_displacefn = envgen_displace; envgen_widgetbehavior.w_selectfn = envgen_select; envgen_widgetbehavior.w_activatefn = envgen_activate; envgen_widgetbehavior.w_deletefn = envgen_delete; envgen_widgetbehavior.w_visfn = envgen_vis; envgen_widgetbehavior.w_clickfn = envgen_newclick; #if PD_MINOR_VERSION < 37 envgen_widgetbehavior.w_propertiesfn = NULL; envgen_widgetbehavior.w_savefn = envgen_save; #endif class_setwidget(envgen_class,&envgen_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(envgen_class,&envgen_save); #endif class_addmethod(envgen_class,(t_method)envgen_dump,gensym("dump"),A_NULL); } ggee-0.28/gui/envgen.h000066400000000000000000000020501402462307700145730ustar00rootroot00000000000000#ifndef __GG_ENVGEN_H__ #define __GG_ENVGEN_H__ #include "g_canvas.h" typedef struct _wenvgen { t_glist* glist; int width; int height; int numdoodles; int grabbed; /* for moving points */ int shift; /* move 100th */ float pointerx; float pointery; t_clock* numclock; } t_wenvgen; typedef struct _envgen { t_object x_obj; t_float x_val; int x_state; int last_state; int sustain_state; int envchanged; t_float* finalvalues; t_float* duration; t_float totaldur; t_int args; /* get rid of that */ t_int resizing; t_int resizeable; t_symbol* r_sym; t_symbol* s_sym; t_float min; t_float max; t_clock* x_clock; t_float x_freeze; t_outlet* out2; /* widget parameters */ t_wenvgen w; } t_envgen; t_widgetbehavior envgen_widgetbehavior; void envgen_drawme(t_envgen *x, t_glist *glist, int firsttime); int envgen_set_values(t_envgen * x); void envgen_resize(t_envgen* x,int ns); #endif ggee-0.28/gui/fatom.c000066400000000000000000000004271402462307700144200ustar00rootroot00000000000000#include #include "g_canvas.h" #include "fatom.h" static t_class *fatom_class; void fatom_setup() { post("fatom setup"); fatom_class = class_new(gensym("fatom"), (t_newmethod)fatom_new, 0, sizeof(t_fatom),0,A_DEFSYM,0); fatom_setup_common(fatom_class); } ggee-0.28/gui/fatom.h000066400000000000000000000316761402462307700144370ustar00rootroot00000000000000/* ------------------------ fatom ----------------------------- */ #define x_val a_pos.a_w.w_float #define DEBUG(x) #include #include typedef struct _fatom { t_object x_obj; t_atom a_pos; /* the value of the fatom */ t_glist * x_glist; /* value of the current canvas, intialized in _new */ int x_rect_width; /* width of the widget */ int x_rect_height; /* height of the widget */ t_symbol* x_sym; /* symbol for receiving callbacks from GUI */ t_symbol* x_type; /* type of fatom (vslider, hslider, checkbutton) */ t_symbol* x_text; /* associated widget text */ int x_max; /* maximum value of a_pos (x_val) */ int x_min; /* minimum value of a_pos (x_val) */ int x_width; /* width of widget (e.g x_rect_height + 15 for hslider, x_rect_width + 15 for slider) */ t_symbol* x_color; t_symbol* x_bgcolor; } t_fatom; /* widget helper functions */ static void draw_inlets(t_fatom *x, t_glist *glist, int firsttime, int nin, int nout) { int n = nin; int nplus, i; nplus = (n == 1 ? 1 : n-1); DEBUG(post("draw inlet");) for (i = 0; i < n; i++) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxo%d\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height, x, i); else sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height); } n = nout; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxi%d\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist), onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1, x, i); else sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist), onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1); } DEBUG(post("draw inlet end");) } static void draw_handle(t_fatom *x, t_glist *glist, int firsttime) { int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2); if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxhandle\n", glist_getcanvas(glist), onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4, x); else sys_vgui(".x%lx.c coords %lxhandle %d %d %d %d\n", glist_getcanvas(glist), x, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4); } static void create_widget(t_fatom *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); post("slider create widget"); sys_vgui("destroy .x%lx.c.s%lx\n",glist_getcanvas(glist),x); if (!strcmp(x->x_type->s_name,"vslider")) { x->x_rect_width = x->x_width+15; x->x_rect_height = x->x_max-x->x_min+26; sys_vgui("scale .x%lx.c.s%lx \ -sliderlength 10 \ -showvalue 0 \ -length %d \ -resolution 0.01 \ -repeatinterval 20 \ -from %d -to %d \ -width %d \ -bg %s \ -activebackground %s \ -troughcolor %s \ -command fatom_cb%lx\n",canvas,x, x->x_max-x->x_min+14, x->x_max, x->x_min, x->x_width, x->x_color->s_name, x->x_color->s_name, x->x_bgcolor->s_name, x); } else if (!strcmp(x->x_type->s_name,"hslider")) { x->x_rect_width = x->x_max-x->x_min + 24; x->x_rect_height = x->x_width + 15; sys_vgui("scale .x%lx.c.s%lx \ -sliderlength 10 \ -showvalue 0 \ -length %d \ -resolution 0.01 \ -orient horizontal \ -repeatinterval 20 \ -from %d -to %d \ -width %d \ -bg %s \ -activebackground %s \ -troughcolor %s \ -command fatom_cb%lx\n",canvas,x, x->x_max-x->x_min+14, x->x_min, x->x_max, x->x_width, x->x_color->s_name, x->x_color->s_name, x->x_bgcolor->s_name, x); } else if (!strcmp(x->x_type->s_name,"checkbutton")) { x->x_rect_width = 32; x->x_rect_height = 28; sys_vgui("checkbutton .x%lx.c.s%lx \ -command { fatom_cb%lx $fatom_val%lx} -variable fatom_val%lx -text \"%s\" \ -bg %s \ -activebackground %s \ \n",canvas,x,x,x,x, x->x_text->s_name, x->x_color->s_name, x->x_bgcolor->s_name); } else if (!strcmp(x->x_type->s_name,"hradio")) { int i; x->x_rect_width = 8*20; x->x_rect_height = 25; for (i=0;i<8;i++) { sys_vgui("radiobutton .x%lx.c.s%lx%d \ -command { fatom_cb%lx $fatom_val%lx} -variable fatom_val%lx -value %d\n",canvas,x,i,x,x,x,i); } /* TODO pack them */ } else if (!strcmp(x->x_type->s_name,"vradio")) { int i; x->x_rect_width = 30; x->x_rect_height = 20*8+5; for (i=0;i<8;i++) { sys_vgui("radiobutton .x%lx.c.s%lx%d \ -command { fatom_cb%lx $fatom_val%lx} -variable fatom_val%lx -value %d\n",canvas,x,i,x,x,x,i); } /* TODO pack them */ } else { x->x_rect_width = 32; x->x_rect_height = 140; sys_vgui("scale .x%lx.c.s%lx \ -sliderlength 10 \ -showvalue 0 \ -length 131 \ -from 127 -to 0 \ -command fatom_cb%lx\n",canvas,x,x); } /* set the start value */ if (!strcmp(x->x_type->s_name,"checkbutton")) { if (x->x_val) sys_vgui(".x%lx.c.s%lx select\n",canvas,x,x->x_val); else sys_vgui(".x%lx.c.s%lx deselect\n",canvas,x,x->x_val); } else sys_vgui(".x%lx.c.s%lx set %f\n",canvas,x,x->x_val); } static void fatom_drawme(t_fatom *x, t_glist *glist, int firsttime) { t_canvas *canvas=glist_getcanvas(glist);// x->x_glist;//glist_getcanvas(glist); DEBUG(post("drawme %d",firsttime);) if (firsttime) { DEBUG(post("glist %lx canvas %lx",x->x_glist,canvas)); create_widget(x,glist); x->x_glist = canvas; post("create window to hold widget"); sys_vgui(".x%lx.c create window %d %d -anchor nw -window .x%lx.c.s%lx -tags %lxS\n", canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2,x->x_glist,x,x); } else { sys_vgui(".x%lx.c coords %lxS \ %d %d\n", canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2); } draw_inlets(x, glist, firsttime, 1,1); // draw_handle(x, glist, firsttime); } static void fatom_erase(t_fatom* x,t_glist* glist) { int n; DEBUG(post("erase");) sys_vgui("destroy .x%lx.c.s%lx\n",glist_getcanvas(glist),x); sys_vgui(".x%lx.c delete %lxS\n",glist_getcanvas(glist), x); /* inlets and outlets */ sys_vgui(".x%lx.c delete %lxi%d\n",glist_getcanvas(glist),x,0); sys_vgui(".x%lx.c delete %lxo%d\n",glist_getcanvas(glist),x,0); sys_vgui(".x%lx.c delete %lxhandle\n",glist_getcanvas(glist),x,0); } /* ------------------------ fatom widgetbehaviour----------------------------- */ static void fatom_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_fatom* s = (t_fatom*)z; width = s->x_rect_width; height = s->x_rect_height; *xp1 = text_xpix(&s->x_obj, owner); *yp1 = text_ypix(&s->x_obj, owner); *xp2 = text_xpix(&s->x_obj, owner) + width; *yp2 = text_ypix(&s->x_obj, owner) + height; } static void fatom_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_fatom *x = (t_fatom *)z; DEBUG(post("displace");) x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; if (glist_isvisible(glist)) { sys_vgui(".x%lx.c coords %lxSEL %d %d %d %d\n", glist_getcanvas(glist), x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height); fatom_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } DEBUG(post("displace end");) } static void fatom_select(t_gobj *z, t_glist *glist, int state) { t_fatom *x = (t_fatom *)z; if (state) { sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lxSEL -outline blue\n", glist_getcanvas(glist), text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height, x); } else { sys_vgui(".x%lx.c delete %lxSEL\n", glist_getcanvas(glist), x); } } static void fatom_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void fatom_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void fatom_vis(t_gobj *z, t_glist *glist, int vis) { t_fatom* x = (t_fatom*)z; DEBUG(post("vis: %d",vis);) if (vis) { fatom_drawme(x, glist, 1); } else { fatom_erase(x,glist); } } static void fatom_save(t_gobj *z, t_binbuf *b); t_widgetbehavior fatom_widgetbehavior; void fatom_size(t_fatom* x,t_floatarg w,t_floatarg h) { x->x_rect_width = w; x->x_rect_height = h; } void fatom_color(t_fatom* x,t_symbol* col) { /* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang .. so color black does the same as bang, but doesn't forward the bang */ } static void fatom_float(t_fatom* x,t_floatarg f) { x->x_val = f; if (glist_isvisible(x->x_glist)) { if (!strcmp(x->x_type->s_name,"checkbutton")) { if (x->x_val) sys_vgui(".x%lx.c.s%lx select\n",x->x_glist,x,f); else sys_vgui(".x%lx.c.s%lx deselect\n",x->x_glist,x,f); } else sys_vgui(".x%lx.c.s%lx set %f\n",x->x_glist,x,f); } outlet_float(x->x_obj.ob_outlet,f); } static void fatom_bang(t_fatom* x,t_floatarg f) { outlet_float(x->x_obj.ob_outlet,x->x_val); } static void fatom_f(t_fatom* x,t_floatarg f) { x->x_val = f; outlet_float(x->x_obj.ob_outlet,f); } static void fatom_properties(t_gobj *z, t_glist *owner) { post("N/I"); } static void fatom_save(t_gobj *z, t_binbuf *b) { t_fatom *x = (t_fatom *)z; binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix , gensym("fatom"),x->x_type); binbuf_addv(b, ";"); } static void *fatom_new(t_fatom* x,t_floatarg max, t_floatarg min, t_floatarg h,t_symbol* text) { char buf[256]; x->x_glist = canvas_getcurrent(); if (text != &s_) x->x_text = text; else x->x_text = gensym(""); x->a_pos.a_type = A_FLOAT; if (!max) x->x_max = 127; else x->x_max = max; x->x_min = min; if (h) x->x_width = h; else x->x_width = 15; x->x_color = gensym("grey"); x->x_bgcolor = gensym("grey"); /* bind to a symbol for slider callback (later make this based on the filepath ??) */ sprintf(buf,"fatom%lx",x); x->x_sym = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_sym); /* pipe startup code to slitk */ sys_vgui("proc fatom_cb%lx {val} {\n pdsend \"fatom%lx f $val\"\n }\n",x,x); outlet_new(&x->x_obj, &s_float); return (x); } void fatom_setup_common(t_class* class) { fatom_widgetbehavior.w_getrectfn = fatom_getrect; fatom_widgetbehavior.w_displacefn = fatom_displace; fatom_widgetbehavior.w_selectfn = fatom_select; fatom_widgetbehavior.w_activatefn = fatom_activate; fatom_widgetbehavior.w_deletefn = fatom_delete; fatom_widgetbehavior.w_visfn = fatom_vis; #if PD_MINOR_VERSION < 37 fatom_widgetbehavior.w_savefn = fatom_save; fatom_widgetbehavior.w_propertiesfn = NULL, #endif fatom_widgetbehavior.w_clickfn = NULL, class_addfloat(class, (t_method)fatom_float); class_addbang(class, (t_method)fatom_bang); class_addmethod(class, (t_method)fatom_f, gensym("f"), A_FLOAT, 0); /* class_addmethod(class, (t_method)fatom_size, gensym("size"), A_FLOAT, A_FLOAT, 0); class_addmethod(class, (t_method)fatom_color, gensym("color"), A_SYMBOL, 0); */ /* class_addmethod(class, (t_method)fatom_open, gensym("open"), A_SYMBOL, 0); */ class_setwidget(class,&fatom_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(class,&fatom_save); #endif } ggee-0.28/gui/gcanvas-help.pd000066400000000000000000000056441402462307700160510ustar00rootroot00000000000000#N canvas 0 26 524 527 10; #X obj 34 472 nbx 5 25 -1e+37 1e+37 0 0 empty empty X: -20 14 1 16 -241655 -1 -1 0 256; #X obj 40 248 gcanvas 200 200; #X obj 136 471 nbx 5 25 -1e+37 1e+37 0 0 empty empty Y: -20 14 1 16 -241655 -1 -1 0 256; #X text 18 3 [gcanvas]; #X text 69 505 mouse values; #X text 41 24 click and drag in the grey [gcanvas] to get pixel values ; #X obj 241 486 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X text 261 487 mouse clicked in box; #N canvas 0 22 441 440 resize 0; #X obj 132 192 gcanvas 49 49; #X msg 132 172 size 49 49; #X obj 37 193 vsl 20 200 200 5 0 0 empty empty Y 0 -8 1 11 -241655 -1 -1 15308 0; #X obj 135 72 hsl 200 20 5 200 0 0 empty empty X -2 -6 1 11 -241655 -1 -1 4592 0; #X obj 20 62 loadbang; #X msg 37 85 50; #N canvas 526 29 466 316 guts 0; #X obj 141 36 inlet; #X obj 184 271 outlet; #X obj 154 160 pack f f; #X obj 175 135 t b f; #X obj 154 181 t b a; #X obj 208 37 inlet; #X text 130 36 Y; #X text 253 38 X; #X obj 208 76 int; #X obj 141 78 int; #X msg 184 200 set size \$1 \$2; #X connect 0 0 9 0; #X connect 2 0 4 0; #X connect 3 0 2 0; #X connect 3 1 2 1; #X connect 4 0 1 0; #X connect 4 1 10 0; #X connect 5 0 8 0; #X connect 8 0 2 0; #X connect 9 0 3 0; #X connect 10 0 1 0; #X restore 132 118 pd guts; #X obj 246 274 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X text 266 275 mouse clicked in box; #X connect 0 2 7 0; #X connect 1 0 0 0; #X connect 2 0 6 0; #X connect 3 0 6 1; #X connect 4 0 5 0; #X connect 5 0 3 0; #X connect 5 0 2 0; #X connect 6 0 1 0; #X restore 331 343 pd resize; #X floatatom 241 466 5 0 0 0 - - -; #X msg 42 63 color grey 0; #X msg 25 44 color red 0; #X text 131 52 change color of an element; #X msg 142 211 delete 1; #X msg 53 84 line green 25 50 50 50; #X text 202 84 draw a line with args: color x y width height; #X msg 63 104 rect blue 125 150 9 50; #X text 205 104 draw a rectangle with args: color x y width height ; #X msg 76 132 move 2 50 50 50 50; #X text 195 131 move an element with args: element# x y width height ; #X text 211 211 delete an element from the canvas; #X msg 79 210 reset; #X msg 83 172 move 2 50 \$1 50 50; #X obj 86 153 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144 -1 -1 0 1; #N canvas 314 154 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI; #X text 12 45 DESCRIPTION rectangle to detect mouse position; #X text 12 65 INLET_0 color line rect move reset delete; #X text 12 85 OUTLET_0 float; #X text 12 105 OUTLET_1 float; #X text 12 125 OUTLET_2 float; #X restore 472 504 pd META; #X connect 1 0 0 0; #X connect 1 1 2 0; #X connect 1 2 9 0; #X connect 9 0 6 0; #X connect 10 0 1 0; #X connect 11 0 1 0; #X connect 13 0 1 0; #X connect 14 0 1 0; #X connect 16 0 1 0; #X connect 18 0 1 0; #X connect 21 0 1 0; #X connect 22 0 1 0; #X connect 23 0 22 0; ggee-0.28/gui/gcanvas.c000066400000000000000000000274301402462307700147370ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include "m_pd.h" #include "g_canvas.h" /* ------------------------ gcanvas ----------------------------- */ #define DEFAULTSIZE 80 static t_class *gcanvas_class; #define RECT 1 #define LINE 2 #define MAXELEM 1024 typedef struct _elem { int x; int y; int w; int h; int g; int type; char* color; } t_element; typedef struct _gcanvas { t_object x_obj; t_glist * x_glist; t_outlet* out2; t_outlet* out3; int x_width; int x_height; int x; int y; t_element* x_element[MAXELEM]; int x_numelem; } t_gcanvas; /* cv .. canvas o .. object identifier c .. element id x,y,w,h .. coordinates */ static void rectangle(void* cv,void* o,int c,int x, int y,int w,int h,char* color) { sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lx%d -fill %s\n",cv,x,y,x+w,y+h,o,c,color); } static void move_object(void* cv,void* o,int c,int x, int y,int w,int h) { sys_vgui(".x%lx.c coords %lx%d %d %d %d %d\n", cv,o,c,x,y,x+w,y+h); } static void color_object(void* cv,void* o,int c,char* color) { sys_vgui(".x%lx.c itemconfigure %lx%d -fill %s\n", cv, o, c,color); } static void delete_object(void* cv,void* o,int c) { sys_vgui(".x%lx.c delete %lx%d\n", cv, o,c); } static void line(void* cv,void* o,int c,int x,int y,int w,int h,char* color) { sys_vgui(".x%lx.c create line \ %d %d %d %d -tags %lx%d -fill %s\n",cv,x,y,x+w,y+h,o,c,color); } static void gcanvas_draw_element(t_gcanvas *x,int num) { t_element* e = x->x_element[num]; if (!e) post("gcanvas_draw_element assertion failed"); switch (e->type) { case RECT: rectangle(glist_getcanvas(x->x_glist),x,num, x->x_obj.te_xpix + e->x, x->x_obj.te_ypix + e->y, e->w, e->h,e->color); break; case LINE: line(glist_getcanvas(x->x_glist),x,num, x->x_obj.te_xpix + e->x, x->x_obj.te_ypix + e->y, e->w, e->h,e->color); break; default: post("gcanvas: unknown element"); } } static void gcanvas_move_element(t_gcanvas *x,int num) { t_element* e = x->x_element[num]; move_object( glist_getcanvas(x->x_glist),x,num, x->x_obj.te_xpix + e->x, x->x_obj.te_ypix + e->y, e->w, e->h); } static void gcanvas_delete_element(t_gcanvas *x,int num) { delete_object(glist_getcanvas(x->x_glist),x,num); } static void gcanvas_color_element(t_gcanvas* x,int num,char* color) { t_element* e = x->x_element[num]; e->color = color; color_object(glist_getcanvas(x->x_glist),x,num,color); } /* widget helper functions */ void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime) { int i; if (firsttime) { for (i=0;ix_numelem;i++) gcanvas_draw_element(x,i); } else { for (i=0;ix_numelem;i++) gcanvas_move_element(x,i); } { /* outlets */ int n = 3; int nplus, i; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxo%d\n", glist_getcanvas(glist), onset, x->x_obj.te_ypix + x->x_height - 1, onset + IOWIDTH, x->x_obj.te_ypix + x->x_height, x, i); else sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, x->x_obj.te_ypix + x->x_height - 1, onset + IOWIDTH, x->x_obj.te_ypix + x->x_height); } /* inlets */ n = 0; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxi%d\n", glist_getcanvas(glist), onset, x->x_obj.te_ypix, onset + IOWIDTH, x->x_obj.te_ypix + 1, x, i); else sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, x->x_obj.te_ypix, onset + IOWIDTH, x->x_obj.te_ypix + 1); } } } void gcanvas_erase(t_gcanvas* x,t_glist* glist) { int n,i; for (i=0;ix_numelem;i++) gcanvas_delete_element(x,i); n = 3; while (n--) { sys_vgui(".x%lx.c delete %lxo%d\n",glist_getcanvas(glist),x,n); } } /* ------------------------ gcanvas widgetbehaviour----------------------------- */ static void gcanvas_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_gcanvas* s = (t_gcanvas*)z; width = s->x_width; height = s->x_height; *xp1 = s->x_obj.te_xpix; *yp1 = s->x_obj.te_ypix; *xp2 = s->x_obj.te_xpix + width; *yp2 = s->x_obj.te_ypix + height; } static void gcanvas_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_gcanvas *x = (t_gcanvas *)z; x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; gcanvas_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } static void gcanvas_select(t_gobj *z, t_glist *glist, int state) { t_gcanvas *x = (t_gcanvas *)z; color_object(glist,x,0,state ? "blue" : x->x_element[0]->color); } static void gcanvas_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void gcanvas_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void gcanvas_vis(t_gobj *z, t_glist *glist, int vis) { t_gcanvas* x = (t_gcanvas*)z; if (vis) gcanvas_drawme(x, glist, 1); else gcanvas_erase(x,glist); } /* can we use the normal text save function ?? */ static void gcanvas_save(t_gobj *z, t_binbuf *b) { t_gcanvas *x = (t_gcanvas *)z; binbuf_addv(b, "ssiisii", gensym("#X"),gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, gensym("gcanvas"),x->x_width,x->x_height); binbuf_addv(b, ";"); } t_widgetbehavior gcanvas_widgetbehavior; static void gcanvas_motion(t_gcanvas *x, t_floatarg dx, t_floatarg dy) { x->x += dx; x->y += dy; outlet_float(x->out2,x->y); outlet_float(x->x_obj.ob_outlet,x->x); } void gcanvas_key(t_gcanvas *x, t_floatarg f) { post("key"); } static void gcanvas_click(t_gcanvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg doit,int up) { glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion, (t_glistkeyfn) NULL, xpos, ypos); x->x = xpos - x->x_obj.te_xpix; x->y = ypos - x->x_obj.te_ypix; outlet_float(x->out2,x->y); outlet_float(x->x_obj.ob_outlet,x->x); outlet_float(x->out3,0); } static int gcanvas_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { if (doit) gcanvas_click((t_gcanvas *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt,dbl); if (dbl) outlet_float(((t_gcanvas*)z)->out3,1); return (1); } void gcanvas_size(t_gcanvas* x,t_floatarg w,t_floatarg h) { x->x_width = w; x->x_height = h; gcanvas_drawme(x, x->x_glist, 0); } static void gcanvas_setwidget(void) { gcanvas_widgetbehavior.w_getrectfn = gcanvas_getrect; gcanvas_widgetbehavior.w_displacefn = gcanvas_displace; gcanvas_widgetbehavior.w_selectfn = gcanvas_select; gcanvas_widgetbehavior.w_activatefn = gcanvas_activate; gcanvas_widgetbehavior.w_deletefn = gcanvas_delete; gcanvas_widgetbehavior.w_visfn = gcanvas_vis; gcanvas_widgetbehavior.w_clickfn = gcanvas_newclick; class_setsavefn(gcanvas_class,gcanvas_save); } static void gcanvas_rect(t_gcanvas* x,t_symbol* c,float xp,float y,float w,float h) { t_element* e = getbytes(sizeof(t_element)); x->x_element[x->x_numelem++] = e; e->type = RECT; e->x = xp; e->y = y; e->w = w; e->h = h; e->color = c->s_name; gcanvas_draw_element(x,x->x_numelem-1); } static void gcanvas_line(t_gcanvas* x,t_symbol* c,float xp,float y,float w,float h) { if (x->x_numelem < MAXELEM-1) { t_element* e = getbytes(sizeof(t_element)); x->x_element[x->x_numelem++] = e; e->type = LINE; e->x = xp; e->y = y; e->w = w; e->h = h; e->g = 1; e->color = c->s_name; gcanvas_draw_element(x,x->x_numelem-1); } } static void gcanvas_move(t_gcanvas* x,float num,float xp,float y,float w,float h) { t_element* e = x->x_element[(int)num]; if (e) { e->x = xp; e->y = y; e->w = w; e->h = h; gcanvas_move_element(x,(int)num); } } static void gcanvas_color(t_gcanvas* x,t_symbol* c,float num) { gcanvas_color_element(x,(int)num,c->s_name); } void gcanvas_deletenum(t_gcanvas* x,float num) { int i = (int) num; if (x->x_element[i]) { gcanvas_delete_element(x,i); freebytes(x->x_element[i],sizeof(t_element)); x->x_element[i] = NULL; } } static void gcanvas_reset(t_gcanvas* x) { int i; for (i=1;ix_numelem;i++) gcanvas_deletenum(x,i); x->x_numelem = 1; } static void *gcanvas_new(t_symbol* s,t_int ac,t_atom* at) { int i; t_gcanvas *x = (t_gcanvas *)pd_new(gcanvas_class); x->x_glist = (t_glist*) canvas_getcurrent(); for (i=0;ix_element[i] = NULL; x->x_numelem = 0; /* Fetch the width */ x->x_width = DEFAULTSIZE; if (ac-- > 0) { if (at->a_type != A_FLOAT) error("gcanvas: wrong argument type"); else x->x_width = atom_getfloat(at++); if (x->x_width < 0 || x->x_width > 2000) { error("gcanvas: unallowed width %f",x->x_width); x->x_width = DEFAULTSIZE; } } /* Fetch the height */ x->x_height = DEFAULTSIZE; if (ac-- > 0) { if (at->a_type != A_FLOAT) error("gcanvas: wrong argument type"); else x->x_height = atom_getfloat(at++); if (x->x_height < 0 || x->x_height > 2000) { error("gcanvas: unallowed height %f",x->x_height); x->x_width = DEFAULTSIZE; } } x->x_element[0] = getbytes(sizeof(t_element)); x->x_numelem++; x->x_element[0]->type = RECT; x->x_element[0]->x = 0; x->x_element[0]->y = 0; x->x_element[0]->w = x->x_width; x->x_element[0]->h = x->x_height; x->x_element[0]->color = "white"; outlet_new(&x->x_obj, &s_float); x->out2 = outlet_new(&x->x_obj, &s_float); x->out3 = outlet_new(&x->x_obj, &s_float); return (x); } void gcanvas_setup(void) { gcanvas_class = class_new(gensym("gcanvas"), (t_newmethod)gcanvas_new, 0, sizeof(t_gcanvas),0, A_GIMME,0); class_addmethod(gcanvas_class, (t_method)gcanvas_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(gcanvas_class, (t_method)gcanvas_size, gensym("size"), A_FLOAT, A_FLOAT, 0); class_addmethod(gcanvas_class, (t_method)gcanvas_line, gensym("line"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT,A_FLOAT,0); class_addmethod(gcanvas_class, (t_method)gcanvas_rect, gensym("rect"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT,A_FLOAT,0); class_addmethod(gcanvas_class, (t_method)gcanvas_move, gensym("move"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT,A_FLOAT,0); class_addmethod(gcanvas_class, (t_method)gcanvas_color, gensym("color"), A_SYMBOL,A_FLOAT,0); class_addmethod(gcanvas_class, (t_method)gcanvas_deletenum,gensym("delete"), A_FLOAT,0); class_addmethod(gcanvas_class, (t_method)gcanvas_reset,gensym("reset"),0); gcanvas_setwidget(); class_setwidget(gcanvas_class,&gcanvas_widgetbehavior); } ggee-0.28/gui/image-help.pd000066400000000000000000000022271402462307700155030ustar00rootroot00000000000000#N canvas 0 26 462 397 10; #X obj 265 274 image logo100.gif; #X text 19 18 Incorporate images. This is instantiated with; #X text 19 34 [image logo100.gif]; #X text 17 57 [image] works with .gif \, .ppm \, and .pgm image formats only.; #X msg 86 132 open \$1; #X obj 86 88 bng 15 250 50 0 empty empty empty 0 -6 0 10 -4034 -1 -1 ; #X obj 86 109 openpanel; #X obj 265 357 bng 15 250 50 0 empty empty empty 0 -6 0 10 -262144 -1 -1; #X msg 265 152 size \$1 \$2; #X obj 265 129 pack 0 0; #X obj 313 106 hsl 128 15 0 127 0 0 empty empty y 7 7 0 10 -203904 -1 -1 0 1; #X obj 263 88 hsl 128 15 0 127 0 0 empty empty x 7 7 0 10 -204800 -1 -1 0 1; #N canvas 369 218 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI; #X text 12 45 DESCRIPTION display an image; #X text 12 65 INLET_0 open size; #X text 12 85 OUTLET_0 bang; #X restore 412 375 pd META; #X connect 0 0 7 0; #X connect 4 0 0 0; #X connect 5 0 6 0; #X connect 6 0 4 0; #X connect 8 0 0 0; #X connect 9 0 8 0; #X connect 10 0 9 1; #X connect 11 0 9 0; ggee-0.28/gui/image.c000066400000000000000000000135311402462307700143740ustar00rootroot00000000000000#include #include #include "g_canvas.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ image ----------------------------- */ static t_class *image_class; typedef struct _image { t_object x_obj; t_glist * x_glist; int x_width; int x_height; t_symbol* x_fname; } t_image; /* widget helper functions */ void image_drawme(t_image *x, t_glist *glist, int firsttime) { if (firsttime) { char fname[MAXPDSTRING]; canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name, fname, MAXPDSTRING); sys_vgui("image create photo img%lx -file {%s}\n",x,fname); sys_vgui(".x%lx.c create image %d %d -image img%lx -tags %lxS\n", glist_getcanvas(glist),text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x,x); /* TODO callback from gui sys_vgui("image_size logo"); */ } else { sys_vgui(".x%lx.c coords %lxS %d %d\n", glist_getcanvas(glist), x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } } void image_erase(t_image* x,t_glist* glist) { int n; sys_vgui(".x%lx.c delete %lxS\n", glist_getcanvas(glist), x); } static t_symbol *get_filename(t_int argc, t_atom *argv) { t_symbol *fname; fname = atom_getsymbolarg(0, argc, argv); if(argc > 1) { int i; char buf[MAXPDSTRING]; strcpy(buf, fname->s_name); for(i = 1; i < argc; i++) { strcat(buf, " "); strcat(buf, atom_getsymbolarg(i, argc, argv)->s_name); } fname = gensym(buf); } return fname; } /* ------------------------ image widgetbehaviour----------------------------- */ static void image_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_image* x = (t_image*)z; width = x->x_width; height = x->x_height; *xp1 = text_xpix(&x->x_obj, glist); *yp1 = text_ypix(&x->x_obj, glist); *xp2 = text_xpix(&x->x_obj, glist) + width; *yp2 = text_ypix(&x->x_obj, glist) + height; } static void image_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_image *x = (t_image *)z; x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; sys_vgui(".x%lx.c coords %lxSEL %d %d %d %d\n", glist_getcanvas(glist), x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height); image_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } static void image_select(t_gobj *z, t_glist *glist, int state) { t_image *x = (t_image *)z; if (state) { sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lxSEL -outline blue\n", glist_getcanvas(glist), text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, x); } else { sys_vgui(".x%lx.c delete %lxSEL\n", glist_getcanvas(glist), x); } } static void image_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void image_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void image_vis(t_gobj *z, t_glist *glist, int vis) { t_image* x = (t_image*)z; if (vis) image_drawme(x, glist, 1); else image_erase(x,glist); } /* can we use the normal text save function ?? */ static void image_save(t_gobj *z, t_binbuf *b) { t_image *x = (t_image *)z; binbuf_addv(b, "ssiiss", gensym("#X"), gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix, atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_fname); binbuf_addv(b, ";"); } t_widgetbehavior image_widgetbehavior; void image_size(t_image* x,t_floatarg w,t_floatarg h) { x->x_width = w; x->x_height = h; } void image_color(t_image* x,t_symbol* col) { /* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang .. so color black does the same as bang, but doesn't forward the bang */ } void image_open(t_image* x, t_symbol *s, t_int argc, t_atom *argv) { x->x_fname = get_filename(argc, argv); image_erase(x, x->x_glist); image_drawme(x, x->x_glist, 1); } static void image_setwidget(void) { image_widgetbehavior.w_getrectfn = image_getrect; image_widgetbehavior.w_displacefn = image_displace; image_widgetbehavior.w_selectfn = image_select; image_widgetbehavior.w_activatefn = image_activate; image_widgetbehavior.w_deletefn = image_delete; image_widgetbehavior.w_visfn = image_vis; #if (PD_VERSION_MINOR > 31) image_widgetbehavior.w_clickfn = NULL; image_widgetbehavior.w_propertiesfn = NULL; #endif #if PD_MINOR_VERSION < 37 image_widgetbehavior.w_savefn = image_save; #endif } static void *image_new(t_symbol *s, t_int argc, t_atom *argv) { t_image *x = (t_image *)pd_new(image_class); x->x_glist = (t_glist*) canvas_getcurrent(); x->x_width = 15; x->x_height = 15; x->x_fname = get_filename(argc, argv); outlet_new(&x->x_obj, &s_float); return (x); } void image_setup(void) { image_class = class_new(gensym("image"), (t_newmethod)image_new, 0, sizeof(t_image),0, A_GIMME,0); class_addmethod(image_class, (t_method)image_size, gensym("size"), A_FLOAT, A_FLOAT, 0); /* class_addmethod(image_class, (t_method)image_color, gensym("color"), A_SYMBOL, 0); */ class_addmethod(image_class, (t_method)image_open, gensym("open"), A_GIMME, 0); image_setwidget(); class_setwidget(image_class,&image_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(image_class,&image_save); #endif } ggee-0.28/gui/logo100.gif000066400000000000000000000044451402462307700150220ustar00rootroot00000000000000GIF89aDd÷ÿÿÿÿÿÿÌÿÿ™ÿÿfÿÿ3ÿÿÿÌÿÿÌÌÿÌ™ÿÌfÿÌ3ÿÌÿ™ÿÿ™Ìÿ™™ÿ™fÿ™3ÿ™ÿfÿÿfÌÿf™ÿffÿf3ÿfÿ3ÿÿ3Ìÿ3™ÿ3fÿ33ÿ3ÿÿÿÌÿ™ÿfÿ3ÿÌÿÿÌÿÌÌÿ™ÌÿfÌÿ3ÌÿÌÌÿÌÌÌÌÌ™ÌÌfÌÌ3ÌÌÌ™ÿÌ™ÌÌ™™Ì™fÌ™3Ì™ÌfÿÌfÌÌf™ÌffÌf3ÌfÌ3ÿÌ3ÌÌ3™Ì3fÌ33Ì3ÌÿÌÌÌ™ÌfÌ3Ì™ÿÿ™ÿÌ™ÿ™™ÿf™ÿ3™ÿ™Ìÿ™Ì̙̙™Ìf™Ì3™Ì™™ÿ™™Ì™™™™™f™™3™™™fÿ™fÌ™f™™ff™f3™f™3ÿ™3Ì™3™™3f™33™3™ÿ™Ì™™™f™3™fÿÿfÿÌfÿ™fÿffÿ3fÿfÌÿfÌÌfÌ™fÌffÌ3fÌf™ÿf™Ìf™™f™ff™3f™ffÿffÌff™fffff3fff3ÿf3Ìf3™f3ff33f3fÿfÌf™fff3f3ÿÿ3ÿÌ3ÿ™3ÿf3ÿ33ÿ3Ìÿ3ÌÌ3Ì™3Ìf3Ì33Ì3™ÿ3™Ì3™™3™f3™33™3fÿ3fÌ3f™3ff3f33f33ÿ33Ì33™33f333333ÿ3Ì3™3f333ÿÿÿÌÿ™ÿfÿ3ÿÌÿÌÌÌ™ÌfÌ3Ì™ÿ™Ì™™™f™3™fÿfÌf™fff3f3ÿ3Ì3™3f333ÿÌ™f3îÝ»ªˆwUD"îÝ»ªˆwUD"îÝ»ªˆwUD"îîîÝÝÝ»»»ªªªˆˆˆwwwUUUDDD""",DdÿH° Áƒ*\Ȱ¡ÀzöHt@Q†Œ92æpà°ãÀzõ$@@ÑEŒuY¹2ˆË—0c™qÀcB,[ÆÜɳ§Ï ë1qbM2~*]ªÈÆ‹s¨ÌS†@L³jݺ“#¬\Êõ‰àêØ³hƒ›¶­Ö£ÜÊ] D(€¸m™ëÈ@¼Z÷îܱƒoO¿3=²cÁÁG"(ðØpLíq]°à%ãÉ [†™ã#¬Ÿ+ïåüXðh—¥ž^¡³ËÈ‚¸~írÁÙK#Gp] Æîzõ¶µ:øÒÐ{Ô°ÝsïFœÇÃzè\)t— ŒWÿr€= Ù·nÐݧôÛ;r§?¢Ã€zOªÔsþ-A¨‰gÕé TÈ8£ ímU9pµeÙQW=¤(¨!2] eß@nõ™n1Yx€= j¨!gÕEPˆÕÆÓ¨¢ŠÎM‹Á¨•cÇñ†8:ƒÌ!;”\‰=aöbX@*YZ†E®ÂÓ¡ÁåN± 4ƒˆòt@E*ÈâN5@Ý€k’VPR5Vbö”é ’È¡¦g2òÔ¥@pÁNY¤*³)w›žÃÝVC£;17[‹aéš…(–©cNÁ˜šk5ØUA”GØ¥Šã!œÊ`—ÑÅÿ§Õz_‰x*LP‰ã*ª ãkFW[;=X+Z@¬p£ÎÀ ‚m¹”± E_̪ØE°«mõá_Öæ j¶¥å ×£ÄÊd¸g‘ƒ®Ì®ÂzA š.Lˆ¤XXîÂkç!‘)Sù²;–»ËÚ9F=2èukVNt^»9$\fõÐ+`Vʆì²Èø» I÷úÔ1wÈâHJÂú@¯X’þ––*’OÂV ®"®ŠV¶e¬@T‡U“=T2øºíüÓ׎u€ ++ˆˆ¬ÈAFÈ®ûdÕO¨ÿHÆ=º®HDÈ"äcÔª®’¬¿÷ðÇãA‡kU¨†Šgª¢=¨ÍSÁÿ‰u„‰×µ,)õÀúøÔž;`…†ûÔ·, ç}ÔJ ¹º‘ˆÐ¹¬ÐN°Þ>ó›ƒ "“»*Z±¯XßÊ̯ÄIF*à(ÃòbÏ>2 98£ØsõuìbáÐ9> >å@ à;SçÏÿÓ˜9ÃûY«ß–Ñš9Xô¡?þÝéŽC‹ÑÊ· äCzûSÑä§¹ž,Yü^øT”ƒ—¡¥gwIKäF'ÊÁÆ~J!£ƒåÎrÓ³úÎ⛂¬`:Dg% à#€h9Y©ÿ$„U c ZÐHqC¦ñ`9Â!¡¸zŒnˆay¢ç0s@8£ŠËªBÏ¢E·å!E@ ›ŠV`®´DlRS +&¢°)!̨„ˆÉ)(:k çb- Ü#A‡†dpG<äK…ÄÐ4@dÎ-ƒ„d!óAŠôÍ’‹‹ö––#a9PV×æÒ¼¶Í%‡8Ó\Œ¹­è€"0qÙ½€ð´qZ=BŽæÊ_é8åÚ-wâÔ8}ŸƒVL¤"¥`1Ej ÛmæÅ¤î|š3£…¾r©rqJ',ˆ6Mô•—¹ËÎ7µ‘˜<à.ž*WüPÿ˗Ъ=ܼ_"„È<8ñ»Ì±nS®hÒ'ÿ,Q@uc•ÓtÐ3…‰ü<ãq–æ»Wϼ9/ƒ²GQÛœáç~9N~%„é©DPMX53¥Jš4uÓÑrB¨4X„I =¦$«ÀW8™é‚@¾zxê–ø É f£¾vÖ'&#È I9¨_,ÁV_âçä$¬YÍLu*ÄV.9¥ž‰ëOþÔÄíæuå-õ¥W¾,¯}%_‹I‚•°\åBë!826-å9ìc³Ùí­d*gm¤ƒ¢G²®D#2 ˆDd˜¢ˆD$%)ÉIP¯f6² ­F <› Øö¶¸Í­n;ggee-0.28/gui/slider-help.pd000066400000000000000000000026761402462307700157130ustar00rootroot00000000000000#N canvas 0 26 592 446 12; #X obj 14 121 slider 127 0 15; #X floatatom 12 42 0 0 0 0 - - -; #X floatatom 14 319 0 0 0 0 - - -; #X text 140 188 This was instantiated with slider 200 100; #X obj 14 85 random 127; #X obj 468 343 state sl; #X msg 468 283 save; #X msg 520 283 1; #X floatatom 98 296 0 0 0 0 - - -; #X obj 186 252 slider 127 0 40; #X text 184 231 This was instantiated with slider 127 0 40; #X obj 274 333 sliderh 127 0 30; #X text 273 307 Same with sliderh; #X floatatom 274 384 5 0 0 0 - - -; #X obj 12 64 metro 2; #X obj 98 167 slider 200 100 15; #X text 125 117 Slider is state aware.; #N canvas 447 185 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI; #X text 12 45 DESCRIPTION graphical slider; #X text 12 65 INLET_0 float bang; #X text 12 85 OUTLET_0 float; #X restore 532 416 pd META; #X text 126 11 Instantiate a new slider with Put->Object and type slider into the object. The slider takes up to 3 parameters \, the first is the maximum value \, the second is the minimum. The third is the width of the slider (contributed by Dieter . Click on the trough to move in 0.01. Middle button jumps.; #X connect 0 0 2 0; #X connect 1 0 14 0; #X connect 4 0 0 0; #X connect 6 0 5 0; #X connect 7 0 5 0; #X connect 11 0 13 0; #X connect 14 0 4 0; #X connect 15 0 8 0; ggee-0.28/gui/slider.c000066400000000000000000000031031402462307700145660ustar00rootroot00000000000000#include #include #include "g_canvas.h" /* for widgetbehaviour */ #include "fatom.h" static t_class *slider_class; static void slider_save(t_gobj *z, t_binbuf *b) { t_fatom *x = (t_fatom *)z; binbuf_addv(b, "ssiisiii", gensym("#X"), gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix , atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_max,x->x_min,x->x_width); binbuf_addv(b, ";"); } static void *slider_new(t_floatarg max, t_floatarg min, t_floatarg h) { t_fatom *x = (t_fatom *)pd_new(slider_class); x->x_type = gensym("vslider"); return fatom_new(x,max,min,h,&s_); } t_widgetbehavior slider_widgetbehavior; void slider_setup() { slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0, sizeof(t_fatom),0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); slider_widgetbehavior.w_getrectfn = fatom_getrect, slider_widgetbehavior.w_displacefn = fatom_displace, slider_widgetbehavior.w_selectfn = fatom_select, slider_widgetbehavior.w_activatefn = fatom_activate, slider_widgetbehavior.w_deletefn = fatom_delete, slider_widgetbehavior.w_visfn= fatom_vis, #if PD_MINOR_VERSION < 37 slider_widgetbehavior.w_savefn = slider_save, slider_widgetbehavior.w_propertiesfn = NULL, #endif slider_widgetbehavior.w_clickfn = NULL, fatom_setup_common(slider_class); class_setwidget(slider_class,&slider_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(slider_class,&slider_save); #endif class_setpropertiesfn(slider_class,&fatom_properties); } ggee-0.28/gui/sliderh-help.pd000066400000000000000000000007611402462307700160540ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 44 79 sliderh 127 0 20; #X text 44 59 sliderh 127 0 20; #X obj 46 147 sliderh 127 0 10; #X text 43 127 sliderh 127 0 10; #N canvas 184 156 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 115 AUTHOR Guenter Geiger; #X text 12 95 OUTLET_0; #X text 12 45 DESCRIPTION; #X text 12 75 INLET_0; #X text 12 5 KEYWORDS control GUI; #X restore 394 270 pd META; ggee-0.28/gui/sliderh.c000066400000000000000000000032231402462307700147410ustar00rootroot00000000000000#include #include "g_canvas.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include "fatom.h" /* can we use the normal text save function ?? */ static t_class *sliderh_class; static void sliderh_save(t_gobj *z, t_binbuf *b) { t_fatom *x = (t_fatom *)z; binbuf_addv(b, "ssiisiii", gensym("#X"), gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix , atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_max,x->x_min,x->x_width); binbuf_addv(b, ";"); } static void *sliderh_new(t_floatarg max, t_floatarg min,t_floatarg h) { t_fatom *x = (t_fatom *)pd_new(sliderh_class); x->x_type = gensym("hslider"); return fatom_new(x,max,min,h,&s_); } t_widgetbehavior sliderh_widgetbehavior; void sliderh_setup() { sliderh_class = class_new(gensym("sliderh"), (t_newmethod)sliderh_new, 0, sizeof(t_fatom),0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); fatom_setup_common(sliderh_class); sliderh_widgetbehavior.w_getrectfn = fatom_getrect; sliderh_widgetbehavior.w_displacefn= fatom_displace; sliderh_widgetbehavior.w_selectfn= fatom_select; sliderh_widgetbehavior.w_activatefn=fatom_activate; sliderh_widgetbehavior.w_deletefn= fatom_delete; sliderh_widgetbehavior.w_visfn= fatom_vis; #if PD_MINOR_VERSION < 37 sliderh_widgetbehavior.w_savefn= sliderh_save; sliderh_widgetbehavior.w_propertiesfn= NULL; #endif sliderh_widgetbehavior.w_clickfn= NULL; class_setwidget(sliderh_class,&sliderh_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(sliderh_class,&sliderh_save); #endif } ggee-0.28/gui/state-help.pd000066400000000000000000000006611402462307700155410ustar00rootroot00000000000000#N canvas 1 88 450 300 10; #X obj 180 119 state; #X text 67 43 any idea for state saving; #N canvas 184 156 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 115 AUTHOR Guenter Geiger; #X text 12 95 OUTLET_0; #X text 12 75 INLET_0 save; #X text 12 45 DESCRIPTION; #X text 12 5 KEYWORDS control; #X restore 384 260 pd META; ggee-0.28/gui/state.c000066400000000000000000000162531402462307700144360ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* hacks .... this duplicates definitions in pd and must be * adjusted if something changes there !!!! */ #define EMPTYSYMBOL "emptysymbol" typedef struct _mygatom { t_text a_text; t_atom a_atom; } t_mygatom; /* this is not !! the real t_gatom ...*/ #define TATOM(a) (&((t_mygatom*)a)->a_atom) #define ATOMVAL(a) a->a_w.w_float /* glist's are not visible, but the only thing we need is to get the list link from them */ typedef struct _myglist { t_object gl_gobj; t_gobj* g_list; } t_myglist; #define FIRSTOBJECT(a) (((t_myglist*)a)->g_list) #ifndef vmess #define vmess pd_vmess #endif /* ------------------------ State ----------------------------- */ #include "envgen.h" static t_class *state_class; typedef struct _state { t_object x_obj; t_canvas* x_canvas; t_symbol* x_name; int x_slot; t_symbol* x_symslot; int x_save; int x_loading; t_clock* x_clock; } t_state; void state_dosave(t_state *x) { char name[255]; FILE* fp; t_text* a; t_symbol* dir; char dirstr[255]; #ifdef _WIN32 dir = gensym(""); #else dir = canvas_getdir(x->x_canvas); #endif strcpy(dirstr,dir->s_name); #ifndef _WIN32 strcat(dirstr,"/"); #endif if (x->x_symslot) sprintf(name,"%s%s.%s",dirstr,x->x_name->s_name,x->x_symslot->s_name); else sprintf(name,"%s%s.%d",dirstr,x->x_name->s_name,x->x_slot); fp = fopen(name,"w"); if (!fp) { post("state: unable to open %s",name); return; } a = (t_text*)FIRSTOBJECT(x->x_canvas); do { if (a->te_type == T_ATOM) { if (TATOM(a)->a_type == A_SYMBOL) { if (strlen(TATOM(a)->a_w.w_symbol->s_name)) fprintf(fp,"%s\n",atom_getsymbol(TATOM(a))->s_name); else fprintf(fp,EMPTYSYMBOL"\n"); } else { fprintf(fp,"%f\n",atom_getfloat(TATOM(a))); } } /* slider should be an atom as well ... how to do it ? */ if (!strcmp(class_getname(a->te_pd),"slider")) { fprintf(fp,"%f\n",atom_getfloat(TATOM(a))); } if (!strcmp(class_getname(a->te_pd),"sliderh")) { fprintf(fp,"%f\n",atom_getfloat(TATOM(a))); } if (!strcmp(class_getname(a->te_pd),"ticker")) { fprintf(fp,"%f\n",atom_getfloat(TATOM(a))); } #if 0 if (!strcmp(class_getname(a->te_pd),"vsl")) { /* float val = atom_getfloat(TATOM(a));*/ float val = *((float*) (((char*)a) + sizeof(t_iemgui) + sizeof(int))); fprintf(fp,"%f\n",val); fprintf(stderr,"vslider %f\n",val); } if (!strcmp(class_getname(a->te_pd),"hsl")) { float val = *((float*) (((char*)a) + sizeof(t_iemgui) + sizeof(int))); fprintf(fp,"%f\n",val); fprintf(stderr,"hslider %f\n",val); } #endif if (!strncmp(class_getname(a->te_pd),"envgen",6)) { int i; t_envgen* e = (t_envgen*) a; fprintf(fp,"%d ",e->last_state); fprintf(fp,"%f ",e->finalvalues[0]); for (i=1;i <= e->last_state;i++) fprintf(fp,"%f %f ",e->duration[i] - e->duration[i-1],e->finalvalues[i]); fprintf(fp,"\n"); } } while ((a = (t_text*)((t_gobj*)a)->g_next)); post("state saved to: %s",name); fclose(fp); } void state_save(t_state *x) { x->x_save = 1; clock_delay(x->x_clock,2000); } void state_saveoff(t_state *x) { x->x_save = 0; } void state_load(t_state *x) { char name[255]; FILE* fp; t_text* a; t_float in; t_symbol* dir; char dirstr[255]; #ifdef _WIN32 dir = gensym(""); #else dir = canvas_getdir(x->x_canvas); #endif strcpy(dirstr,dir->s_name); #ifndef _WIN32 strcat(dirstr,"/"); #endif if (x->x_symslot) sprintf(name,"%s%s.%s",dirstr,x->x_name->s_name,x->x_symslot->s_name); else sprintf(name,"%s%s.%d",dirstr,x->x_name->s_name,x->x_slot); fp = fopen(name,"r"); if (!fp) { post("state: unable to open %s",name); return; } a = (t_text*) FIRSTOBJECT(x->x_canvas); x->x_loading = 1; post("state loading from: %s",name); *name = 0; do { if (a->te_type == T_ATOM || !strcmp(class_getname(a->te_pd),"slider") || !strcmp(class_getname(a->te_pd),"ticker") || !strcmp(class_getname(a->te_pd),"sliderh") /* || !strcmp(class_getname(a->te_pd),"vsl") || !strcmp(class_getname(a->te_pd),"hsl" ) */ ) { if (TATOM(a)->a_type == A_SYMBOL) { if (fscanf(fp,"%s",name)<=0) continue; if (strcmp(name,EMPTYSYMBOL)) vmess((t_pd*)a,gensym("set"),"s",gensym(name)); } else { if (fscanf(fp,"%f",&in)<=0) continue; vmess((t_pd*)a,&s_float,"f",in); } } if (!strncmp(class_getname(a->te_pd),"envgen",6)) { int i; int end; float val; float dur; t_atom ilist[255]; fscanf(fp,"%f",&in); end = in; if (fscanf(fp,"%f",&val)<=0) continue; SETFLOAT(ilist,val); for (i=1 ;i <= end;i++) { fscanf(fp,"%f",&dur); fscanf(fp,"%f",&val); SETFLOAT(ilist +2*i-1,dur); SETFLOAT(ilist+2*i,val); } pd_typedmess((t_pd*)a,&s_list,2*end+1,ilist); // post("ok %d",end); } } while ((a = (t_text*)((t_gobj*)a)->g_next) && !feof(fp)); x->x_loading = 0; fclose(fp); } void state_float(t_state *x,t_floatarg f) { if (x->x_loading) return; x->x_symslot = NULL; x->x_slot = f; if (x->x_save) { x->x_save = 0; state_dosave(x); return; } state_load(x); outlet_float(x->x_obj.ob_outlet,x->x_slot); } void state_anything(t_state *x,t_symbol* s,t_int argc,t_atom* argv) { x->x_symslot = s; if (x->x_save) { x->x_save = 0; state_dosave(x); return; } state_load(x); outlet_symbol(x->x_obj.ob_outlet,x->x_symslot); } void state_symbol(t_state *x,t_symbol* s) { x->x_symslot = s; if (x->x_save) { x->x_save = 0; state_dosave(x); return; } state_load(x); outlet_symbol(x->x_obj.ob_outlet,x->x_symslot); } void state_bang(t_state *x) { if (x->x_symslot) outlet_symbol(x->x_obj.ob_outlet,x->x_symslot); else outlet_float(x->x_obj.ob_outlet,x->x_slot); } static void *state_new(t_symbol* name) { t_state *x = (t_state *)pd_new(state_class); x->x_canvas = canvas_getcurrent(); if (name != &s_) x->x_name = name; else x->x_name = gensym("state"); x->x_clock = clock_new(x, (t_method)state_saveoff); x->x_slot = 0; x->x_symslot = NULL; x->x_loading = 0; x->x_save = 0; outlet_new(&x->x_obj, &s_float); return (x); } void state_setup(void) { state_class = class_new(gensym("state"), (t_newmethod)state_new, 0, sizeof(t_state), 0,A_DEFSYM,0); class_addfloat(state_class,state_float); class_addmethod(state_class,(t_method) state_save, gensym("save"), 0); class_addanything(state_class,(t_method) state_anything); class_addbang(state_class,state_bang); class_addsymbol(state_class,state_symbol); /* class_addmethod(state_class, (t_method)state_load, gensym("load"), 0);*/ } ggee-0.28/gui/state.list000066400000000000000000000000231402462307700151530ustar00rootroot0000000000000066.000000 0.000000 ggee-0.28/gui/ticker-help.pd000066400000000000000000000017761402462307700157120ustar00rootroot00000000000000#N canvas 0 22 489 266 10; #X obj 76 108 ticker ; #X text 25 21 [ticker] is a OS-native checkbox; #X obj 44 70 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X msg 75 69 bang; #X floatatom 75 157 5 0 0 0 - - -; #X obj 44 158 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #N canvas 188 140 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI; #X text 12 45 DESCRIPTION OS-native checkbox; #X text 12 65 INLET_0 bang float; #X text 12 85 OUTLET_0 float; #X restore 431 238 pd META; #X text 186 66 A single symbol argument sets the label; #X text 208 88 [ticker my_label] will create:; #X obj 249 119 ticker my_label; #X text 49 195 Note: moving the object is a little awkward-- try creating a bounding box around the object first \, then click and drag.; #X connect 0 0 4 0; #X connect 0 0 5 0; #X connect 2 0 0 0; #X connect 3 0 0 0; ggee-0.28/gui/ticker.c000066400000000000000000000034241402462307700145730ustar00rootroot00000000000000#include #include "g_canvas.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include "fatom.h" /* can we use the normal text save function ?? */ static t_class *ticker_class; static void ticker_save(t_gobj *z, t_binbuf *b) { t_fatom *x = (t_fatom *)z; binbuf_addv(b, "ssiiss", gensym("#X"), gensym("obj"), x->x_obj.te_xpix, x->x_obj.te_ypix , atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_text,x->x_max,x->x_width); binbuf_addv(b, ";"); } static void ticker_bang(t_fatom* x) { x->x_val = !x->x_val; fatom_float(x,x->x_val); } static void *ticker_new(t_symbol* t) { t_fatom *x = (t_fatom *)pd_new(ticker_class); x->x_type = gensym("checkbutton"); return fatom_new(x,10,0,0,t); } t_widgetbehavior ticker_widgetbehavior; void ticker_setup() { ticker_class = class_new(gensym("ticker"), (t_newmethod)ticker_new, 0, sizeof(t_fatom),0,A_DEFSYMBOL,0); class_addbang(ticker_class,ticker_bang); fatom_setup_common(ticker_class); class_addbang(ticker_class, (t_method)ticker_bang); ticker_widgetbehavior.w_getrectfn= fatom_getrect; ticker_widgetbehavior.w_displacefn= fatom_displace; ticker_widgetbehavior.w_selectfn= fatom_select; ticker_widgetbehavior.w_activatefn= fatom_activate; ticker_widgetbehavior.w_deletefn= fatom_delete; ticker_widgetbehavior.w_visfn= fatom_vis; #if PD_MINOR_VERSION < 37 ticker_widgetbehavior.w_savefn= ticker_save; ticker_widgetbehavior.w_propertiesfn= NULL; #endif ticker_widgetbehavior.w_clickfn= NULL; class_setwidget(ticker_class,&ticker_widgetbehavior); #if PD_MINOR_VERSION >= 37 class_setsavefn(ticker_class,&ticker_save); #endif } ggee-0.28/gui/toddle-help.pd000066400000000000000000000034661402462307700157020ustar00rootroot00000000000000#N canvas 0 26 631 491 12; #X obj 21 258 toddle blue 50 50; #X obj 254 397 toddle magenta 62 67; #X obj 21 315 print; #X msg 21 232 bang; #X msg 254 251 size 15 15; #X obj 22 57 toddle black 15 15; #X text 333 250 set the size; #X text 42 54 default toddle; #X obj 22 92 toddle black 40 40; #X text 72 105 toddle black 40 40; #X obj 22 149 toddle red 15 15; #X text 46 148 toddle red; #X obj 22 180 toddle green 10 40; #X text 43 193 toddle green 10 40; #X text 19 460 (C) 1999 Guenter Geiger; #X text 232 9 The Toddle object; #X text 232 24 ==================; #X msg 460 248 size \$1 \$2; #X floatatom 460 206 0 0 0 0 - - -; #X obj 460 227 pack 1 2; #X floatatom 511 206 0 0 0 0 - - -; #X msg 460 183 bang; #X text 254 155 wow .....; #X msg 460 285 color magenta \, bang; #X msg 459 306 color red \, bang; #X msg 459 328 color slategrey \, bang; #X msg 460 350 color darkgreen \, bang; #X text 199 52 To create: Put->Object and type in the "toddle"; #X floatatom 75 231 0 0 0 0 - - -; #X text 75 263 toddle is not a "bang"; #X text 75 278 converter \, but routes; #X text 76 294 messages through; #N canvas 324 237 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS control GUI; #X text 12 45 DESCRIPTION graphical button; #X text 12 65 INLET_0 anything size color; #X text 12 85 OUTLET_0 anything; #X restore 572 466 pd META; #X connect 0 0 2 0; #X connect 3 0 0 0; #X connect 4 0 1 0; #X connect 5 0 8 0; #X connect 8 0 10 0; #X connect 10 0 12 0; #X connect 17 0 1 0; #X connect 18 0 19 0; #X connect 19 0 17 0; #X connect 20 0 19 1; #X connect 20 0 21 0; #X connect 21 0 18 0; #X connect 23 0 1 0; #X connect 24 0 1 0; #X connect 25 0 1 0; #X connect 26 0 1 0; #X connect 28 0 0 0; ggee-0.28/gui/toddle.c000066400000000000000000000230621402462307700145650ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include "g_canvas.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #define PD_VERSION_MINOR 32 #define BACKGROUND "-fill grey" #define BACKGROUNDCOLOR "grey" #define te_xpos te_xpix #define te_ypos te_ypix /* ------------------------ toddle ----------------------------- */ #define DEFAULTSIZE 15 #define DEFAULTCOLOR "black" static t_class *toddle_class; typedef struct _toddle { t_object x_obj; t_glist * x_glist; int x_width; int x_height; t_symbol* x_color; t_clock* x_clock; } t_toddle; /* widget helper functions */ void toddle_drawbang(t_toddle *x,t_glist *glist,int on) { if (glist_isvisible(glist)) { if (on) sys_vgui(".x%lx.c create oval %d %d %d %d -fill %s -tags %lxB\n",glist_getcanvas(glist), x->x_obj.te_xpos+1,x->x_obj.te_ypos+1, x->x_obj.te_xpos + x->x_width -1, x->x_obj.te_ypos + x->x_height -1,x->x_color->s_name,x); else sys_vgui(".x%lx.c delete %lxB\n", glist_getcanvas(glist), x); } } void toddle_drawme(t_toddle *x, t_glist *glist, int firsttime) { if (firsttime) { #if 0 sys_vgui(".x%lx.c create line \ %d %d %d %d %d %d %d %d %d %d -tags %lxS\n", glist_getcanvas(glist), x->x_obj.te_xpos, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height, x->x_obj.te_xpos, x->x_obj.te_ypos + x->x_height, x->x_obj.te_xpos, x->x_obj.te_ypos, x); #endif sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lxS "BACKGROUND"\n", glist_getcanvas(glist), x->x_obj.te_xpos, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height, x); sys_vgui(".x%lx.c create oval \ %d %d %d %d -tags %lxP\n",glist_getcanvas(glist), x->x_obj.te_xpos+1,x->x_obj.te_ypos+1, x->x_obj.te_xpos + x->x_width -1, x->x_obj.te_ypos + x->x_height -1,x); } else { #if 0 sys_vgui(".x%lx.c coords %lxS \ %d %d %d %d %d %d %d %d %d %d\n", glist_getcanvas(glist), x, x->x_obj.te_xpos, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height, x->x_obj.te_xpos, x->x_obj.te_ypos + x->x_height, x->x_obj.te_xpos, x->x_obj.te_ypos); #endif sys_vgui(".x%lx.c coords %lxS \ %d %d %d %d\n", glist_getcanvas(glist), x, x->x_obj.te_xpos, x->x_obj.te_ypos, x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height); sys_vgui(".x%lx.c coords %lxP \ %d %d %d %d\n",glist_getcanvas(glist),x, x->x_obj.te_xpos+1,x->x_obj.te_ypos+1, x->x_obj.te_xpos + x->x_width-1, x->x_obj.te_ypos + x->x_height-1); } { int n = 1; int nplus, i; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = x->x_obj.te_xpos + (x->x_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxo%d\n", glist_getcanvas(glist), onset, x->x_obj.te_ypos + x->x_height - 1, onset + IOWIDTH, x->x_obj.te_ypos + x->x_height, x, i); else sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, x->x_obj.te_ypos + x->x_height - 1, onset + IOWIDTH, x->x_obj.te_ypos + x->x_height); } n = 1; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = x->x_obj.te_xpos + (x->x_width - IOWIDTH) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxi%d\n", glist_getcanvas(glist), onset, x->x_obj.te_ypos, onset + IOWIDTH, x->x_obj.te_ypos + 1, x, i); else sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, x->x_obj.te_ypos, onset + IOWIDTH, x->x_obj.te_ypos + 1); } } } void toddle_erase(t_toddle* x,t_glist* glist) { int n; sys_vgui(".x%lx.c delete %lxS\n", glist_getcanvas(glist), x); sys_vgui(".x%lx.c delete %lxP\n", glist_getcanvas(glist), x); n = 1; while (n--) { sys_vgui(".x%lx.c delete %lxi%d\n",glist_getcanvas(glist),x,n); sys_vgui(".x%lx.c delete %lxo%d\n",glist_getcanvas(glist),x,n); } } /* ------------------------ toddle widgetbehaviour----------------------------- */ static void toddle_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_toddle* s = (t_toddle*)z; width = s->x_width; height = s->x_height; *xp1 = s->x_obj.te_xpos; *yp1 = s->x_obj.te_ypos; *xp2 = s->x_obj.te_xpos + width; *yp2 = s->x_obj.te_ypos + height; } static void toddle_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_toddle *x = (t_toddle *)z; x->x_obj.te_xpos += dx; x->x_obj.te_ypos += dy; toddle_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } static void toddle_select(t_gobj *z, t_glist *glist, int state) { t_toddle *x = (t_toddle *)z; sys_vgui(".x%lx.c itemconfigure %lxS -fill %s\n", glist, x, (state? "blue" : BACKGROUNDCOLOR)); } static void toddle_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void toddle_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void toddle_vis(t_gobj *z, t_glist *glist, int vis) { t_toddle* x = (t_toddle*)z; if (vis) toddle_drawme(x, glist, 1); else toddle_erase(x,glist); } /* can we use the normal text save function ?? */ static void toddle_save(t_gobj *z, t_binbuf *b) { t_toddle *x = (t_toddle *)z; binbuf_addv(b, "ssiissii", gensym("#X"), gensym("obj"), (t_int)x->x_obj.te_xpos, (t_int)x->x_obj.te_ypos, atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->x_color,x->x_width,x->x_height); binbuf_addv(b, ";"); } t_widgetbehavior toddle_widgetbehavior; void toddle_bang(t_toddle *x) { toddle_drawbang(x,x->x_glist,1); outlet_bang(x->x_obj.ob_outlet); clock_delay(x->x_clock, 100); } static void toddle_click(t_toddle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { toddle_bang(x); } #if (PD_VERSION_MINOR > 31) static int toddle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { if (doit) toddle_click((t_toddle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); return (1); } #endif void toddle_float(t_toddle *x,t_floatarg f) { toddle_drawbang(x,x->x_glist,1); clock_delay(x->x_clock, 100); outlet_float(x->x_obj.ob_outlet,f); } void toddle_on(t_toddle* x) { toddle_drawbang(x,x->x_glist,1); } void toddle_off(t_toddle* x) { toddle_drawbang(x,x->x_glist,0); } void toddle_tick(t_toddle* x) { toddle_drawbang(x,x->x_glist,0); clock_unset(x->x_clock); } void toddle_size(t_toddle* x,t_floatarg w,t_floatarg h) { x->x_width = w; x->x_height = h; toddle_drawme(x, x->x_glist, 0); } void toddle_color(t_toddle* x,t_symbol* col) { x->x_color = col; toddle_drawbang(x,x->x_glist,1); clock_delay(x->x_clock, 100); /* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang .. so color black does the same as bang, but doesn't forward the bang */ } static void toddle_setwidget(void) { toddle_widgetbehavior.w_getrectfn = toddle_getrect; toddle_widgetbehavior.w_displacefn = toddle_displace; toddle_widgetbehavior.w_selectfn = toddle_select; toddle_widgetbehavior.w_activatefn = toddle_activate; toddle_widgetbehavior.w_deletefn = toddle_delete; toddle_widgetbehavior.w_visfn = toddle_vis; toddle_widgetbehavior.w_clickfn = toddle_newclick; #if (PD_MINOR_VERSION < 37) toddle_widgetbehavior.w_propertiesfn = NULL; toddle_widgetbehavior.w_savefn = toddle_save; #endif #if PD_MINOR_VERSION >= 37 class_setsavefn(toddle_class,&toddle_save); #endif } static void *toddle_new(t_symbol* col,t_floatarg h,t_floatarg o) { t_toddle *x = (t_toddle *)pd_new(toddle_class); x->x_glist = (t_glist*) canvas_getcurrent(); if (h) x->x_width = h; else x->x_width = DEFAULTSIZE; if (o) x->x_height = o; else x->x_height = DEFAULTSIZE; if (col != &s_) x->x_color = col; else x->x_color = gensym(DEFAULTCOLOR); x->x_clock = clock_new(x, (t_method)toddle_tick); outlet_new(&x->x_obj, &s_float); return (x); } void toddle_setup(void) { toddle_class = class_new(gensym("toddle"), (t_newmethod)toddle_new, 0, sizeof(t_toddle),0, A_DEFSYM,A_DEFFLOAT,A_DEFFLOAT,0); class_addcreator((t_newmethod)toddle_new,gensym("bng"),A_DEFSYM,A_DEFFLOAT,A_DEFFLOAT,A_GIMME,0); class_addbang(toddle_class,toddle_bang); class_addfloat(toddle_class,toddle_float); class_addmethod(toddle_class, (t_method)toddle_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(toddle_class, (t_method)toddle_size, gensym("size"), A_FLOAT, A_FLOAT, 0); class_addmethod(toddle_class, (t_method)toddle_color, gensym("color"), A_SYMBOL, 0); class_addmethod(toddle_class, (t_method)toddle_on, gensym("on"), 0); class_addmethod(toddle_class, (t_method)toddle_off, gensym("off"), 0); toddle_setwidget(); class_setwidget(toddle_class,&toddle_widgetbehavior); } ggee-0.28/gui/w_envgen.h000066400000000000000000000277541402462307700151430ustar00rootroot00000000000000#include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #ifdef _WIN32 #define abs fabs #endif #define BACKGROUNDCOLOR "grey" #define BORDER 2 static void draw_inlets(t_envgen *x, t_glist *glist, int firsttime, int nin, int nout) { int n = nout; int nplus, i; int xpos = text_xpix(&x->x_obj,glist); int ypos = text_ypix(&x->x_obj,glist); nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = xpos + (x->w.width-2*BORDER) * i / nplus; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxo%d\n", glist_getcanvas(glist), onset, ypos + x->w.height - 1 + 2*BORDER, onset + IOWIDTH, ypos + x->w.height + 2*BORDER, x, i); else sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, ypos + x->w.height - 1 + 2*BORDER, onset + IOWIDTH, ypos + x->w.height + 2*BORDER); } n = nin; nplus = (n == 1 ? 1 : n-1); for (i = 0; i < n; i++) { int onset = xpos + (x->w.width - IOWIDTH) * i / nplus - BORDER; if (firsttime) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxi%d\n", glist_getcanvas(glist), onset, ypos - BORDER, onset + IOWIDTH, ypos + 1 - BORDER, x, i); else sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n", glist_getcanvas(glist), x, i, onset, ypos - BORDER, onset + IOWIDTH, ypos + 1 - BORDER); } } static int envgen_next_doodle(t_envgen *x, struct _glist *glist, int xpos,int ypos) { int ret = -1; float xscale,yscale; int dxpos,dypos; float minval = 100000.0; float tval; int i; int insertpos = -1; if (xpos > text_xpix(&x->x_obj,glist) + x->w.width) xpos = text_xpix(&x->x_obj,glist) + x->w.width; xscale = x->w.width/x->duration[x->last_state]; yscale = x->w.height; dxpos = text_xpix(&x->x_obj,glist);/* + BORDER */; dypos = text_ypix(&x->x_obj,glist) + BORDER; for (i=0;i<=x->last_state;i++) { float dx2 = (dxpos + (x->duration[i] * xscale)) - xpos; float dy2 = (dypos + yscale - (x->finalvalues[i] * yscale)) - ypos; dx2*=dx2; dy2*=dy2; tval = sqrt(dx2+dy2); if (tval <= minval) { minval = tval; insertpos = i; } } /* decide if we want to make a new one */ if (minval > /*5*/ 8 && insertpos >= 0 && !x->x_freeze) { while (((dxpos + (x->duration[insertpos] * xscale)) - xpos) < 0) insertpos++; while (((dxpos + (x->duration[insertpos-1] * xscale)) - xpos) > 0) insertpos--; if (x->last_state+1 >= x->args) envgen_resize(x,x->args+1); for (i=x->last_state;i>=insertpos;i--) { x->duration[i+1] = x->duration[i]; x->finalvalues[i+1] = x->finalvalues[i]; } x->duration[insertpos] = (float)(xpos-dxpos)/x->w.width*x->duration[x->last_state++]; x->w.pointerx = xpos; x->w.pointery = ypos; } else { x->w.pointerx = text_xpix(&x->x_obj,glist) + x->duration[insertpos]*x->w.width/x->duration[x->last_state]; x->w.pointery = text_ypix(&x->x_obj,glist) + (1.f - x->finalvalues[insertpos])*x->w.height; } x->w.grabbed = insertpos; return insertpos; } static void envgen_create_doodles(t_envgen *x, t_glist *glist) { float xscale,yscale; int xpos,ypos; int i; char guistr[255]; xscale = x->w.width/x->duration[x->last_state]; yscale = x->w.height; xpos = text_xpix(&x->x_obj,glist); ypos = (int) (text_ypix(&x->x_obj,glist) + x->w.height); for (i=0;i<=x->last_state;i++) { sprintf(guistr,".x%lx.c create oval %d %d %d %d -tags %lxD%d",(long unsigned int)glist_getcanvas(glist), (int) (xpos+(x->duration[i] * xscale) - 2), (int) (ypos - x->finalvalues[i]*yscale - 2), (int) (xpos+(x->duration[i] * xscale)+2), (int) (ypos - x->finalvalues[i]*yscale + 2), (long unsigned int)x,i); if (i == x->w.grabbed) strcat(guistr," -fill red\n"); else strcat(guistr,"\n"); sys_vgui("%s",guistr); } x->w.numdoodles = i; } static void envgen_delete_doodles(t_envgen *x, t_glist *glist) { int i; for (i=0;i<=x->w.numdoodles;i++) { sys_vgui(".x%lx.c delete %lxD%d\n",glist_getcanvas(glist),x,i); } } static void envgen_update_doodles(t_envgen *x, t_glist *glist) { envgen_delete_doodles(x,glist); /* LATER only create new doodles if necessary */ envgen_create_doodles(x, glist); } static void envgen_delnum(t_envgen *x) { sys_vgui(".x%lx.c delete %lxT\n",glist_getcanvas(x->w.glist),x); } static void envgen_shownum(t_envgen *x,t_glist* glist) { float xscale,yscale; int xpos,ypos; int i= x->w.grabbed; xscale = x->w.width/x->duration[x->last_state]; yscale = x->w.height; xpos = text_xpix(&x->x_obj,glist); ypos = (int) (text_ypix(&x->x_obj,glist) + x->w.height); envgen_delnum(x); sys_vgui(".x%lx.c create text %d %d -text %fx%f -tags %lxT\n", (long unsigned int)glist_getcanvas(x->w.glist), (int) (xpos+(x->duration[i] * xscale) + 12), (int) (ypos - x->finalvalues[i]*yscale - 2), x->finalvalues[i]*(x->max-x->min), x->duration[i], (long unsigned int)x); clock_delay(x->w.numclock,700); } static void envgen_create(t_envgen *x, t_glist *glist) { int i; static char buf[1024]; float xscale,yscale; int xpos,ypos; char num[40]; xpos = text_xpix(&x->x_obj,glist); ypos = (int) text_ypix(&x->x_obj,glist); x->w.numclock = clock_new(x, (t_method) envgen_delnum); sys_vgui(".x%lx.c create rectangle \ %d %d %d %d -tags %lxS -fill "BACKGROUNDCOLOR"\n", glist_getcanvas(glist), xpos-BORDER, ypos-BORDER, xpos + x->w.width+2*BORDER, ypos + x->w.height+2*BORDER, x); xscale = x->w.width/x->duration[x->last_state]; yscale = x->w.height; sprintf(buf,".x%lx.c create line",(long unsigned int)glist_getcanvas(glist)); for (i=0;i<=x->last_state;i++) { sprintf(num," %d %d ",(int)(xpos + x->duration[i]*xscale), (int)(ypos + x->w.height- x->finalvalues[i]*yscale)); strcat(buf,num); } sprintf(num,"-tags %pP\n",x); strcat(buf,num); sys_vgui("%s",buf); envgen_create_doodles(x,glist); } static void envgen_update(t_envgen *x, t_glist *glist) { int i; static char buf[1024]; float xscale,yscale; char num[40]; int xpos = text_xpix(&x->x_obj,glist); int ypos = text_ypix(&x->x_obj,glist); sys_vgui(".x%lx.c coords %lxS \ %d %d %d %d\n", glist_getcanvas(glist), x, xpos - BORDER, ypos -BORDER, xpos + x->w.width+2*BORDER, ypos + x->w.height+2*BORDER); xscale = x->w.width/x->duration[x->last_state]; yscale = x->w.height; sprintf(buf,".x%lx.c coords %pP",(long unsigned int)glist_getcanvas(glist),x); for (i=0;i<=x->last_state;i++) { sprintf(num," %d %d ",(int)(xpos + x->duration[i]*xscale), (int) (ypos + x->w.height - x->finalvalues[i]*yscale)); strcat(buf,num); } strcat(buf,"\n"); sys_vgui("%s",buf); envgen_update_doodles(x,glist); draw_inlets(x, glist, 0,1,2); } void envgen_drawme(t_envgen *x, t_glist *glist, int firsttime) { if (firsttime) envgen_create(x,glist); else envgen_update(x,glist); draw_inlets(x, glist, firsttime, 1,2); } void envgen_erase(t_envgen* x,t_glist* glist) { int n; sys_vgui(".x%lx.c delete %lxS\n", glist_getcanvas(glist), x); sys_vgui(".x%lx.c delete %pP\n", glist_getcanvas(glist), x); sys_vgui(".x%lx.c delete %lxi0\n",glist_getcanvas(glist),x); sys_vgui(".x%lx.c delete %lxo0\n",glist_getcanvas(glist),x); sys_vgui(".x%lx.c delete %lxo1\n",glist_getcanvas(glist),x); envgen_delete_doodles(x,glist); } /* ------------------------ envgen widgetbehaviour----------------------------- */ static void envgen_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) { int width, height; t_envgen* s = (t_envgen*)z; width = s->w.width + 2*BORDER; height = s->w.height + 2*BORDER; *xp1 = text_xpix(&s->x_obj,owner)-BORDER; *yp1 = text_ypix(&s->x_obj,owner)-BORDER; *xp2 = text_xpix(&s->x_obj,owner) + width + 4; *yp2 = text_ypix(&s->x_obj,owner) + height + 4; } static void envgen_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_envgen *x = (t_envgen *)z; x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; envgen_drawme(x, glist, 0); canvas_fixlinesfor(glist,(t_text*) x); } static void envgen_select(t_gobj *z, t_glist *glist, int state) { t_envgen *x = (t_envgen *)z; sys_vgui(".x%lx.c itemconfigure %lxS -fill %s\n", glist, x, (state? "blue" : BACKGROUNDCOLOR)); } static void envgen_activate(t_gobj *z, t_glist *glist, int state) { /* t_text *x = (t_text *)z; t_rtext *y = glist_findrtext(glist, x); if (z->g_pd != gatom_class) rtext_activate(y, state);*/ } static void envgen_delete(t_gobj *z, t_glist *glist) { t_text *x = (t_text *)z; canvas_deletelinesfor(glist, x); } static void envgen_vis(t_gobj *z, t_glist *glist, int vis) { t_envgen* s = (t_envgen*)z; if (vis) envgen_drawme(s, glist, 1); else envgen_erase(s,glist); } /* can we use the normal text save function ?? */ static void envgen_save(t_gobj *z, t_binbuf *b) { t_envgen *x = (t_envgen *)z; binbuf_addv(b, "ssiisiiffss", gensym("#X"), gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), x->w.width,x->w.height,x->max,x->min,x->r_sym,x->s_sym); binbuf_addv(b, ";"); } static void envgen_followpointer(t_envgen* x,t_glist* glist) { float dur; float xscale = x->duration[x->last_state]/x->w.width; if ((x->w.grabbed > 0) && (x->w.grabbed < x->last_state)) { dur = (x->w.pointerx - text_xpix(&x->x_obj,glist))*xscale; if (dur < x->duration[x->w.grabbed-1]) dur = x->duration[x->w.grabbed-1]; if (dur > x->duration[x->w.grabbed+1]) dur = x->duration[x->w.grabbed+1]; x->duration[x->w.grabbed] = dur; } x->finalvalues[x->w.grabbed] = 1.0f - (x->w.pointery - (float)text_ypix(&x->x_obj,glist))/(float)x->w.height; if (x->finalvalues[x->w.grabbed] < 0.0) x->finalvalues[x->w.grabbed]= 0.0; else if (x->finalvalues[x->w.grabbed] > 1.0) x->finalvalues[x->w.grabbed]= 1.0; } void envgen_motion(t_envgen *x, t_floatarg dx, t_floatarg dy) { if (x->w.shift) { x->w.pointerx+=dx/1000.f; x->w.pointery+=dy/1000.f; } else { x->w.pointerx+=dx; x->w.pointery+=dy; } if (!x->resizing) envgen_followpointer(x,x->w.glist); else { x->w.width+=dx; x->w.height+=dy; } envgen_shownum(x,x->w.glist); envgen_update(x,x->w.glist); } void envgen_key(t_envgen *x, t_floatarg f) { if (f == 8.0 && x->w.grabbed < x->last_state && x->w.grabbed > 0) { int i; for (i=x->w.grabbed;i<=x->last_state;i++) { x->duration[i] = x->duration[i+1]; x->finalvalues[i] = x->finalvalues[i+1]; } x->last_state--; x->w.grabbed--; envgen_update(x,x->w.glist); } } static int envgen_newclick(t_envgen *x, struct _glist *glist, int xpos, int ypos, int shift, int alt, int dbl, int doit) { /* check if user wants to resize */ float wxpos = text_xpix(&x->x_obj,glist); float wypos = (int) (text_ypix(&x->x_obj,glist) + x->w.height); if (doit){ envgen_next_doodle(x,glist,xpos,ypos); glist_grab(x->w.glist, &x->x_obj.te_g, (t_glistmotionfn) envgen_motion, (t_glistkeyfn) envgen_key, xpos, ypos); x->resizing = 0; if (x->resizeable && (xpos > wxpos + x->w.width) && (ypos > wypos)) { x->resizing = 1; return (0); } x->w.shift = shift; envgen_followpointer(x,glist); envgen_shownum(x,glist); envgen_update(x,glist); } return (1); } ggee-0.28/other/000077500000000000000000000000001402462307700135005ustar00rootroot00000000000000ggee-0.28/other/ls_setup000066400000000000000000000067661402462307700153000ustar00rootroot00000000000000File: loudspeaker_hdm_3D Configured 28 sets in 3 dimensions: Triplet 0 Loudspeakers: 1 5 6 Matrix 4.456940 0.000000 -3.755852 -2.228470 -0.923062 2.655788 -2.228470 0.923062 2.655788 Triplet 1 Loudspeakers: 1 5 9 Matrix 0.652704 1.575766 0.777862 0.000000 -1.846125 -0.000000 0.652704 -0.270359 -0.777862 Triplet 2 Loudspeakers: 1 6 9 Matrix 0.652704 -1.575766 0.777862 -0.000000 1.846125 0.000000 0.652704 0.270359 -0.777862 Triplet 3 Loudspeakers: 2 6 8 Matrix 0.000002 4.456941 -3.755853 0.923062 -2.228471 2.655789 -0.923063 -2.228470 2.655789 Triplet 4 Loudspeakers: 2 6 10 Matrix -1.575766 0.652704 0.777862 1.846125 -0.000001 -0.000000 0.270359 0.652703 -0.777862 Triplet 5 Loudspeakers: 2 8 10 Matrix 1.575766 0.652703 0.777862 -1.846125 0.000001 0.000000 -0.270358 0.652704 -0.777862 Triplet 6 Loudspeakers: 3 5 7 Matrix 0.000002 -4.456941 -3.755853 0.923062 2.228471 2.655789 -0.923063 2.228470 2.655789 Triplet 7 Loudspeakers: 3 5 11 Matrix -1.575766 -0.652704 0.777862 1.846125 0.000001 0.000000 0.270359 -0.652703 -0.777862 Triplet 8 Loudspeakers: 3 7 11 Matrix 1.575766 -0.652703 0.777862 -1.846125 -0.000001 -0.000000 -0.270358 -0.652704 -0.777862 Triplet 9 Loudspeakers: 4 7 8 Matrix -4.456932 -0.000000 -3.755843 2.228464 -0.923062 2.655782 2.228468 0.923062 2.655785 Triplet 10 Loudspeakers: 4 7 12 Matrix -0.652703 1.575764 0.777862 -0.000001 -1.846122 0.000000 -0.652704 -0.270359 -0.777862 Triplet 11 Loudspeakers: 4 8 12 Matrix -0.652705 -1.575766 0.777862 0.000001 1.846125 -0.000000 -0.652703 0.270359 -0.777862 Triplet 12 Loudspeakers: 5 6 7 Matrix 0.923063 -0.923062 -0.000001 -0.000000 0.923062 0.777862 -0.923062 -0.000000 0.777862 Triplet 13 Loudspeakers: 5 9 13 Matrix 0.652704 -0.270359 0.777862 1.305407 1.305407 0.000000 -0.652704 -1.575766 -0.777862 Triplet 14 Loudspeakers: 5 11 13 Matrix 0.270359 -0.652703 0.777862 -1.305407 -1.305407 -0.000000 1.575766 0.652704 -0.777862 Triplet 15 Loudspeakers: 6 7 8 Matrix 0.923062 0.000000 0.777862 -0.000000 -0.923062 0.777862 -0.923062 0.923062 0.000001 Triplet 16 Loudspeakers: 6 9 14 Matrix 0.652704 0.270359 0.777862 1.305407 -1.305407 -0.000000 -0.652704 1.575766 -0.777862 Triplet 17 Loudspeakers: 6 10 14 Matrix 0.270359 0.652703 0.777862 -1.305407 1.305407 0.000000 1.575766 -0.652704 -0.777862 Triplet 18 Loudspeakers: 7 11 15 Matrix -0.270358 -0.652704 0.777862 1.305408 -1.305407 0.000000 -1.575766 0.652703 -0.777862 Triplet 19 Loudspeakers: 7 12 15 Matrix -0.652704 -0.270359 0.777862 -1.305406 1.305405 -0.000000 0.652703 -1.575764 -0.777862 Triplet 20 Loudspeakers: 8 10 16 Matrix -0.270358 0.652704 0.777862 1.305408 1.305407 -0.000000 -1.575766 -0.652703 -0.777862 Triplet 21 Loudspeakers: 8 12 16 Matrix -0.652703 0.270359 0.777862 -1.305408 -1.305407 0.000000 0.652705 1.575766 -0.777862 Triplet 22 Loudspeakers: 9 13 14 Matrix 4.456940 -0.000000 3.755852 -2.228470 -0.923062 -2.655788 -2.228470 0.923062 -2.655788 Triplet 23 Loudspeakers: 10 14 16 Matrix 0.000002 4.456941 3.755853 0.923062 -2.228471 -2.655789 -0.923063 -2.228470 -2.655789 Triplet 24 Loudspeakers: 11 13 15 Matrix 0.000002 -4.456941 3.755853 0.923062 2.228471 -2.655789 -0.923063 2.228470 -2.655789 Triplet 25 Loudspeakers: 12 15 16 Matrix -4.456932 0.000000 3.755843 2.228464 -0.923062 -2.655782 2.228468 0.923062 -2.655785 Triplet 26 Loudspeakers: 13 14 15 Matrix 0.923063 -0.923062 0.000001 -0.000000 0.923062 -0.777862 -0.923062 0.000000 -0.777862 Triplet 27 Loudspeakers: 14 15 16 Matrix 0.923062 -0.000000 -0.777862 -0.000000 -0.923062 -0.777862 -0.923062 0.923062 -0.000001 ggee-0.28/other/ls_setup16000066400000000000000000000067661402462307700154470ustar00rootroot00000000000000File: loudspeaker_hdm_3D Configured 28 sets in 3 dimensions: Triplet 0 Loudspeakers: 1 5 6 Matrix 4.456940 0.000000 -3.755852 -2.228470 -0.923062 2.655788 -2.228470 0.923062 2.655788 Triplet 1 Loudspeakers: 1 5 9 Matrix 0.652704 1.575766 0.777862 0.000000 -1.846125 -0.000000 0.652704 -0.270359 -0.777862 Triplet 2 Loudspeakers: 1 6 9 Matrix 0.652704 -1.575766 0.777862 -0.000000 1.846125 0.000000 0.652704 0.270359 -0.777862 Triplet 3 Loudspeakers: 2 6 8 Matrix 0.000002 4.456941 -3.755853 0.923062 -2.228471 2.655789 -0.923063 -2.228470 2.655789 Triplet 4 Loudspeakers: 2 6 10 Matrix -1.575766 0.652704 0.777862 1.846125 -0.000001 -0.000000 0.270359 0.652703 -0.777862 Triplet 5 Loudspeakers: 2 8 10 Matrix 1.575766 0.652703 0.777862 -1.846125 0.000001 0.000000 -0.270358 0.652704 -0.777862 Triplet 6 Loudspeakers: 3 5 7 Matrix 0.000002 -4.456941 -3.755853 0.923062 2.228471 2.655789 -0.923063 2.228470 2.655789 Triplet 7 Loudspeakers: 3 5 11 Matrix -1.575766 -0.652704 0.777862 1.846125 0.000001 0.000000 0.270359 -0.652703 -0.777862 Triplet 8 Loudspeakers: 3 7 11 Matrix 1.575766 -0.652703 0.777862 -1.846125 -0.000001 -0.000000 -0.270358 -0.652704 -0.777862 Triplet 9 Loudspeakers: 4 7 8 Matrix -4.456932 -0.000000 -3.755843 2.228464 -0.923062 2.655782 2.228468 0.923062 2.655785 Triplet 10 Loudspeakers: 4 7 12 Matrix -0.652703 1.575764 0.777862 -0.000001 -1.846122 0.000000 -0.652704 -0.270359 -0.777862 Triplet 11 Loudspeakers: 4 8 12 Matrix -0.652705 -1.575766 0.777862 0.000001 1.846125 -0.000000 -0.652703 0.270359 -0.777862 Triplet 12 Loudspeakers: 5 6 7 Matrix 0.923063 -0.923062 -0.000001 -0.000000 0.923062 0.777862 -0.923062 -0.000000 0.777862 Triplet 13 Loudspeakers: 5 9 13 Matrix 0.652704 -0.270359 0.777862 1.305407 1.305407 0.000000 -0.652704 -1.575766 -0.777862 Triplet 14 Loudspeakers: 5 11 13 Matrix 0.270359 -0.652703 0.777862 -1.305407 -1.305407 -0.000000 1.575766 0.652704 -0.777862 Triplet 15 Loudspeakers: 6 7 8 Matrix 0.923062 0.000000 0.777862 -0.000000 -0.923062 0.777862 -0.923062 0.923062 0.000001 Triplet 16 Loudspeakers: 6 9 14 Matrix 0.652704 0.270359 0.777862 1.305407 -1.305407 -0.000000 -0.652704 1.575766 -0.777862 Triplet 17 Loudspeakers: 6 10 14 Matrix 0.270359 0.652703 0.777862 -1.305407 1.305407 0.000000 1.575766 -0.652704 -0.777862 Triplet 18 Loudspeakers: 7 11 15 Matrix -0.270358 -0.652704 0.777862 1.305408 -1.305407 0.000000 -1.575766 0.652703 -0.777862 Triplet 19 Loudspeakers: 7 12 15 Matrix -0.652704 -0.270359 0.777862 -1.305406 1.305405 -0.000000 0.652703 -1.575764 -0.777862 Triplet 20 Loudspeakers: 8 10 16 Matrix -0.270358 0.652704 0.777862 1.305408 1.305407 -0.000000 -1.575766 -0.652703 -0.777862 Triplet 21 Loudspeakers: 8 12 16 Matrix -0.652703 0.270359 0.777862 -1.305408 -1.305407 0.000000 0.652705 1.575766 -0.777862 Triplet 22 Loudspeakers: 9 13 14 Matrix 4.456940 -0.000000 3.755852 -2.228470 -0.923062 -2.655788 -2.228470 0.923062 -2.655788 Triplet 23 Loudspeakers: 10 14 16 Matrix 0.000002 4.456941 3.755853 0.923062 -2.228471 -2.655789 -0.923063 -2.228470 -2.655789 Triplet 24 Loudspeakers: 11 13 15 Matrix 0.000002 -4.456941 3.755853 0.923062 2.228471 -2.655789 -0.923063 2.228470 -2.655789 Triplet 25 Loudspeakers: 12 15 16 Matrix -4.456932 0.000000 3.755843 2.228464 -0.923062 -2.655782 2.228468 0.923062 -2.655785 Triplet 26 Loudspeakers: 13 14 15 Matrix 0.923063 -0.923062 0.000001 -0.000000 0.923062 -0.777862 -0.923062 0.000000 -0.777862 Triplet 27 Loudspeakers: 14 15 16 Matrix 0.923062 -0.000000 -0.777862 -0.000000 -0.923062 -0.777862 -0.923062 0.923062 -0.000001 ggee-0.28/other/messages.c000066400000000000000000000013151402462307700154530ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ messages ----------------------------- */ static t_class *messages_class; typedef struct _messages { t_object x_obj; } t_messages; void messages_bang(t_messages *x) { post("bang"); } static void *messages_new() { t_messages *x = (t_messages *)pd_new(messages_class); outlet_new(&x->x_obj, &s_float); return (x); } void messages_setup(void) { messages_class = class_new(gensym("messages"), (t_newmethod)messages_new, 0, sizeof(t_messages), 0,0); class_addbang(messages_class,messages_bang); } ggee-0.28/other/vbap-help.pd000066400000000000000000000035161402462307700157100ustar00rootroot00000000000000#N canvas 0 26 550 445 10; #X msg 82 109 20 0; #X obj 27 108 pack 1 2; #X floatatom 27 87 0 0 0 0 - - -; #X floatatom 70 88 0 0 0 0 - - -; #X obj 62 176 route 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; #X floatatom 62 221 0 0 0 0 - - -; #X floatatom 78 251 0 0 0 0 - - -; #X floatatom 94 284 0 0 0 0 - - -; #X floatatom 111 316 0 0 0 0 - - -; #X floatatom 127 224 0 0 0 0 - - -; #X floatatom 143 251 0 0 0 0 - - -; #X floatatom 160 282 0 0 0 0 - - -; #X floatatom 176 317 0 0 0 0 - - -; #X floatatom 216 225 0 0 0 0 - - -; #X floatatom 239 251 0 0 0 0 - - -; #X floatatom 273 277 0 0 0 0 - - -; #X floatatom 334 247 0 0 0 0 - - -; #X floatatom 309 225 0 0 0 0 - - -; #X floatatom 308 314 0 0 0 0 - - -; #X floatatom 373 276 0 0 0 0 - - -; #X floatatom 415 315 0 0 0 0 - - -; #X floatatom 401 227 0 0 0 0 - - -; #X floatatom 476 295 0 0 0 0 - - -; #X floatatom 443 258 0 0 0 0 - - -; #X text 31 15 A VBAP (Vector Base Amplitude Panning) external; #X obj 82 144 vbap; #N canvas 339 212 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 5 KEYWORDS control; #X text 12 45 DESCRIPTION vector base amplitude panning; #X text 12 65 INLET_0 list; #X text 12 85 OUTLET_0 list; #X text 12 105 AUTHOR Guenter Geiger and Ville Pulkki; #X restore 501 425 pd META; #X connect 0 0 25 0; #X connect 1 0 25 0; #X connect 2 0 1 0; #X connect 3 0 1 1; #X connect 4 0 5 0; #X connect 4 1 6 0; #X connect 4 2 7 0; #X connect 4 3 8 0; #X connect 4 4 9 0; #X connect 4 5 10 0; #X connect 4 6 11 0; #X connect 4 7 12 0; #X connect 4 8 13 0; #X connect 4 9 14 0; #X connect 4 10 15 0; #X connect 4 11 16 0; #X connect 4 12 17 0; #X connect 4 13 18 0; #X connect 4 14 19 0; #X connect 4 15 20 0; #X connect 4 16 21 0; #X connect 4 17 22 0; #X connect 4 18 23 0; #X connect 25 0 4 0; ggee-0.28/other/vbap.c000066400000000000000000000142601402462307700145770ustar00rootroot00000000000000/* (C) Guenter Geiger */ /* (C) Guenter Geiger based on code by: (c) Ville Pulkki 2.2.1999 Helsinki University of Technology Laboratory of Acoustics and Audio Signal Processing */ #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include #ifndef __APPLE__ #include #endif #include /* strtok */ #define MAX_TRIPLET_AMOUNT 64 /* this is related to the number of ls .. and shoud be 3**(MAX_LS_AMOUNT / 4) */ #define MAX_LS_AMOUNT 16 #define MAX_DIM_SQUARE 9 /* ------------------------ vbap ----------------------------- */ static t_class *vbap_class; typedef struct _vbap { t_object x_ob; t_outlet* x_out2; t_outlet* x_out3; t_float lsm[MAX_TRIPLET_AMOUNT][MAX_LS_AMOUNT+1]; /* loudspeaker triplet matrices */ int lstripl[MAX_TRIPLET_AMOUNT][3]; /* loudspeaker triplet ldspeaker numbers */ int lasttrip[3]; int triplet_amount; int dimension; int opened; } t_vbap; t_float *angle_to_cart(t_float azi, t_float ele); void vbap(t_vbap* x,t_float g[3], int ls[3], t_float azi, t_float ele) ; int read_ls_conf(t_vbap* x,FILE *fp ); void vbap_list(t_vbap *x,t_symbol* s,t_int argc,t_atom* argv) { t_float azi,ele; t_float g[3]; int ls[3]; t_atom a[2]; if (argc != 2) post("vbap: list message required %d",argc); else { int i; azi = atom_getfloat(argv++); ele = atom_getfloat(argv++); vbap(x,g,ls,azi,ele); for (i=0;idimension;i++) { if (x->lasttrip[i] != ls[i]) { SETFLOAT(a,(t_float)x->lasttrip[i]); SETFLOAT(a+1,0.0f); outlet_list(x->x_ob.ob_outlet, &s_list,2 ,(t_atom*)&a); x->lasttrip[i] = ls[i]; } } for (i=0;idimension;i++) { SETFLOAT(a,(t_float)ls[i]); SETFLOAT(a+1,g[i]); outlet_list(x->x_ob.ob_outlet, &s_list,2 ,(t_atom*)&a); } } } void vbap_bang(t_vbap *x) { post("vbap: bang"); } static void *vbap_new(t_symbol* s) { FILE *fp; t_vbap *x = (t_vbap *)pd_new(vbap_class); char fname[MAXPDSTRING]; if (s == &s_) { post("vbap: Using default loudspeaker setup"); s = gensym("ls_setup"); } /* opening the loudspeaker matrix file*/ canvas_makefilename(canvas_getcurrent(),s->s_name, fname,MAXPDSTRING); if((fp=fopen(fname,"r"))==NULL){ post("vbap: Could not open loudspeaker data file %s\n",fname); x->opened = 0; } else { if (!read_ls_conf(x,fp)) return NULL; x->opened = 1; fclose(fp); } x->lasttrip[0] = 0; x->lasttrip[1] = 1; x->lasttrip[2] = 2; outlet_new(&x->x_ob, &s_list); return (x); } void vbap_setup(void) { vbap_class = class_new(gensym("vbap"), (t_newmethod)vbap_new, 0, sizeof(t_vbap), 0,A_DEFSYM,0); /* class_addbang(vbap_class,vbap_bang);*/ class_addlist(vbap_class,vbap_list); } t_float *angle_to_cart(t_float azi, t_float ele) { t_float *res; t_float atorad = (2 * 3.1415927 / 360) ; res = (t_float *) malloc(3*sizeof(t_float)); res[0] = (float) (cos((t_float) (azi * atorad)) * cos((t_float) (ele * atorad))); res[1] = (float) (sin((t_float) (azi * atorad)) * cos((t_float) (ele * atorad))); res[2] = (float) (sin((t_float) (ele * atorad))); return res; } void vbap(t_vbap* x,t_float g[3], int ls[3], float azi, float ele) { /* calculates gain factors using loudspeaker setup and given direction */ t_float *cartdir; t_float power; int i,j,k; t_float small_g; t_float big_sm_g, gtmp[3]; int winner_triplet; cartdir=angle_to_cart(azi,ele); big_sm_g = -100000.0; for(i=0;itriplet_amount;i++){ small_g = 10000000.0; for(j=0;jdimension;j++){ gtmp[j]=0.0; for(k=0;kdimension;k++) gtmp[j]+=cartdir[k]*x->lsm[i][k+j*x->dimension]; if(gtmp[j] < small_g) small_g = gtmp[j]; } if(small_g > big_sm_g){ big_sm_g = small_g; winner_triplet=i; g[0]=gtmp[0]; g[1]=gtmp[1]; ls[0]=x->lstripl[i][0]; ls[1]=x->lstripl[i][1]; if(x->dimension==3){ g[2]=gtmp[2]; ls[2]=x->lstripl[i][2]; } else { g[2]=0.0; ls[2]=0; } } } /* this should probably be optimized somehow */ power=sqrt(g[0]*g[0] + g[1]*g[1] + g[2]*g[2]); /* power=g[0]+g[1];*/ g[0] /= power; g[1] /= power; g[2] /= power; free(cartdir); } int read_ls_conf(t_vbap* x,FILE *fp ){ /* reads from specified file the loudspeaker triplet setup */ int amount,i,j,a,b,d=0; char *toke; char c[1000]; t_float mx[MAX_DIM_SQUARE]; fgets(c,1000,fp); toke = (char *) strtok(c, " "); toke = (char *) strtok(NULL, " "); toke = (char *) strtok(NULL, " "); if((toke = (char *) strtok(NULL, " "))==NULL){ fprintf(stderr,"Wrong ls matrix file?\n"); return 0; } sscanf(toke, "%d",&amount); toke = (char *) strtok(NULL, " "); toke = (char *) strtok(NULL, " "); if((toke = (char *) strtok(NULL, " "))==NULL){ fprintf(stderr,"Wrong ls matrix file?\n"); return 0; } sscanf(toke, "%d",&x->dimension); x->triplet_amount = amount; for(i=0;idimension==3){ fprintf(stderr,"Something wrong in ls matrix file\n"); return 0; } if(strncmp(toke,"Pair",4)!=0 && x->dimension==2){ fprintf(stderr,"Something wrong in ls matrix file\n"); return 0; } toke = (char *) strtok(NULL, " "); toke = (char *) strtok(NULL, " "); toke = (char *) strtok(NULL, " "); sscanf(toke, "%d",&a); x->lstripl[i][0]=a; toke = (char *) strtok(NULL, " "); sscanf(toke, "%d",&b); x->lstripl[i][1]=b; if (x->dimension==3){ toke = (char *) strtok(NULL, " "); sscanf(toke, "%d",&d); x->lstripl[i][2]=d; } toke = (char *) strtok(NULL, " "); for(j=0;j<(x->dimension*x->dimension);j++){ toke = (char *) strtok(NULL, " "); sscanf(toke, "%f",&(mx[j])); x->lsm[i][j]=mx[j]; } } return 1; } ggee-0.28/pd-lib-builder/000077500000000000000000000000001402462307700151525ustar00rootroot00000000000000ggee-0.28/pd-lib-builder/CHANGELOG.txt000066400000000000000000000066431402462307700172130ustar00rootroot00000000000000Changelog for Makefile.pdlibbuilder. v0.6.0, dated 2019-12-21 - detect target platform (OS and architecture) rather than build platform (#55) - introduce optional user variable 'PLATFORM' for cross compilation - no longer build OSX/MacOS fat binaries by default (#21, #50) - do build fat binaries when 'extension=d_fat' is specified for OSX/MacOS - fix bug where minimum OSX/MacOS version wasn't defined, and set it to 10.6 v0.5.1, dated 2018-03-15 Fixes and improvements for Windows builds: - properly evaluate variables 'PDDIR' and 'PDBINDIR' to find pd.dll - define default path of 32 bit Pd on 64 bit Windows - link C++ externals with standard C libs on Windows, they don't load otherwise - strip installed Windows binaries by default (issues #34, #39, #41, #42 respectively) Warning for all platforms: variable 'PD_PATH' is no longer supported, use the equivalent 'PDDIR'. v0.5.0, dated 2018-01-23 Implement target architecture detection for Windows builds, and set appropriate options for 32 and 64 bit (used to be for 32 bit only). (feature, issue #37 #38, merge commit 215bf3e) v0.4.4, dated 2016-11-22 Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}' (bugfix, issue #31, commit 2c14110) v0.4.3, dated 2016-11-02 Replace flags '-fpic' by 'fPIC'. (bugfix, issue #29, commit 426b38b) v0.4.2, dated 2016-10-30 Fix issue where incorrect message about m_pd.h is given. (bugfix, commit 2e13d8f) v0.4.1, dated 2016-10-27 Respect cflag for minimum OSX version when defined by lib makefile. (bugfix, pull request #22, commit 48c4127) v0.4.0, dated 2016-10-14 Introduced path variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR which can also be defined in environment. (feature, issue #27, commit b0dab72) v0.3.1, dated 2016-10-13 Fix bug where pd.dll wouldn't be found. (bugfix, commit a0c87be) v0.3.0, dated 2016-10-09 Variable 'PD_PATH' introduced for pd-extended / pd-l2ork compatibility. (feature, issue #26, commit 41e9743) v0.2.8, dated 2016-10-09 Allow installed files to contain weird characters (notably '$'). (bugfix, pull request #20, commit 5b920b1) v0.2.7, dated 2016-10-04 Remove all default pd search paths except vanilla's. (discussion, issue #25, commit a6a89dc) v0.2.6, dated 2016-09-20 Redefined dependency checking so it won't stall rebuilds on OSX. (bugfix, issue #16, commit 9fd1795) v0.2.5, dated 2016-06-26 Fixed dependency checking for object files in other directories. (bugfix, commit f06e550) v0.2.4, dated 2016-06-25 Fixed regression bug that disabled all dependency checking. (bugfix, commit 1d7bb5e) v0.2.3, dated 2016-03-29 Disabled dependency checking for OSX <= 10.5 because it stalled rebuilds. (bugfix, issue #16, commit eb614fd) v0.2.2, dated 2016-03-28 Removed target 'pre' because it forced rebuild of everything in 'all'. (bugfix, issue #17, commit c989c8e) v0.2.1, dated 2015-12-27 Implement / respect 'CPPFLAGS','CFLAGS'and 'LDFLAGS'. (bugfix, issue #5, commit 98f3582) v0.2.0, dated 2015-12-19 Added per-platform multiline defines 'forLinux', 'forDarwin', 'forWindows'. (feature, pull request #9, commit 3946ea5) v0.1.0, dated 2015-12-08 Added targets 'pre' and 'post' to automatically run before and after 'all'. (feature, pull request #4, commit a5678ac) v0.0.2, dated 2015-12-06 Improved methods for searching pd paths. (bugfix, commit ed37e6b) v0.0.1, dated 2015-10-31 Fixed expansion of variable 'lib.version'. (bugfix, issue #1, commit 974b617) v0.0.0, dated 2015-06-24 Initial version. (commit 16517a2) ggee-0.28/pd-lib-builder/Makefile.pdlibbuilder000066400000000000000000001266041402462307700212630ustar00rootroot00000000000000# Makefile.pdlibbuilder dated 2019-12-21 version = 0.6.0 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's # ShakeNMake. # # Grab the newest version of Makefile.pdlibbuilder from # https://github.com/pure-data/pd-lib-builder/ # # GNU make version >= 3.81 required. # # #=== characteristics =========================================================== # # # - defines build settings based on autodetected OS and architecture # - defines rules to build Pd class- or lib executables from C or C++ sources # - defines rules for libdir installation # - defines convenience targets for developer and user # - evaluates implicit dependencies for non-clean builds # # #=== basic usage =============================================================== # # # In your Makefile, define your Pd lib name and class files, and include # Makefile.pdlibbuilder at the end of the Makefile. Like so: # # ________________________________________________________________________ # # # Makefile for mylib # # lib.name = mylib # # class.sources = myclass1.c myclass2.c # # datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt # # include Makefile.pdlibbuilder # ________________________________________________________________________ # # # For files in class.sources it is assumed that class basename == source file # basename. The default target builds all classes as individual executables # with Pd's default extension for the platform. For anything more than the # most basic usage, continue reading. # # #=== list of Makefile.pdlibbuilder API variables =============================== # # # Variables available for definition in your library Makefile: # # - lib.name # - lib.setup.sources # - class.sources # - common.sources # - shared.sources # - .class.sources # - .class.ldflags # - .class.ldlibs # - cflags # - ldflags # - ldlibs # - datafiles # - datadirs # - makefiles # - makefiledirs # - externalsdir # # Optional multiline defines evaluated per operating system: # # - forLinux # - forDarwin # - forWindows # # Variables available for your makefile or make command line: # # - make-lib-executable # - suppress-wunused # # Path variables for make command line or environment: # # - PDDIR # - PDINCLUDEDIR # - PDBINDIR # - PDLIBDIR # # Standard make variables for make command line or environment: # # - CPPFLAGS # - CFLAGS # - LDFLAGS # - CC # - CXX # - INSTALL # - STRIP # - DESTDIR # # Optional user variables for make command line or environment: # # - PLATFORM # # Deprecated path variables: # # - pdincludepath # - pdbinpath # - objectsdir # # #=== descriptions of Makefile.pdlibbuilder API variables ======================= # # # lib.name: # Name of the library directory as it will be installed / distributed. Also the # name of the lib executable in the case where all classes are linked into # a single binary. # # lib.setup.sources: # Source file(s) (C or C++) which must be compiled only when linking all classes # into a single lib binary. # # class.sources: # All sources files (C or C++) for which the condition holds that # class name == source file basename. # # .class.sources: # Source file(s) (C or C++) specific to class . Use this for # multiple-source classes or when class name != source file basename. # # common.sources: # Source file(s) which must be statically linked to each class in the library. # # shared.sources: # Source file(s) (C or C++) to build a shared dynamic link lib, to be linked # with all class executables. # # cflags, ldflags, ldlibs: # Define cflags (preprocessor&compiler), ldflags (linker) and ldlibs (dynamic # link libs) for the whole library. These flags are added to platform-specific # flags defined by Makefile.pdlibbuilder. # # .class.ldflags and .class.ldlibs: # Define ldflags resp. ldlibs specific to class . These flags are # added to platform-specific flags defined by Makefile.pdlibbuilder, and flags # defined in your Makefile for the whole library. Note: cflags can not be # defined per class in the current implementation. # # datafiles and datadirs: # All extra files you want to include in binary distributions of the # library: abstractions and help patches, example patches, meta patch, readme # and license texts, manuals, sound files, etcetera. Use 'datafiles' for all # files that should go into your lib rootdir and 'datadirs' for complete # directories you want to copy from source to distribution. # # forLinux, forDarwin, forWindows: # Shorthand for 'variable definitions for Linux only' etc. Use like: # define forLinux # cflags += -DLINUX # class.sources += linuxthing.c # endef # # makefiles and makefiledirs: # Extra makefiles or directories with makefiles that should be made in sub-make # processes. # # make-lib-executable: # When this variable is defined 'yes' in your makefile or as command argument, # Makefile.pdlibbuilder will try to build all classes into a single library # executable (but it will force exit if lib.setup.sources is undefined). # If your makefile defines 'make-lib-executable=yes' as the library default, # this can still be overridden with 'make-lib-executable=no' as command argument # to build individual class executables (the Makefile.pdlibbuilder default.) # # suppress-wunused: # When this variable is defined ('yes' or any other value), -Wunused-variable, # -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, # but the other warnings from -Wall are retained. # # PDDIR: # Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and # PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. # # PDINCLUDEDIR: # Directory where Pd API m_pd.h should be found, and other Pd header files. # Overrides the default search path. # # PDBINDIR: # Directory where pd.dll should be found for linking (Windows only). Overrides # the default search path. # # PDLIBDIR: # Root directory for installation of Pd library directories. Overrides the # default install location. # # DESTDIR: # Prepended path component for staged install. # # PLATFORM: # Target platform for cross compilation in the form of GNU triplet: # cpu-vendor-os. Example: x86_64-w64-mingw32. This specifies the tool chain that # pdlibbuilder will use, if installed and locatable. System and architecture # will then be autodefined accordingly. In most cases no other variables need to # be overridden. # # CPPFLAGS: # Preprocessor flags which are not strictly required for building. # # CFLAGS: # Compiler flags which are not strictly required for building. Compiler flags # defined by Makefile.pdlibbuilder for warning, optimization and architecture # specification are overriden by CFLAGS. # # LDFLAGS: # Linker flags which are not strictly required for building. Linker flags # defined by Makefile.pdlibbuilder for architecture specification are overriden # by LDFLAGS. # # CC and CXX: # C and C++ compiler programs as defined in your build environment. # # INSTALL # Definition of install program. # # STRIP # Name of strip program. Default 'strip' can be overridden in cross compilation # environments. # # objectsdir: # Root directory for installation of Pd library directories, like PDLIBDIR but # not overridable by environment. Supported for compatibility with pd-extended # central makefile, but deprecated otherwise. # # pdincludepath, pdbinpath: # As PDINCLUDEDIR and PDBINDIR but not overridable by environment. Deprecated # as user variables. # # #=== paths ===================================================================== # # # Source files in directories other than current working directory must be # prefixed with their relative path. Do not rely on VPATH or vpath. # Object (.o) files are built in the directory of their source files. # Executables are built in current working directory. # # Default search path for m_pd.h and other API header files is platform # dependent, and overridable by PDINCLUDEDIR: # # Linux: /usr/include/pd # # OSX: /Applications/Pd*.app/Contents/Resources/src # # Windows: %PROGRAMFILES%/Pd/src # %PROGRAMFILES(X86)%/Pd/src (32 bit builds on 64 bit Windows) # # Default search path for binary pd.dll (Windows), overridable by PDBINDIR # # %PROGRAMFILES%/Pd/bin # %PROGRAMFILES(X86)%/Pd/bin (32 bit builds on 64 bit Windows) # # Default location to install pd libraries is platform dependent, and # overridable by PDLIBDIR: # # Linux: /usr/local/lib/pd-externals # OSX: ~/Library/Pd # Windows: %APPDATA%/Pd # # https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files # The rationale for not installing to ~/pd-externals by default on Linux # is that some people share the home dir between 32 and 64 bit installations. # # #=== targets =================================================================== # # # all: build $(executables) plus optional post target # post: target to build after $(executables) # alldebug: build all with -g option turned on for debug symbols # : force clean build of an individual class # .pre: make preprocessor output file in current working directory # .lst: make asm/source output file in current working directory # # install: install executables and data files # clean: remove build products from source tree # # help: print help text # vars: print makefile variables # allvars: print all variables # depend: print generated prerequisites # dumpmachine: print compiler output of option '-dumpmachine' # coffee: dummy target # # Variable $(executables) expands to class executables plus optional shared lib, # or alternatively to single lib executable when make-lib-executable=true. # Targets pre and post can be defined by library makefile. Make sure to include # Makefile.pdlibbuilder first so default target all will not be redefined. # # #=== Pd-extended libdir concept ================================================ # # # For libdir layout as conceived by Hans-Christoph Steiner, see: # # https://puredata.info/docs/developer/Libdir # # Files README.txt, LICENSE.txt and -meta.pd are part of the libdir # convention. Help patches for each class and abstraction are supposed to be # available. Makefile.pdlibbuilder does not force the presence of these files # however. It does not automatically include such files in libdir installations. # Data files you want to include in distributions must be defined explicitly in # your Makefile. # # #=== Makefile.pdlibbuilder syntax conventions ================================== # # # Makefile.pdlibbuilder variable names are lower case. Default make variables, # environment variables, and standard user variables (CC, CXX, CFLAGS, DESTDIR) # are upper case. Use target 'allvars' to print all variables and their values. # # 'Fields' in data variables are separated by dots, like in 'foo.class.sources'. # Words in variables expressing a function or command are separated by dashes, # like in 'make-lib-executable'. # # #=== useful make options ======================================================= # # # Use 'make -d ' to print debug details of the make process. # Use 'make -p ' to print make's database. # # #=== TODO ====================================================================== # # # - decide whether to use -static-libgcc or shared dll in MinGW # - cygwin support # - android support # - figure out how to handle '$' in filenames # - add makefile template targets dpkg-source dist libdir distclean tags? # # #=== end of documentation sections ============================================= # # ################################################################################ ################################################################################ ################################################################################ # GNU make version 3.81 (2006) or higher is required because of the following: # - function 'info' # - variable '.DEFAULT_GOAL' # force exit when make version is < 3.81 ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81) $(error GNU make version 3.81 or higher is required) endif # Relative path to externals root dir in multi-lib source tree like # pd-extended SVN. Default is parent of current working directory. May be # defined differently in including makefile. externalsdir ?= .. # variable you can use to check if Makefile.pdlibbuilder is already included Makefile.pdlibbuilder = true ################################################################################ ### variables: library name and version ######################################## ################################################################################ # strip possibles spaces from lib.name, they mess up calculated file names lib.name := $(strip $(lib.name)) # if meta file exists, check library version metafile := $(wildcard $(lib.name)-meta.pd) ifdef metafile lib.version := $(shell sed -n \ 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ $(metafile)) endif ################################################################################ ### variables: files ########################################################### ################################################################################ #=== sources =================================================================== # (re)define .class.sources using file names in class.sources define add-class-source $(notdir $(basename $v)).class.sources += $v endef $(foreach v, $(class.sources), $(eval $(add-class-source))) # derive class names from .class.sources variables sourcevariables := $(filter %.class.sources, $(.VARIABLES)) classes := $(basename $(basename $(sourcevariables))) # accumulate all source files specified in makefile classes.sources := $(sort $(foreach v, $(sourcevariables), $($v))) all.sources := $(classes.sources) $(lib.setup.sources) \ $(shared.sources) $(common.sources) #=== object files ============================================================== # construct object filenames from all C and C++ source file names classes.objects := $(addsuffix .o, $(basename $(classes.sources))) common.objects := $(addsuffix .o, $(basename $(common.sources))) shared.objects := $(addsuffix .o, $(basename $(shared.sources))) lib.setup.objects := $(addsuffix .o, $(basename $(lib.setup.sources))) all.objects = $(classes.objects) $(common.objects) $(shared.objects) \ $(lib.setup.objects) #=== executables =============================================================== # use recursive variables here because executable extension is not yet known # construct class executable names from class names classes.executables = $(addsuffix .$(extension), $(classes)) # construct shared lib executable name if shared sources are defined ifdef shared.sources shared.lib = lib$(lib.name).$(shared.extension) else shared.lib = endif ################################################################################ ### target platform detection ################################################## ################################################################################ #=== target platform =========================================================== # PLATFORM: optional user variable to define target platform for cross # compilation. Redefine build tools accordingly. PLATFORM should match # the exact target prefix of tools present in $PATH, like x86_64-w64-mingw32, # x86_64-apple-darwin12 etc. Tool definitions are exported to ensure submakes # will get the same. ifneq ($(PLATFORM),) ifneq ($(findstring darwin, $(PLATFORM)),) export CC = $(PLATFORM)-cc export CXX = $(PLATFORM)-c++ export CPP = $(PLATFORM)-cc else export CC = $(PLATFORM)-gcc export CXX = $(PLATFORM)-g++ export CPP = $(PLATFORM)-cpp endif STRIP = $(PLATFORM)-strip endif # Let (native or cross-) compiler report target triplet and isolate individual # words therein to facilitate later processing. target.triplet := $(subst -, ,$(shell $(CC) -dumpmachine)) #=== operating system ========================================================== # The following systems are defined: Linux, Darwin, Windows. GNU and # GNU/kFreeBSD are treated as Linux to get the same options. ifneq ($(filter linux gnu% kfreebsd, $(target.triplet)),) system = Linux endif ifneq ($(filter darwin%, $(target.triplet)),) system = Darwin endif ifneq ($(filter mingw% cygwin%, $(target.triplet)),) system = Windows endif # evaluate possible system-specific multiline defines from library makefile $(eval $(for$(system))) # TODO: Cygwin, Android #=== architecture ============================================================== # The following CPU names can be processed by pdlibbuilder: # i*86 Intel 32 bit # x86_64 Intel 64 bit # arm ARM 32 bit # aarch64 ARM 64 bit target.arch := $(firstword $(target.triplet)) ################################################################################ ### variables per platform ##################################################### ################################################################################ #=== flags per architecture ==================================================== # Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, # arch.c.flags are overriden below. To see gcc's default architecture flags: # $ gcc -Q --help=target # ARMv6: Raspberry Pi 1st gen, not detectable from target.arch ifeq ($(shell uname), armv6l) arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard # ARMv7: Beagle, Udoo, RPi2 etc. else ifeq ($(target.arch), arm) arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard # ARMv8 64 bit, not tested yet else ifeq ($(target.arch), aarch64) arch.c.flags = -mcpu=cortex-a53 # Intel 32 bit, build with SSE and SSE2 instructions else ifneq ($(filter i%86, $(target.arch)),) arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions else ifeq ($(target.arch), x86_64) arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 # if none of the above architectures detected else arch.c.flags = endif #=== flags and paths for Linux ================================================= ifeq ($(system), Linux) prefix = /usr/local libdir := $(prefix)/lib pkglibdir = $(libdir)/pd-externals pdincludepath := $(wildcard /usr/include/pd) extension = pd_linux cpp.flags := -DUNIX c.flags := -fPIC c.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags c.ldlibs := -lc -lm cxx.flags := -fPIC -fcheck-new cxx.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) endif #=== flags and paths for Darwin ================================================ # LLVM-clang doesn't support -fcheck-new, therefore this flag is only used when # compiling with g++. ifeq ($(system), Darwin) pkglibdir = $(HOME)/Library/Pd pdincludepath := $(firstword $(wildcard \ /Applications/Pd*.app/Contents/Resources/src)) extension = pd_darwin cpp.flags := -DUNIX -DMACOSX -I /sw/include c.flags := c.ldflags := -undefined suppress -flat_namespace -bundle c.ldlibs := -lc cxx.ldflags := -undefined suppress -flat_namespace -bundle cxx.ldlibs := -lc shared.extension = dylib shared.ldflags = -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 ifneq ($(filter %g++, $(CXX)),) cxx.flags := -fcheck-new endif ifeq ($(extension), d_fat) arch := i386 x86_64 else arch := $(target.arch) endif ifneq ($(filter -mmacosx-version-min=%, $(cflags)),) version.flag := $(filter -mmacosx-version-min=%, $(cflags)) else version.flag = -mmacosx-version-min=10.6 endif arch.c.flags := $(addprefix -arch , $(arch)) $(version.flag) arch.ld.flags := $(arch.c.flags) endif #=== flags and paths for Windows =============================================== # Standard paths on Windows contain spaces, and GNU make functions treat such # paths as lists, with unintended effects. Therefore we must use shell function # ls instead of make's wildcard when probing for a path, and use double quotes # when specifying a path in a command argument. # Default paths in Mingw / Mingw-w64 environments. 'PROGRAMFILES' is standard # location for builds with native architecture, 'ProgramFiles(x86)' for i686 # builds on x86_64 Windows (detection method by Lucas Cordiviola). Curly braces # required because of parentheses in variable name. ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd ifeq ($(target.arch), i686) programfiles := ${ProgramFiles(x86)} else programfiles := $(PROGRAMFILES) endif pdbinpath := $(programfiles)/Pd/bin pdincludepath := $(programfiles)/Pd/src endif # Store default path to pd.dll in PDBINDIR if the latter is not user-defined. # For include path this is done in the platform-independent paths section below, # but for PDBINDIR it is done here so ld flags can be evaluated as immediate # variables. ifeq ($(system), Windows) ifdef PDDIR PDBINDIR := $(PDDIR)/bin endif PDBINDIR ?= $(pdbinpath) endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) cpp.flags := -DMSW -DNT ifeq ($(target.arch), i686) arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse else ifeq ($(target.arch), x86_64) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 arch.c.flags := -march=core2 -msse -msse2 -msse3 -mfpmath=sse else arch.c.flags = endif extension = dll c.flags := c.ldflags := -static-libgcc -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new cxx.ldflags := -static-libgcc -static-libstdc++ -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" cxx.ldlibs := shared.extension = dll shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" stripflags = --strip-all endif #=== paths ===================================================================== # Platform-dependent default paths are specified above, but overridable. # Path variables in upper case can be defined as make command argument or in the # environment. Variable 'objectsdir' is supported for compatibility with # the build system that pd-l2ork has inherited from pd-extended. PDINCLUDEDIR ?= $(pdincludepath) PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) ifdef PDDIR PDINCLUDEDIR := $(wildcard $(PDDIR)/src) endif # base path where all components of the lib will be installed by default installpath := $(DESTDIR)$(PDLIBDIR)/$(lib.name) # check if include path contains spaces (as is often the case on Windows) # if so, store the path so we can later do checks with it pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR)) #=== accumulated build flags =================================================== # From GNU make docs: 'Users expect to be able to specify CFLAGS freely # themselves.' So we use CFLAGS to define options which are not strictly # required for compilation: optimizations, architecture specifications, and # warnings. CFLAGS can be safely overriden using a make command argument. # Variables cflags, ldflags and ldlibs may be defined in including makefile. optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer warn.flags = -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing # suppress -Wunused-variable & Co if you don't want to clutter a build log ifdef suppress-wunused warn.flags += $(addprefix -Wno-unused-, function parameter value variable) endif CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) # preprocessor flags cpp.flags := -DPD -I "$(PDINCLUDEDIR)" $(cpp.flags) $(CPPFLAGS) # flags for dependency checking (cflags from makefile may define -I options) depcheck.flags := $(cpp.flags) $(cflags) # architecture specifications for linker are overridable by LDFLAGS LDFLAGS := $(arch.ld.flags) # now add the same ld flags to shared dynamic lib shared.ldflags := $(shared.ldflags) $(LDFLAGS) # accumulated flags for C compiler / linker c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS) c.ldlibs := $(c.ldlibs) $(ldlibs) # accumulated flags for C++ compiler / linker cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS) cxx.ldflags := $(cxx.ldflags) $(ldflags) $(LDFLAGS) cxx.ldlibs := $(cxx.ldlibs) $(ldlibs) ################################################################################ ### variables: tools ########################################################### ################################################################################ # aliases so we can later define 'compile-$1' and set 'c' or 'cxx' as argument compile-c := $(CC) compile-cxx := $(CXX) ################################################################################ ### checks ##################################################################### ################################################################################ # At this point most variables are defined. Now do some checks and info's # before rules begin. # print Makefile.pdlibbuilder version before possible termination $(info ++++ info: using Makefile.pdlibbuilder version $(version)) # Terminate if target triplet remained empty, to avoid all sorts of confusing # scenarios and spurious bugs. ifeq ($(target.triplet),) $(error Command "$(CC) -dumpmachine" did not return a target triplet, \ needed for a build. \ Is compiler "$(CC)" installed in your PATH? ($(PATH)). \ Does compiler "$(CC)" support option "-dumpmachine"?) endif # 'forward declaration' of default target, needed to do checks all: # To avoid unpredictable results, make sure the default target is not redefined # by including makefile. ifneq ($(.DEFAULT_GOAL), all) $(error Default target must be 'all'.) endif # find out which target(s) will be made ifdef MAKECMDGOALS goals := $(MAKECMDGOALS) else goals := all endif # store path to Pd API m_pd.h if it is found ifdef PDINCLUDEDIR mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") endif # store path to pd.dll; if not found, ls will give a useful error ifeq ($(system), Windows) pddll := $(shell ls "$(PDBINDIR)/pd.dll") endif # when making target all, check if m_pd.h is found and print info about it ifeq ($(goals), all) $(if $(mpdh), \ $(info ++++ info: using Pd API $(mpdh)), \ $(warning Where is Pd API m_pd.h? Do 'make help' for info.)) endif # print target info $(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name))) # when installing, print installpath info $(if $(filter install install-lib, $(goals)), $(info ++++ info: \ installpath is '$(installpath)')) #=== define executables ======================================================== # By default we build class executables, and optionally a shared dynamic link # lib. When make-lib-executable=yes we build all classes into a single lib # executable, on the condition that variable lib.setup.sources is defined. ifeq ($(make-lib-executable),yes) $(if $(lib.setup.sources), ,\ $(error Can not build library blob because lib.setup.sources is undefined)) executables := $(lib.name).$(extension) else executables := $(classes.executables) $(shared.lib) endif ################################################################################ ### rules: special targets ##################################################### ################################################################################ # Disable built-in rules. If some target can't be built with the specified # rules, it should not be built at all. MAKEFLAGS += --no-builtin-rules .PRECIOUS: .SUFFIXES: .PHONY: all post build-lib \ $(classes) $(makefiledirs) $(makefiles) \ install install-executables install-datafiles install-datadirs \ force clean vars allvars depend help ################################################################################ ### rules: build targets ####################################################### ################################################################################ # Target all forces the build of targets [$(executables) post] in # deterministic order. Target $(executables) builds class executables plus # optional shared lib or alternatively a single lib executable when # make-lib-executable=true. Target post is optionally defined by # library makefile. all: post post: $(executables) all: $(info ++++info: target all in lib $(lib.name) completed) # build all with -g option turned on for debug symbols alldebug: c.flags += -g alldebug: cxx.flags += -g alldebug: all #=== class executable ========================================================== # recipe for linking objects in class executable # argument $1 = compiler type (c or cxx) # argument $2 = class basename define link-class $(compile-$1) \ $($1.ldflags) $($2.class.ldflags) \ -o $2.$(extension) \ $(addsuffix .o, $(basename $($2.class.sources))) \ $(addsuffix .o, $(basename $(common.sources))) \ $($1.ldlibs) $($2.class.ldlibs) $(shared.lib) endef # general rule for linking object files in class executable %.$(extension): $(shared.lib) $(info ++++ info: linking objects in $@ for lib $(lib.name)) $(if $(filter %.cc %.cpp, $($*.class.sources)), \ $(call link-class,cxx,$*), \ $(call link-class,c,$*)) #=== library blob ============================================================== # build all classes into single executable build-lib: $(lib.name).$(extension) $(info ++++ info: library blob $(lib.name).$(extension) completed) # recipe for linking objects in lib executable # argument $1 = compiler type (c or cxx) define link-lib $(compile-$1) \ $($1.ldflags) $(lib.ldflags) \ -o $(lib.name).$(extension) $(all.objects) \ $($1.ldlibs) $(lib.ldlibs) endef # rule for linking objects in lib executable # declared conditionally to avoid name clashes ifeq ($(make-lib-executable),yes) $(lib.name).$(extension): $(all.objects) $(if $(filter %.cc %.cpp, $(all.sources)), \ $(call link-lib,cxx), \ $(call link-lib,c)) endif #=== shared dynamic lib ======================================================== # recipe for linking objects in shared executable # argument $1 = compiler type (c or cxx) define link-shared $(compile-$1) \ $(shared.ldflags) \ -o lib$(lib.name).$(shared.extension) $(shared.objects) \ $($1.ldlibs) $(shared.ldlibs) endef # rule for linking objects in shared executable # build recipe is in macro 'link-shared' lib$(lib.name).$(shared.extension): $(shared.objects) $(info ++++ info: linking objects in shared lib $@) $(if $(filter %.cc %.cpp, $(shared.sources)), \ $(call link-shared,cxx), \ $(call link-shared,c)) #=== object files ============================================================== # recipe to make .o file from source # argument $1 is compiler type (c or cxx) define make-object-file $(info ++++ info: making $@ in lib $(lib.name)) $(compile-$1) \ $($1.flags) \ -o $@ -c $< endef # Three rules to create .o files. These are double colon 'terminal' rules, # meaning they are the last in a rules chain. %.o:: %.c $(call make-object-file,c) %.o:: %.cc $(call make-object-file,cxx) %.o:: %.cpp $(call make-object-file,cxx) #=== explicit prerequisites for class executables ============================== # For class executables, prerequisite rules are declared in run time. Target # 'depend' prints these rules for debugging purposes. # declare explicit prerequisites rule like 'class: class.extension' # argument $v is class basename define declare-class-target $v: $v.$(extension) endef # declare explicit prerequisites rule like 'class.extension: object1.o object2.o' # argument $v is class basename define declare-class-executable-target $v.$(extension): $(addsuffix .o, $(basename $($v.class.sources))) \ $(addsuffix .o, $(basename $(common.sources))) endef # evaluate explicit prerequisite rules for all classes $(foreach v, $(classes), $(eval $(declare-class-target))) $(foreach v, $(classes), $(eval $(declare-class-executable-target))) #=== implicit prerequisites for class executables ============================== # Evaluating implicit prerequisites (header files) with help from the # preprocessor is 'expensive' so this is done conditionally and selectively. # Note that it is also possible to trigger a build via install targets, in # which case implicit prerequisites are not checked. # When the Pd include path contains spaces it will mess up the implicit # prerequisites rules. disable-dependency-tracking := $(strip $(pdincludepathwithspaces)) ifndef disable-dependency-tracking must-build-everything := $(filter all, $(goals)) must-build-class := $(filter $(classes), $(goals)) must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) endif # declare implicit prerequisites rule like 'object.o: header1.h header2.h ...' # argument $1 is input source file(s) # dir is explicitly added because option -MM strips it by default define declare-object-target $(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(depcheck.flags) -MM $1)) $(MAKEFILE_LIST) endef # evaluate implicit prerequisite rules when rebuilding everything ifdef must-build-everything $(if $(wildcard $(all.objects)), \ $(info ++++ info: evaluating implicit prerequisites in lib $(lib.name).....) \ $(foreach v, $(all.sources), $(eval $(call declare-object-target, $v)))) endif # evaluate implicit prerequisite rules when selectively building classes ifdef must-build-class $(foreach v, $(must-build-sources), \ $(eval $(call declare-object-target, $v))) $(foreach v, $(shared.sources), \ $(eval $(call declare-object-target, $v))) endif ################################################################################ ### rules: preprocessor and assembly files ##################################### ################################################################################ # Preprocessor and assembly output files for bug tracing etc. They are not part # of the build processes for executables. By default these files are created in # the current working directory. Dependency tracking is not performed, the build # is forced instead to make sure it's up to date. force: #=== preprocessor file ========================================================= # make preprocessor output file with extension .pre # argument $1 = compiler type (c or cxx) define make-preprocessor-file $(info ++++ info: making preprocessor output file $(notdir $*.pre) \ in current working directory) $(compile-$1) -E $< $(c.flags) $($1.flags) -o $(notdir $*.pre) endef %.pre:: %.c force $(call make-preprocessor-file,c) %.pre:: %.cc force $(call make-preprocessor-file,cxx) %.pre:: %.cpp force $(call make-preprocessor-file,cxx) #=== assembly file ============================================================= # make C / assembly interleaved output file with extension .lst # argument $1 = compiler type (c or cxx) define make-assembly-file $(info ++++ info: making assembly output file $(notdir $*.lst) \ in current working directory) $(compile-$1) \ -c -Wa,-a,-ad -fverbose-asm \ $($1.flags) \ $< > $(notdir $*.lst) endef %.lst:: %.c force $(call make-assembly-file,c) %.lst:: %.cc force $(call make-assembly-file,cxx) %.lst:: %.cpp force $(call make-assembly-file,cxx) ################################################################################ ### rules: installation targets ################################################ ################################################################################ #=== strip ===================================================================== # Stripping of installed binaries will only be done when variable 'stripflags' # is defined non-empty. No default definition is provided except for Windows # where the unstripped binaries are large, especially in the case of Mingw-w64. # Note: while stripping all symbols ('-s' or '--strip-all') is possible for # Linux and Windows, in the case of OSX only non-global symbols can be stripped # (option '-x' or '--discard-all'). # Make definition of strip command overridable so it can be defined in an # environment for cross-compilation. STRIP ?= strip # Commands in 'strip-executables' will be executed conditionally in the rule for # target 'install-executables'. strip-executables = cd "$(installpath)" && \ $(foreach v, $(executables), $(STRIP) $(stripflags) '$v';) #=== install =================================================================== # Install targets depend on successful exit status of target all because nothing # must be installed in case of a build error. # -p = preserve time stamps # -m = set permission mode (as in chmod) # -d = create all components of specified directories INSTALL = install INSTALL_PROGRAM := $(INSTALL) -p -m 644 INSTALL_DATA := $(INSTALL) -p -m 644 INSTALL_DIR := $(INSTALL) -m 755 -d # strip spaces from file names executables := $(strip $(executables)) datafiles := $(strip $(datafiles)) datadirs := $(strip $(datadirs)) # Do not make any install sub-target with empty variable definition because the # install program would exit with an error. install: $(if $(executables), install-executables) install: $(if $(datafiles), install-datafiles) install: $(if $(datadirs), install-datadirs) install-executables: all $(INSTALL_DIR) -v "$(installpath)" $(foreach v, $(executables), \ $(INSTALL_PROGRAM) '$v' "$(installpath)";) $(info ++++ info: executables of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) $(if $(stripflags), $(strip-executables),) install-datafiles: all $(INSTALL_DIR) -v "$(installpath)" $(foreach v, $(datafiles), \ $(INSTALL_DATA) '$(v)' "$(installpath)";) $(info ++++ info: data files of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) install-datadirs: all $(foreach v, $(datadirs), $(INSTALL_DIR) "$(installpath)/$v";) $(foreach v, $(datadirs), \ $(INSTALL_DATA) $(wildcard $v/*) "$(installpath)/$v";) $(info ++++ info: data directories of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) ################################################################################ ### rules: distribution targets ################################################ ################################################################################ # TODO # These targets are implemented in Makefile Template, but I have to figure out # how to do it under the not-so-strict conditions of Makefile.pdlibbuilder. # make source package dist: @echo "target dist not yet implemented" # make Debian source package dpkg-source: @echo "target dpkg-source not yet implemented" $(ORIGDIR): $(DISTDIR): ################################################################################ ### rules: clean targets ####################################################### ################################################################################ # delete build products from build tree clean: rm -f $(all.objects) rm -f $(classes.executables) $(lib.name).$(extension) $(shared.lib) rm -f *.pre *.lst # remove distribution directories and tarballs from build tree distclean: clean @echo "target distclean not yet implemented" ################################################################################ ### rules: submake targets ##################################################### ################################################################################ # Iterate over sub-makefiles or makefiles in other directories. # When 'continue-make=yes' is set, sub-makes will report 'true' to the parent # process regardless of their real exit status. This prevents the parent make # from being aborted by a sub-make error. Useful when you want to quickly find # out which sub-makes from a large set will succeed. ifeq ($(continue-make),yes) continue = || true endif # These targets will trigger sub-make processes for entries in 'makefiledirs' # and 'makefiles'. all alldebug install clean distclean dist dkpg-source: \ $(makefiledirs) $(makefiles) # this expands to identical rules for each entry in 'makefiledirs' $(makefiledirs): $(MAKE) --directory=$@ $(MAKECMDGOALS) $(continue) # this expands to identical rules for each entry in 'makefiles' $(makefiles): $(MAKE) --directory=$(dir $@) --makefile=$(notdir $@) $(MAKECMDGOALS) $(continue) ################################################################################ ### rules: convenience targets ################################################# ################################################################################ #=== show variables ============================================================ # Several 'function' macro's cause errors when expanded within a rule or without # proper arguments. Variables which are set with the define directive are only # shown by name for that reason. functions = \ add-class-source \ declare-class-target \ declare-class-executable-target \ declare-object-target \ link-class \ link-lib \ link-shared \ make-object-file \ make-preprocessor-file \ make-assembly-file # show variables from makefiles vars: $(info ++++ info: showing makefile variables:) $(foreach v,\ $(sort $(filter-out $(functions) functions, $(.VARIABLES))),\ $(if $(filter file, $(origin $v)),\ $(info variable $v = $($v)))) $(foreach v, $(functions), $(info 'function' name: $v)) @echo # show all variables allvars: $(info ++++ info: showing default, automatic and makefile variables:) $(foreach v, \ $(sort $(filter-out $(functions) functions, $(.VARIABLES))), \ $(info variable ($(origin $v)) $v = $($v))) $(foreach v, $(functions), $(info 'function' name: $v)) @echo #=== show dependencies ========================================================= # show generated prerequisites rules depend: $(info ++++ info: generated prerequisite rules) $(foreach v, $(classes), $(info $(declare-class-target))) $(foreach v, $(classes), $(info $(declare-class-executable-target))) $(foreach v, $(all.sources), $(info $(call declare-object-target, $v))) @echo #=== show help text ============================================================ # brief info about targets and paths ifdef mpdh mpdhinfo := $(mpdh) else mpdhinfo := m_pd.h was not found. Is Pd installed? endif help: @echo @echo " Main targets:" @echo " all: build executables (default target)" @echo " install: install all components of the library" @echo " vars: print makefile variables for troubleshooting" @echo " allvars: print all variables for troubleshooting" @echo " help: print this help text" @echo @echo " Pd API m_pd.h:" @echo " $(mpdhinfo)" @echo " You may specify your preferred Pd include directory as argument" @echo " to the make command, like 'PDINCLUDEDIR=path/to/pd/src'." @echo @echo " Path for installation of your libdir(s):" @echo " $(PDLIBDIR)" @echo " Alternatively you may specify your path for installation as argument" @echo " to the make command, like 'PDLIBDIR=path/to/pd-externals'." @echo @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder." @echo #=== platform test ============================================================= # This target can be used to test if the compiler for specified PLATFORM is # correctly defined and available. dumpmachine: @$(CC) -dumpmachine #=== dummy target ============================================================== coffee: @echo "Makefile.pdlibbuilder: Can not make coffee. Sorry." ################################################################################ ### end of rules sections ###################################################### ################################################################################ # for syntax highlighting in vim and github # vim: set filetype=make: ggee-0.28/pd-lib-builder/README.md000066400000000000000000000102421402462307700164300ustar00rootroot00000000000000 ### Makefile.pdlibbuilder ### Helper makefile for Pure Data external libraries. Written by Katja Vetter March-June 2015 for the public domain and since then developed as a Pd community project. No warranties. Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's ShakeNMake. GNU make version >= 3.81 required. ### characteristics ### * defines build settings based on autodetected target platform * defines rules to build Pd class- or lib executables from C or C++ sources * defines rules for libdir installation * defines convenience targets for developer and user * evaluates implicit dependencies for non-clean builds ### basic usage ### In your Makefile, define your Pd lib name and class files, and include Makefile.pdlibbuilder at the end of the Makefile. Like so: # Makefile for mylib lib.name = mylib class.sources = myclass1.c myclass2.c datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt include Makefile.pdlibbuilder For files in class.sources it is assumed that class name == source file basename. The default target builds all classes as individual executables with Pd's default extension for the platform. For anything more than the most basic usage, read the documentation sections in Makefile.pdlibbuilder. ### paths ### Makefile.pdlibbuilder >= v0.4.0 supports pd path variables which can be defined not only as make command argument but also in the environment, to override platform-dependent defaults: PDDIR: Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. PDINCLUDEDIR: Directory where Pd API m_pd.h should be found, and other Pd header files. Overrides the default search path. PDBINDIR: Directory where pd.dll should be found for linking (Windows only). Overrides the default search path. PDLIBDIR: Root directory for installation of Pd library directories. Overrides the default install location. ### documentation ### This README.md provides only basic information. A large comment section inside Makefile.pdlibbuilder lists and explains the available user variables, default paths, and targets. The internal documentation reflects the exact functionality of the particular version. For suggestions about project maintenance and advanced compilation see tips-tricks.md. ### versioning ### The project is versioned in MAJOR.MINOR.BUGFIX format (see http://semver.org), and maintained at https://github.com/pure-data/pd-lib-builder. Pd lib developers are invited to regulary check for updates, and to contribute and discuss improvements here. If you really need to distribute a personalized version with your library, rename Makefile.pdlibbuilder to avoid confusion. ### examples ### The list of projects using pd-lib-builder can be helpful if you are looking for examples, from the simplest use case to more complex implementations. - helloworld: traditional illustration of simplest use case - pd-windowing: straightforward real world use case of a small library - pd-nilwind / pd-cyclone: more elaborate source tree - zexy: migrated from autotools to pd-lib-builder ### projects using pd-lib-builder ### non-exhaustive list https://github.com/pure-data/helloworld https://github.com/electrickery/pd-nilwind https://github.com/electrickery/pd-maxlib https://github.com/electrickery/pd-sigpack https://github.com/electrickery/pd-tof https://github.com/electrickery/pd-windowing https://github.com/electrickery/pd-smlib https://github.com/porres/pd-cyclone https://github.com/porres/pd-else https://github.com/porres/pd-psycho https://git.iem.at/pd/comport https://git.iem.at/pd/hexloader https://git.iem.at/pd/iemgui https://git.iem.at/pd/iemguts https://git.iem.at/pd/iemlib https://git.iem.at/pd/iemnet https://git.iem.at/pd/iem_ambi https://git.iem.at/pd/iem_tab https://git.iem.at/pd/iem_adaptfilt https://git.iem.at/pd/iem_roomsim https://git.iem.at/pd/iem_spec2 https://git.iem.at/pd/mediasettings https://git.iem.at/pd/zexy https://git.iem.at/pd-gui/punish https://github.com/residuum/PuRestJson https://github.com/libpd/abl_link https://github.com/wbrent/timbreID https://github.com/MetaluNet/moonlib ggee-0.28/pd-lib-builder/tips-tricks.md000066400000000000000000000162561402462307700177620ustar00rootroot00000000000000pd-lib-builder cheatsheet ========================= # Creating special builds ## cross-compiling on linux x86_64 for other platforms Using pd-lib-builder >=0.6.0 we can define variable `PLATFORM` to specify a target triplet for cross-compilation. Example to build W32 binaries (assuming package `mingw-w64` is installed and a W32 package for Pd is unzipped into a path `${PDWIN32}`: make PLATFORM=x86_64-w64-mingw32 PDDIR="${PDWIN32}" #### older pd-lib-builder versions Using pd-lib-builder < 0.6.0, in the absence of variable `PLATFORM`, you would instead override variables `system`, `target.arch`, `CC` and / or `CXX`, `STRIP`. Example: make system=Windows target.arch=i686 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip PDDIR="${PDWIN32}" #### toolchains Cross toolchains for relevant platforms in Debian Buster (install g++ with dependencies for a given platform to get the whole tool chain): - `arm-linux-gnueabihf` - `aarch64-linux-gnu` - `i686-linux-gnu` - `i686-w64-mingw32` and `x86_64-w64-mingw32` (install `mingw-w64`) OSX/MacOS cross tool chains are not distributed by Debian. Use project `osxcross` from Thomas Poechtraeger to create the tools. ## building double-precision externals At the time of writing (2018-02) there is no official Pd that supports double-precision numbers yet. However, if you do get hold of an experimental double-precision Pd, you can easily build your externals for 64-bit numbers: make CPPFLAGS="-DPD_FLOATSIZE=64" ## building externals for W64 (64-bit Windows) At the time of writing (2018-02) there is no official Pd that supports W64 yet. However, if you do get hold of an experimental W64 Pd, you can easily build your externals for this environment with make CPPFLAGS="-DPD_LONGINTTYPE=__int64" CC=x86_64-w64-mingw32-gcc To build a double-precision external for W64, use something like: make CPPFLAGS="-DPD_LONGINTTYPE=__int64 -DPD_FLOATSIZE=64" CC=x86_64-w64-mingw32-gcc ## TODO universal binaries on OSX # Project management In general it is advised to put the `Makefile.pdlibbuilder` into a separate subdirectory (e.g. `pd-lib-builder/`). This makes it much easier to update the `Makefile.pdlibbuilder` later You *should* also use a variable to the actual path of the Makefile.pdlibbuilder (even if you keep it in the root-directory), as this allows easy experimenting with newer (or older) (or site-specific) versions of the pd-lib-builder Makefile. ~~~make PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder ~~~ ## Keeping pd-lib-builder up-to-date ### `git subtree` With git-subtrees, you make the pd-lib-builder repository (or any other repository for that matter) part of your own repository - with full history and everything - put nicely into a distinct subdirectory. Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). The nice thing however is, that from "outside" the subtree is part of your repository like any other directory. E.g. older versions of Git can clone your repository with the full subtree (and all it's history) just fine. You can also use git-archive to make a complete snapshot of your repository (including the subtree) - nice, if you e.g. want self-contained downloads of your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) In short, `git subtree` is the better `git submodule`. So here's how to do it: #### Initial setup/check-out This will create a `pd-lib-builder/` directory containing the full history of the pd-lib-builder repository up to its release `v0.5.0` ~~~sh git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 ~~~ This will automatically merge the `pd-lib-builder/` history into your current branch, so everything is ready to go. #### Cloning your repository with the subtree Nothing special, really. Just clone your repository as always: ~~~sh git clone https://git.example.org/pd/superbonk~.git ~~~ #### Updating the subtree Time passes and sooner or later you will find, that there is a shiny new pd-lib-builder with plenty of bugfixes and new features. To update your local copy to pd-lib-builder's current `master`, simply run: ~~~sh git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master ~~~ #### Pulling the updated subtree into existing clones Again, nothing special. Just pull as always: ~~~sh git pull ~~~ #### Further reading More on the power of `git subtree` can be found online - https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 - https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree - ... ### ~~`git submodule`~~ [DISCOURAGED] #### Initial setup/check-out To add a new submodule to your repository, just run `git submodule add` and commit the changes: ~~~sh git submodule add https://github.com/pure-data/pd-lib-builder git commit .gitmodules pd-lib-builder/ -m "Added pd-lib-builder as git-submodule" ~~~ #### Cloning your repository with the submodule When doing a fresh clone of your repository, pass the `--recursive` option to automatically fetch all submodules: ~~~sh git clone --recursive https://git.example.org/pd/superbonk~.git ~~~ If you've cloned non-recursively, you can initialize and update the submodules manually: ~~~sh git submodule init git submodule update ~~~ #### Updating the submodule Submodules are usually fixed to a given commit in their repository. To update the `pd-lib-builder` submodule to the current `master` do something like: ~~~sh cd pd-lib-builder git checkout master git pull cd .. git status pd-lib-builder git commit pd-lib-builder -m "Updated pd-lib-builder to current master" ~~~ #### Pulling the updated submodule into existing clones After you have pushed the submodule updates in your repository, other clones of the repository can be updated as follows: ~~~sh git pull ~~~ The above will make your repository aware, that the submodule is out-of-sync. ~~~sh $ LANG=C git status pd-lib-builder On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: pd-lib-builder (new commits) $ ~~~ In order to sync the submodule to the correct commit, run the following: ~~~sh git submodule update ~~~ #### Drawbacks `git submodule` has a number of drawbacks: - it requires special commands to synchronize the submodules, in addition to synching your repository. - you must make sure to use an URL for the submodule that is accessible to your potential users. e.g. using `git@github.com:pure-data/pd-lib-builder` is bad, because it requires everybody who wants to checkout your sources to have a github-account - even if they could checkout *your* repository anonymously. - submodules will be excluded from `git archive`. This means, that if you use a mainstream git provider (like Github, GitLab, Bitbucket,...) and make releases by creating a `git tag`, the automatically generated zipfiles with the sources will lack the submodule - and your users will not be able to compile your source code. In general, I would suggest to **avoid** `git submodule`, and instead use the better `git subtree` (above). ggee-0.28/signal/000077500000000000000000000000001402462307700136345ustar00rootroot00000000000000ggee-0.28/signal/atan2~-help.pd000066400000000000000000000011531402462307700163120ustar00rootroot00000000000000#N canvas 0 26 500 184 10; #X obj 33 88 atan2~; #X text 30 121 (C) Guenter Geiger; #X text 30 18 The atan2 function is used to get the phase from a imaginary value of the fft.; #N canvas 46 242 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 5 KEYWORDS signal trigonometry; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION get the phase from a imaginary value of the fft; #X text 12 65 INLET_0 signal; #X text 12 85 INLET_1 signal; #X text 12 105 OUTLET_0 signal; #X restore 440 153 pd META; ggee-0.28/signal/atan2~.c000066400000000000000000000043121402462307700152030ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include "math.h" #include /* ----------------------------- atan2 ----------------------------- */ static t_class *atan2_class; #define INVTWOPI 0.15915494f typedef struct _atan2 { t_object x_obj; } t_atan2; static void *atan2_new(t_symbol *s, int argc, t_atom *argv) { if (argc > 1) post("+~: extra arguments ignored"); { t_atan2 *x = (t_atan2 *)pd_new(atan2_class); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, &s_signal); return (x); } } t_int *atan2_perform(t_int *w) { t_float *in1 = (t_float *)(w[1]); t_float *in2 = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); while (n--) *out++ = (t_float) atan2(*in1++,*in2++) *INVTWOPI; return (w+5); } t_int *atan2_perf8(t_int *w) { t_float *in1 = (t_float *)(w[1]); t_float *in2 = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); for (; n; n -= 8, in1 += 8, in2 += 8, out += 8) { float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3]; float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7]; float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3]; float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7]; out[0] = (t_float) atan2(f0,g0)*INVTWOPI; out[1] = (t_float) atan2(f1,g1)*INVTWOPI; out[2] = (t_float) atan2(f2,g2)*INVTWOPI; out[3] = (t_float) atan2(f3,g3)*INVTWOPI; out[4] = (t_float) atan2(f4,g4)*INVTWOPI; out[5] = (t_float) atan2(f5,g5)*INVTWOPI; out[6] = (t_float) atan2(f6,g6)*INVTWOPI; out[7] = (t_float) atan2(f7,g7)*INVTWOPI; } return (w+5); } void dsp_add_atan2(t_sample *in1, t_sample *in2, t_sample *out, int n) { if (n&7) dsp_add(atan2_perform, 4, in1, in2, out, n); else dsp_add(atan2_perf8, 4, in1, in2, out, n); } static void atan2_dsp(t_atan2 *x, t_signal **sp) { dsp_add_atan2(sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } void atan2_tilde_setup(void) { atan2_class = class_new(gensym("atan2~"), (t_newmethod)atan2_new, 0, sizeof(t_atan2), 0, A_GIMME, 0); class_addmethod(atan2_class, nullfn, gensym("signal"), 0); class_addmethod(atan2_class, (t_method)atan2_dsp, gensym("dsp"), 0); } ggee-0.28/signal/mixer~-help.pd000066400000000000000000000052521402462307700164350ustar00rootroot00000000000000#N canvas 0 26 610 404 10; #X obj 163 120 osc~ 220; #X obj 186 297 dac~; #X obj 163 140 *~ 0.1; #X obj 217 120 osc~ 220; #X obj 217 140 *~ 0.1; #X obj 272 120 osc~ 220; #X obj 272 140 *~ 0.1; #X obj 325 120 osc~ 220; #X obj 325 140 *~ 0.1; #X floatatom 217 97 0 0 0 0 - - -; #X floatatom 273 98 0 0 0 0 - - -; #X floatatom 326 95 0 0 0 0 - - -; #X floatatom 166 96 0 0 0 0 - - -; #X msg 106 175 1 \$1; #X msg 104 198 2 \$1; #X msg 104 221 3 \$1; #X floatatom 58 114 0 0 0 0 - - -; #X floatatom 58 153 0 0 0 0 - - -; #X floatatom 59 201 0 0 0 0 - - -; #X floatatom 59 84 0 0 0 0 - - -; #X msg 105 143 0 \$1; #X obj 196 246 mixer~ 20 --------------------------------------; #X obj 386 119 osc~ 220; #X obj 386 139 *~ 0.1; #X obj 440 119 osc~ 220; #X obj 440 139 *~ 0.1; #X obj 495 119 osc~ 220; #X obj 495 139 *~ 0.1; #X obj 548 119 osc~ 220; #X obj 548 139 *~ 0.1; #X floatatom 440 96 0 0 0 0 - - -; #X floatatom 496 97 0 0 0 0 - - -; #X floatatom 549 94 0 0 0 0 - - -; #X floatatom 389 95 0 0 0 0 - - -; #X floatatom 55 251 0 0 0 0 - - -; #X floatatom 55 290 0 0 0 0 - - -; #X floatatom 56 338 0 0 0 0 - - -; #X floatatom 56 221 0 0 0 0 - - -; #X msg 102 280 4 \$1; #X msg 103 312 5 \$1; #X msg 101 335 6 \$1; #X msg 101 358 7 \$1; #X text 57 7 The beginnig of a dynamic mixer matrix object \, implemented together with Oswald; #N canvas 440 303 494 344 META 0; #X text 12 5 GENRE help; #X text 12 175 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 45 LICENSE Tcl/Tk; #X text 12 155 AUTHOR Guenter Geiger; #X text 12 25 KEYWORDS signal; #X text 12 65 DESCRIPTION The beginning of a dynamic mixer matrix object \, implemented together with Oswald; #X text 12 95 INLET_0 list signal; #X text 12 115 INLET_N signal; #X text 12 135 OUTLET_0 signal; #X restore 560 383 pd META; #X connect 0 0 2 0; #X connect 2 0 21 0; #X connect 3 0 4 0; #X connect 4 0 21 1; #X connect 5 0 6 0; #X connect 6 0 21 2; #X connect 7 0 8 0; #X connect 8 0 21 3; #X connect 9 0 3 0; #X connect 10 0 5 0; #X connect 11 0 7 0; #X connect 12 0 0 0; #X connect 13 0 21 0; #X connect 14 0 21 0; #X connect 15 0 21 0; #X connect 16 0 13 0; #X connect 17 0 14 0; #X connect 18 0 15 0; #X connect 19 0 20 0; #X connect 20 0 21 0; #X connect 21 0 1 0; #X connect 21 0 1 1; #X connect 22 0 23 0; #X connect 23 0 21 4; #X connect 24 0 25 0; #X connect 25 0 21 5; #X connect 26 0 27 0; #X connect 27 0 21 6; #X connect 28 0 29 0; #X connect 29 0 21 7; #X connect 30 0 24 0; #X connect 31 0 26 0; #X connect 32 0 28 0; #X connect 33 0 22 0; #X connect 34 0 39 0; #X connect 35 0 40 0; #X connect 36 0 41 0; #X connect 37 0 38 0; #X connect 38 0 21 0; #X connect 39 0 21 0; #X connect 40 0 21 0; #X connect 41 0 21 0; ggee-0.28/signal/mixer~.c000066400000000000000000000037631402462307700153330ustar00rootroot00000000000000/* (C) Oswald Berthold */ #include "math.h" #include /* ----------------------------- mixer ----------------------------- */ static t_class *mixer_class; typedef struct _mixer { t_object x_obj; t_int x_n; t_float* x_m; } t_mixer; static void *mixer_new(t_symbol *s, t_floatarg num) { int i; t_mixer *x = (t_mixer *)pd_new(mixer_class); if (num < 1) x->x_n = 1; else x->x_n = (int) num; x->x_m = getbytes(sizeof(t_float)*x->x_n); for (i=0;ix_n /* - 1 */ ;i++) { inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); x->x_m[i] = 1.; } outlet_new(&x->x_obj, &s_signal); return (x); } void mixer_list(t_mixer* x,t_symbol* s,t_int argc, t_atom* argv) { int chan; t_float val; if (argc != 2) { post("unknown"); return; } chan = (int) atom_getfloat(argv++); val = atom_getfloat(argv++); x->x_m[chan] = val; } t_int *mixer_perform(t_int *w) { t_mixer* x = (t_mixer*) (w[1]); int n = (int)(w[2]); t_float **in = getbytes(sizeof(float)*x->x_n); t_float *out; int i,j; int offset = 3; for (i=0;i < x->x_n;i++) { in[i] = (t_float *)(w[offset+i]); } out = (t_float *)(w[offset+i]); while (n--) { *out = 0.; for (j=0;jx_n;j++) { *out += *(in[j]++) * x->x_m[j]; } out++; } return (w+offset+1+i); } static void mixer_dsp(t_mixer *x, t_signal **sp) { int i; t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 3)); myvec[0] = (t_int*)x; myvec[1] = (t_int*)sp[0]->s_n; for (i=0;i < x->x_n+1;i++) myvec[2 + i] = (t_int*)sp[i]->s_vec; dsp_addv(mixer_perform, x->x_n + 3, (t_int*)myvec); freebytes(myvec,sizeof(t_int)*(x->x_n + 3)); } void mixer_tilde_setup(void) { mixer_class = class_new(gensym("mixer~"), (t_newmethod)mixer_new, 0, sizeof(t_mixer), 0, A_DEFFLOAT, A_DEFSYM,A_NULL); class_addmethod(mixer_class, nullfn, gensym("signal"), 0); class_addmethod(mixer_class, (t_method)mixer_dsp, gensym("dsp"), 0); class_addlist(mixer_class,mixer_list); } ggee-0.28/signal/sfwrite~-help.pd000066400000000000000000000026421402462307700167740ustar00rootroot00000000000000#N canvas 1 88 477 431 12; #X obj 185 96 sfwrite~ 2; #X msg 65 16 open test.wav; #X floatatom 185 16 0 0 0 0 - - -; #X msg 147 308 0; #X obj 232 17 adc~; #X msg 91 278 0; #X msg 59 278 1; #X obj 142 222 table; #X msg 136 171 bang; #X msg 32 171 resize 441000; #X msg 181 172 read16 test.wav 200 l; #X obj 417 104 env~; #X obj 298 34 osc~ 220; #X obj 125 396 dac~; #X floatatom 411 10 0 0 0 0 - - -; #X obj 125 341 sfread~ 2; #X obj 281 379 dbtorms; #X obj 281 279 slider 96 0 15; #X obj 159 372 *~ 0; #X obj 125 372 *~ 0; #X msg 125 277 open test.wav \, bang; #X floatatom 417 129 0 0 0 0 - - -; #N canvas 371 280 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 145 AUTHOR Guenter Geiger; #X text 12 45 DESCRIPTION needs a description; #X text 12 65 INLET_0 open float; #X text 12 85 INLET_1 float; #X text 12 105 OUTLET_0 signal; #X text 12 125 OUTLET_1 signal; #X text 12 5 KEYWORDS signal; #X restore 421 406 pd META; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 3 0 15 1; #X connect 5 0 15 0; #X connect 6 0 15 0; #X connect 11 0 21 0; #X connect 12 0 0 0; #X connect 12 0 0 1; #X connect 12 0 11 0; #X connect 12 0 19 0; #X connect 12 0 18 0; #X connect 14 0 12 0; #X connect 15 0 19 0; #X connect 15 1 18 0; #X connect 16 0 18 1; #X connect 16 0 19 1; #X connect 18 0 13 1; #X connect 19 0 13 0; #X connect 20 0 15 0; ggee-0.28/signal/sfwrite~.c000066400000000000000000000145701402462307700156700ustar00rootroot00000000000000/* (C) Guenter Geiger */ #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #include #include #ifndef _WIN32 #include #include #else #include #endif #include #include #ifdef _WIN32 #define BINREADMODE "rb" #define OPENPARAMS O_WRONLY | O_CREAT | O_TRUNC #else #define BINREADMODE "r" #define OPENPARAMS O_WRONLY | O_CREAT | O_NONBLOCK | O_TRUNC #endif #define MAX_CHANS 4 /* * ------------------------------------------- sfwrite~ ------------------------------- */ #define BLOCKTIME 0.01 #define uint32 unsigned int #define uint16 unsigned short static t_class *sfwrite_class; typedef struct _sfwrite { t_object x_obj; t_symbol* filename; int x_file; t_int rec; t_int x_channels; uint32 size; t_glist * x_glist; t_int x_blocked; t_int x_blockwarn; } t_sfwrite; typedef struct _wave { char w_fileid[4]; /* chunk id 'RIFF' */ uint32 w_chunksize; /* chunk size */ char w_waveid[4]; /* wave chunk id 'WAVE' */ char w_fmtid[4]; /* format chunk id 'fmt ' */ uint32 w_fmtchunksize; /* format chunk size */ uint16 w_fmttag; /* format tag, 1 for PCM */ uint16 w_nchannels; /* number of channels */ uint32 w_samplespersec; /* sample rate in hz */ uint32 w_navgbytespersec; /* average bytes per second */ uint16 w_nblockalign; /* number of bytes per sample */ uint16 w_nbitspersample; /* number of bits in a sample */ char w_datachunkid[4]; /* data chunk id 'data' */ uint32 w_datachunksize; /* length of data chunk */ } t_wave; static void sfwrite_wave_setup(t_sfwrite* x,t_wave* w) { strncpy(w->w_fileid,"RIFF",4); /* chunk id 'RIFF' */ w->w_chunksize = x->size + sizeof(t_wave) -8;/* chunk size */ strncpy(w->w_waveid,"WAVE",4); /* wave chunk id 'WAVE' */ strncpy(w->w_fmtid,"fmt ",4); /* format chunk id 'fmt ' */ w->w_fmtchunksize = 16; /* format chunk size */ w->w_fmttag = 1; /* format tag, 1 for PCM */ w->w_nchannels = x->x_channels; /* number of channels */ w->w_samplespersec = 44100; /* sample rate in hz */ w->w_navgbytespersec = 44100*x->x_channels*2;/* average bytes per second */ w->w_nblockalign = 4; /* number of bytes per sample */ w->w_nbitspersample = 16; /* number of bits in a sample */ strncpy(w->w_datachunkid,"data",4); /* data chunk id 'data' */ w->w_datachunksize = x->size; /* length of data chunk */ } static void sfwrite_close(t_sfwrite *x) { if (x->x_file > 0) { t_wave w; sfwrite_wave_setup(x,&w); lseek(x->x_file,0,SEEK_SET); write(x->x_file,&w,sizeof(w)); close(x->x_file); } x->x_file = -1; } static void sfwrite_open(t_sfwrite *x,t_symbol *filename) { char fname[MAXPDSTRING]; if (filename == &s_) { post("sfwrite: open without filename"); return; } canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name, fname, MAXPDSTRING); x->x_blocked = 0; x->filename = filename; post("sfwrite: filename = %s",x->filename->s_name); sfwrite_close(x); if ((x->x_file = open(fname,OPENPARAMS,0664)) < 0) { error("can't create %s",fname); return; } /* skip the header */ lseek(x->x_file,sizeof(t_wave),SEEK_SET); x->size = 0; } static void sfwrite_block(t_sfwrite *x, t_floatarg f) { x->x_blockwarn = f; } static void sfwrite_float(t_sfwrite *x, t_floatarg f) { int t = f; if (t) { post("sfwrite: start", f); x->rec=1; } else { post("sfwrite: stop", f); x->rec=0; } } static short out[4*64]; static t_int *sfwrite_perform(t_int *w) { t_sfwrite* x = (t_sfwrite*)(w[1]); t_float * in[4]; int c = x->x_channels; int i,num,n; short* tout = out; int ret; double timebefore,timeafter; double late; for (i=0;i < c;i++) { in[i] = (t_float *)(w[2+i]); } n = num = (int)(w[2+c]); /* loop */ if (x->rec && x->x_file) { while (n--) { for (i=0;ix_file,out,sizeof(short)*num*c)) < (signed int)sizeof(short)*num*c) { post("sfwrite: short write %d",ret); } timeafter = sys_getrealtime(); late = timeafter - timebefore; /* OK, we let only 10 ms block here */ if (late > BLOCKTIME && x->x_blockwarn) { post("sfwrite blocked %f ms",late*1000); x->x_blocked++; if (x->x_blocked > x->x_blockwarn) { x->rec = 0; post("maximum blockcount %d reached, recording stopped (set blockcount with \"block \"",x->x_blockwarn); } } x->size +=64*x->x_channels*sizeof(short) ; } return (w+3+c); } static void sfwrite_dsp(t_sfwrite *x, t_signal **sp) { switch (x->x_channels) { case 1: dsp_add(sfwrite_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); break; case 2: dsp_add(sfwrite_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); break; case 4: dsp_add(sfwrite_perform, 6, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n); break; } } static void sfwrite_free(t_sfwrite* x) { sfwrite_close(x); } static void *sfwrite_new(t_floatarg chan) { t_sfwrite *x = (t_sfwrite *)pd_new(sfwrite_class); t_int c = chan; if (c<1 || c > MAX_CHANS) c = 1; x->x_glist = (t_glist*) canvas_getcurrent(); x->x_channels = c--; x->x_file=0; x->rec = 0; x->size = 0; x->x_blocked = 0; x->x_blockwarn = 10; while (c--) { inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); } return (x); } void sfwrite_tilde_setup(void) { sfwrite_class = class_new(gensym("sfwrite~"), (t_newmethod)sfwrite_new, (t_method)sfwrite_free, sizeof(t_sfwrite), 0,A_DEFFLOAT,0); class_addmethod(sfwrite_class,nullfn,gensym("signal"), 0); class_addmethod(sfwrite_class, (t_method) sfwrite_dsp, gensym("dsp"), 0); class_addmethod(sfwrite_class, (t_method) sfwrite_open, gensym("open"), A_SYMBOL,A_NULL); class_addmethod(sfwrite_class, (t_method) sfwrite_close, gensym("close"), 0); class_addmethod(sfwrite_class, (t_method)sfwrite_block,gensym("block"),A_DEFFLOAT,0); class_addfloat(sfwrite_class, sfwrite_float); } ggee-0.28/signal/stream.h000066400000000000000000000033371402462307700153060ustar00rootroot00000000000000/* (C) Guenter Geiger 1999 */ /*! * \file * \author Guenter Geiger * * \brief Definitions used by both streamin~ and streamout~ * * \todo This code does not honor network byte order. */ #ifndef __PD_STREAM_H #define __PD_STREAM_H #include /*! * \brief Format identifiers for frames */ enum tag_format { SF_FLOAT = 1, SF_DOUBLE = 2, SF_8BIT = 10, SF_16BIT = 11, SF_32BIT = 12, SF_ALAW = 20, SF_MP3 = 30 }; #define SF_SIZEOF(a) (a == SF_FLOAT ? sizeof(t_float) : a == SF_16BIT ? sizeof(short) : 1) #ifdef __GNUC__ #define PACKED __attribute__ ((packed)) #endif /*! * \brief 16-byte frame header * * \note Version 1 */ typedef struct _tag { /*! Frame header version. Currently ignored in streamin, but always set * to 1 for streamout. * * \todo Add version checking on incoming frames. However, this could * break existing uses of the external. */ char version; /*! This field identifies the type of data is in the frame payload */ char format; /*! ??? */ int32_t count; /*! ??? */ char channels; /*! This indicates the full size of the frame. It is basically * ( sizeof(t_tag) + payload length ). */ int32_t framesize; /*! ??? */ char extension[5]; } PACKED t_tag; /*! * \brief A complete frame */ typedef struct _frame { /*! This is the frame header that contains the metadata about the frame */ t_tag tag; /*! This buffer stores the frame data payload. The amount of data in this * buffer is the tag.framesize - sizeof(t_tag). Its contents can be * interpreted according to the tag.version. */ char *data; } t_frame; #endif /* __PD_STREAM_H */ ggee-0.28/signal/streamin~-help.pd000066400000000000000000000033071402462307700171320ustar00rootroot00000000000000#N canvas 1 88 470 459 12; #X obj 45 133 print~; #X msg 45 105 bang; #X obj 23 62 streamin~ 3000; #X obj 132 210 streamout~; #X msg 132 108 disconnect; #X obj 371 87 osc~; #X obj 371 65 sig~ 220; #X floatatom 371 42 0 0 0 0 - - -; #X msg 285 162 format float; #X msg 284 184 format 16bit; #X text 14 432 (C) 1999 Guenter Geiger; #X msg 286 204 format 8bit; #X floatatom 132 235 0 0 0 0 - - -; #X text 21 295 The streamin~ object just takes the portnumber it is listening to as it's argument.; #X text 23 334 For help on the streamout object \, see the streamout.pd patch.; #X obj 23 197 dac~; #X obj 355 115 *~ 0.1; #X floatatom 418 88 0 0 0 0 - - -; #X floatatom 149 159 0 0 0 0 - - -; #X msg 285 252 connect gige 3001; #X msg 132 86 connect localhost 3000; #X msg 23 8 reset 4; #X msg 40 32 print; #X text 96 8 reset \, using n frames (default = 128); #X text 96 32 print queue info; #N canvas 457 240 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 125 AUTHOR Guenter Geiger; #X text 12 85 INLET_0 signal reset print connect disconnect format ; #X text 12 105 OUTLET_0 signal; #X text 12 5 KEYWORDS signal network; #X text 12 45 DESCRIPTION takes the port number it is listening to as its argument; #X restore 413 436 pd META; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 2 0 15 0; #X connect 2 0 15 1; #X connect 3 0 12 0; #X connect 4 0 3 0; #X connect 5 0 16 0; #X connect 6 0 5 0; #X connect 7 0 6 0; #X connect 8 0 3 0; #X connect 9 0 3 0; #X connect 11 0 3 0; #X connect 16 0 3 0; #X connect 17 0 16 1; #X connect 18 0 3 0; #X connect 19 0 3 0; #X connect 20 0 3 0; #X connect 21 0 2 0; #X connect 22 0 2 0; ggee-0.28/signal/streamin~.c000066400000000000000000000206051402462307700160230ustar00rootroot00000000000000 /* Written by Guenter Geiger (C) 1999 */ /* Thanks to Anthony Lee for Windows bug fixes */ #include #include "stream.h" #include #include #ifdef _WIN32 #include #else #include #include #include #include #include #include #include #include #define SOCKET_ERROR -1 #endif /* these pragmas are only used for MSVC, not MinGW or Cygwin */ #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #ifdef unix #define NONBLOCKED #endif #define MAXFRAMES 128 #define MAXFRAMESIZE 256 #define AVERAGENUM 10 /*#define DEBUGMESS(x) x*/ #define DEBUGMESS(x) /* Utility functions */ /* TODO !!!! - check udp support */ #ifdef _WIN32 extern int close(int); #endif extern void sys_rmpollfn(int fd); extern sys_addpollfn(int fd, void* fn, void *ptr); static void sys_sockerror(char *s) { #ifdef _WIN32 int err = WSAGetLastError(); if (err == 10054) return; #else int err = errno; #endif post("%s: %s (%d)\n", s, strerror(err), err); } static void sys_closesocket(int fd) { #ifdef _WIN32 closesocket(fd); #else close(fd); #endif } int setsocketoptions(int sockfd) { #ifndef _WIN32 int sockopt = 1; if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (const char*) &sockopt, sizeof(int)) < 0) { DEBUGMESS(post("setsockopt NODELAY failed\n")); } else { DEBUGMESS(post("TCP_NODELAY set")); } /* if we don`t use REUSEADDR we have to wait under unix until the address gets freed after a close ... this can be very annoying when working with netsend/netreceive GG */ sockopt = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(int)) < 0) post("setsockopt failed\n"); #endif return 0; } /* ------------------------ streamin~ ----------------------------- */ static t_class *streamin_class; typedef struct _streamin { t_object x_obj; int x_socket; int x_connectsocket; int x_nconnections; int x_ndrops; int x_fd; int x_tcp; /* buffering */ int framein; int frameout; t_frame frames[MAXFRAMES]; int maxframes; int nbytes; int counter; int average[AVERAGENUM]; int averagecur; int underflow; } t_streamin; static void streamin_datapoll(t_streamin *x) { int ret; int n; t_tag tag; int i; n = x->nbytes; if (x->nbytes == 0) { /* get the new tag */ ret = recv(x->x_socket, (char*) &x->frames[x->framein].tag,sizeof(t_tag),MSG_PEEK); if (ret != sizeof(t_tag)) { #ifdef _WIN32 sys_closesocket(x->x_socket); sys_rmpollfn(x->x_socket); x->x_socket = -1; #endif return; } ret = recv(x->x_socket, (char*) &x->frames[x->framein].tag,sizeof(t_tag),0); if ((x->frames[x->framein].tag.framesize - sizeof(t_tag)) > MAXFRAMESIZE) { error("streamin~: got an invalid frame size of %d, maximum is %d\n", x->frames[x->framein].tag.framesize, MAXFRAMESIZE); x->frames[x->framein].tag.framesize = MAXFRAMESIZE + sizeof(t_tag); } x->nbytes = n = x->frames[x->framein].tag.framesize; } ret = recv(x->x_socket, (char*) x->frames[x->framein].data + x->frames[x->framein].tag.framesize - n, n, 0); if (ret > 0) n-=ret; x->nbytes = n; if (n == 0) { x->counter++; x->framein++; x->framein %= MAXFRAMES; } } static void streamin_reset(t_streamin* x,t_floatarg frames) { int i; x->counter = 0; x->nbytes = 0; x->framein = 0; x->frameout = 0; for (i=0;iaverage[i] = x->maxframes; x->averagecur=0; if (frames == 0.0) x->maxframes = MAXFRAMES/2; else x->maxframes = frames; x->underflow = 0; } static void streamin_connectpoll(t_streamin *x) { int fd = accept(x->x_connectsocket, 0, 0); #ifdef NONBLOCKED fcntl(fd,F_SETFL,O_NONBLOCK); #endif if (fd < 0) { post("streamin~: accept failed"); return; } if (x->x_socket > 0) { post("streamin~: new connection"); sys_closesocket(x->x_socket); sys_rmpollfn(x->x_socket); } streamin_reset(x,0); x->x_socket = fd; sys_addpollfn(fd, streamin_datapoll, x); } static int streamin_createsocket(t_streamin* x, int portno,t_symbol* prot) { struct sockaddr_in server; int sockfd; int tcp = x->x_tcp; /* create a socket */ if (!tcp) sockfd = socket(AF_INET, SOCK_DGRAM, 0); else sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { sys_sockerror("socket"); return (0); } server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; /* assign server port number */ server.sin_port = htons((u_short)portno); post("listening to port number %d", portno); setsocketoptions(sockfd); /* name the socket */ if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) { sys_sockerror("bind"); sys_closesocket(sockfd); return (0); } if (!tcp) { x->x_socket = sockfd; x->nbytes = 0; sys_addpollfn(sockfd, streamin_datapoll, x); } else { if (listen(sockfd, 5) < 0) { sys_sockerror("listen"); sys_closesocket(sockfd); } else { x->x_connectsocket = sockfd; sys_addpollfn(sockfd, streamin_connectpoll, x); } } return 1; } static void streamin_free(t_streamin *x) { if (x->x_connectsocket > 0) { sys_closesocket(x->x_connectsocket); sys_rmpollfn(x->x_connectsocket); } sys_rmpollfn(x->x_socket); sys_closesocket(x->x_socket); } #define QUEUESIZE ((x->framein + MAXFRAMES - x->frameout)%MAXFRAMES) static t_int *streamin_perform(t_int *w) { t_streamin *x = (t_streamin*) (w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); int ret; int i = 0; if (x->counter < x->maxframes) { return (w+4); } if (x->framein == x->frameout) { x->underflow++; return w+4; } /* queue balancing */ x->average[x->averagecur] = QUEUESIZE; x->averagecur++; x->averagecur %= AVERAGENUM; switch (x->frames[x->frameout].tag.format) { case SF_FLOAT: { t_float* buf = (t_float*)(x->frames[x->frameout].data); while (n--) *out++ = *buf++; x->frameout++; x->frameout %= MAXFRAMES; break; } case SF_16BIT: { short* buf = (short*)(x->frames[x->frameout].data); while (n--) *out++ = (float) *buf++*3.051850e-05; x->frameout++; x->frameout %= MAXFRAMES; break; } case SF_8BIT: { unsigned char* buf = (char*)(x->frames[x->frameout].data); while (n--) *out++ = (float) (0.0078125 * (*buf++)) - 1.0; x->frameout++; x->frameout %= MAXFRAMES; break; } default: post("unknown format %d",x->frames[x->frameout].tag.format); break; } return (w+4); } static void streamin_dsp(t_streamin *x, t_signal **sp) { dsp_add(streamin_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } static void streamin_print(t_streamin* x) { int i; int avg = 0; for (i=0;iaverage[i]; post("last size = %d, avg size = %d, %d underflows", QUEUESIZE,avg/AVERAGENUM,x->underflow); } static void *streamin_new(t_floatarg fportno, t_floatarg prot) { t_streamin *x; int i; if (fportno == 0) fportno = 4267; post("port %f",fportno); x = (t_streamin *)pd_new(streamin_class); x->x_connectsocket = -1; x->x_socket = -1; x->x_tcp = 1; outlet_new(&x->x_obj, &s_signal); x->x_nconnections = 0; x->x_ndrops = 0; for (i=0;iframes[i].data = getbytes(MAXFRAMESIZE); } x->framein = 0; x->frameout = 0; x->maxframes = MAXFRAMES/2; if (prot) x->x_tcp = 0; streamin_createsocket(x, fportno, gensym("tcp")); return (x); } void streamin_tilde_setup(void) { streamin_class = class_new(gensym("streamin~"), (t_newmethod) streamin_new, (t_method) streamin_free, sizeof(t_streamin), 0, A_DEFFLOAT,A_DEFFLOAT, A_NULL); class_addmethod(streamin_class, nullfn, gensym("signal"), 0); class_addmethod(streamin_class, (t_method) streamin_dsp, gensym("dsp"), 0); class_addmethod(streamin_class, (t_method) streamin_print, gensym("print"), 0); class_addmethod(streamin_class, (t_method) streamin_reset, gensym("reset"),A_DEFFLOAT, 0); } ggee-0.28/signal/streamout~-help.pd000066400000000000000000000256371402462307700173450ustar00rootroot00000000000000#N canvas 0 26 938 483 12; #X floatatom 227 194 0 0 0 0 - - -; #X msg 46 32 disconnect; #X obj 369 71 osc~; #X floatatom 368 20 0 0 0 0 - - -; #X obj 368 44 sig~ 220; #X text 9 224 The format message sets the transmission format; #X text 14 462 (C) 1999 Guenter Geiger; #X obj 455 21 streamin~ 3001; #X obj 448 78 dac~; #X msg 156 68 connect tritonus 3000; #X msg 20 113 format float; #X msg 20 144 format 16bit; #X text 9 241 format float: send float numbers; #X text 8 260 format 16bit: send 16 bit integers; #X msg 20 176 format 8bit; #X text 445 259 host:; #X text 9 206 format:; #X text 444 206 connect:; #X text 443 223 connect sets the host and portnumber and immediatly tries to connect .; #X text 445 276 Set the host name and connect to the host \, if a connection was active.; #X msg 250 100 1; #X msg 284 100 0; #X text 444 311 disconnect (0); #X text 443 328 disconnect and 0 disconnect the object; #X text 444 348 1:; #X text 441 365 if the number 1 is sent to streamout \, the object connects to the stored host and portnumber. Default is localhost \, port number 3000; #X msg 179 12 connect gige 15001; #X msg 156 37 connect localhost 3001; #X text 8 277 format 8bit: send 8 bit integers; #X obj 227 162 streamout~; #N canvas 0 0 450 300 (subpatch) 0; #X array array1 900 float 1; #A 0 0.0890625 0.0875 0.0859375 0.084375 0.0828125 0.08125 0.0796875 0.0773438 0.0757812 0.0734375 0.0710938 0.0695313 0.0671875 0.0648438 0.0625 0.0601563 0.0578125 0.0546875 0.0523438 0.05 0.046875 0.0445313 0.0414063 0.0390625 0.0359375 0.0328125 0.0296875 0.0273438 0.0242188 0.0210938 0.0179687 0.0148437 0.0117188 0.00859375 0.00546875 0.00234375 -0.00078125 -0.00390625 -0.00703125 -0.0101563 -0.0132813 -0.0164063 -0.01875 -0.021875 -0.025 -0.028125 -0.03125 -0.034375 -0.0367188 -0.0398437 -0.0429688 -0.0453125 -0.0484375 -0.0507812 -0.0539063 -0.05625 -0.0585938 -0.0617188 -0.0640625 -0.0664062 -0.06875 -0.0710938 -0.0726563 -0.075 -0.0773438 -0.0789063 -0.08125 -0.0828125 -0.084375 -0.0859375 -0.0875 -0.0890625 -0.090625 -0.0921875 -0.0929688 -0.0945313 -0.0953125 -0.0960938 -0.096875 -0.0976562 -0.0984375 -0.0992187 -0.0992187 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.0992187 -0.0984375 -0.0984375 -0.0976562 -0.096875 -0.0960938 -0.0945313 -0.09375 -0.0929688 -0.0914062 -0.0898438 -0.0882813 -0.0875 -0.0851563 -0.0835937 -0.0820312 -0.0804688 -0.078125 -0.0765625 -0.0742188 -0.071875 -0.0703125 -0.0679687 -0.065625 -0.0632813 -0.0601563 -0.0578125 -0.0554687 -0.0523438 -0.05 -0.0476562 -0.0445313 -0.0414063 -0.0390625 -0.0359375 -0.0328125 -0.0296875 -0.0273438 -0.0242188 -0.0210938 -0.0179687 -0.0148437 -0.0117188 -0.00859375 -0.00546875 -0.00234375 0.00078125 0.00390625 0.00703125 0.0101563 0.0132813 0.0164063 0.01875 0.021875 0.025 0.028125 0.03125 0.034375 0.0367188 0.0398437 0.0429688 0.0453125 0.0484375 0.0507812 0.053125 0.05625 0.0585938 0.0609375 0.0632813 0.065625 0.0679687 0.0703125 0.071875 0.0742188 0.0765625 0.078125 0.0796875 0.0820312 0.0835937 0.0851563 0.0867188 0.0882813 0.0890625 0.090625 0.0914062 0.0929688 0.09375 0.0945313 0.0953125 0.0960938 0.096875 0.096875 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.096875 0.096875 0.0960938 0.0953125 0.0945313 0.09375 0.0929688 0.0914062 0.090625 0.0890625 0.0882813 0.0867188 0.0851563 0.0835937 0.0820312 0.0804688 0.078125 0.0765625 0.0742188 0.0726563 0.0703125 0.0679687 0.065625 0.0632813 0.0609375 0.0585938 0.05625 0.0539063 0.0507812 0.0484375 0.0453125 0.0429688 0.0398437 0.0375 0.034375 0.03125 0.028125 0.0257812 0.0226563 0.0195312 0.0164063 0.0132813 0.0101563 0.00703125 0.00390625 0.00078125 -0.00234375 -0.00546875 -0.00859375 -0.0117188 -0.0148437 -0.0179687 -0.0210938 -0.0234375 -0.0265625 -0.0296875 -0.0328125 -0.0359375 -0.0382813 -0.0414063 -0.0445313 -0.046875 -0.05 -0.0523438 -0.0554687 -0.0578125 -0.0601563 -0.0625 -0.0648438 -0.0671875 -0.0695313 -0.071875 -0.0742188 -0.0765625 -0.078125 -0.0804688 -0.0820312 -0.0835937 -0.0851563 -0.0867188 -0.0882813 -0.0898438 -0.0914062 -0.0921875 -0.09375 -0.0945313 -0.0960938 -0.096875 -0.0976562 -0.0984375 -0.0984375 -0.0992187 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.0992187 -0.0992187 -0.0984375 -0.0976562 -0.096875 -0.0960938 -0.0953125 -0.0945313 -0.0929688 -0.0921875 -0.090625 -0.0890625 -0.0875 -0.0859375 -0.084375 -0.0828125 -0.08125 -0.0789063 -0.0773438 -0.075 -0.0734375 -0.0710938 -0.06875 -0.0664062 -0.0640625 -0.0617188 -0.059375 -0.05625 -0.0539063 -0.0515625 -0.0484375 -0.0460938 -0.0429688 -0.0398437 -0.0375 -0.034375 -0.03125 -0.028125 -0.0257812 -0.0226563 -0.0195312 -0.0164063 -0.0132813 -0.0101563 -0.00703125 -0.00390625 -0.00078125 0.00234375 0.00546875 0.00859375 0.0117188 0.0148437 0.0179687 0.0210938 0.0234375 0.0265625 0.0296875 0.0328125 0.0359375 0.0382813 0.0414063 0.04375 0.046875 0.0492188 0.0523438 0.0546875 0.0570313 0.0601563 0.0625 0.0648438 0.0671875 0.06875 0.0710938 0.0734375 0.075 0.0773438 0.0789063 0.08125 0.0828125 0.084375 0.0859375 0.0875 0.0882813 0.0898438 0.0914062 0.0921875 0.0929688 0.09375 0.0953125 0.0953125 0.0960938 0.096875 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.096875 0.096875 0.0960938 0.0953125 0.0953125 0.09375 0.0929688 0.0921875 0.0914062 0.0898438 0.0882813 0.0875 0.0859375 0.084375 0.0828125 0.08125 0.0789063 0.0773438 0.075 0.0734375 0.0710938 0.06875 0.0671875 0.0648438 0.0625 0.0601563 0.0570313 0.0546875 0.0523438 0.0492188 0.046875 0.04375 0.0414063 0.0382813 0.0359375 0.0328125 0.0296875 0.0265625 0.0234375 0.0210938 0.0179687 0.0148437 0.0117188 0.00859375 0.00546875 0.00234375 -0.00078125 -0.00390625 -0.00703125 -0.0101563 -0.0132813 -0.0164063 -0.0195312 -0.0226563 -0.0257812 -0.028125 -0.03125 -0.034375 -0.0375 -0.0398437 -0.0429688 -0.0460938 -0.0484375 -0.0515625 -0.0539063 -0.05625 -0.059375 -0.0617188 -0.0640625 -0.0664062 -0.06875 -0.0710938 -0.0734375 -0.075 -0.0773438 -0.0789063 -0.08125 -0.0828125 -0.084375 -0.0859375 -0.0875 -0.0890625 -0.090625 -0.0921875 -0.0929688 -0.0945313 -0.0953125 -0.0960938 -0.096875 -0.0976562 -0.0984375 -0.0992187 -0.0992187 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.0992187 -0.0984375 -0.0984375 -0.0976562 -0.096875 -0.0960938 -0.0945313 -0.09375 -0.0921875 -0.0914062 -0.0898438 -0.0882813 -0.0867188 -0.0851563 -0.0835937 -0.0820312 -0.0796875 -0.078125 -0.0757812 -0.0742188 -0.071875 -0.0695313 -0.0671875 -0.0648438 -0.0625 -0.0601563 -0.0578125 -0.0554687 -0.0523438 -0.05 -0.046875 -0.0445313 -0.0414063 -0.0382813 -0.0359375 -0.0328125 -0.0296875 -0.0265625 -0.0234375 -0.0210938 -0.0179687 -0.0148437 -0.0117188 -0.00859375 -0.00546875 -0.00234375 0.00078125 0.00390625 0.00703125 0.0101563 0.0132813 0.0164063 0.0195312 0.0226563 0.0257812 0.028125 0.03125 0.034375 0.0375 0.0398437 0.0429688 0.0453125 0.0484375 0.0507812 0.0539063 0.05625 0.0585938 0.0609375 0.0632813 0.065625 0.0679687 0.0703125 0.0726563 0.0742188 0.0765625 0.078125 0.0804688 0.0820312 0.0835937 0.0851563 0.0867188 0.0882813 0.0890625 0.090625 0.0914062 0.0929688 0.09375 0.0945313 0.0953125 0.0960938 0.096875 0.096875 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.096875 0.096875 0.0960938 0.0953125 0.0945313 0.09375 0.0929688 0.0914062 0.090625 0.0890625 0.0882813 0.0867188 0.0851563 0.0835937 0.0820312 0.0796875 0.078125 0.0765625 0.0742188 0.071875 0.0703125 0.0679687 0.065625 0.0632813 0.0609375 0.0585938 0.05625 0.053125 0.0507812 0.0484375 0.0453125 0.0421875 0.0398437 0.0367188 0.034375 0.03125 0.028125 0.025 0.021875 0.01875 0.0164063 0.0132813 0.0101563 0.00703125 0.00390625 0.00078125 -0.00234375 -0.00546875 -0.00859375 -0.0117188 -0.0148437 -0.0179687 -0.0210938 -0.0242188 -0.0273438 -0.0304688 -0.0328125 -0.0359375 -0.0390625 -0.0414063 -0.0445313 -0.0476562 -0.05 -0.053125 -0.0554687 -0.0578125 -0.0601563 -0.0632813 -0.065625 -0.0679687 -0.0703125 -0.071875 -0.0742188 -0.0765625 -0.078125 -0.0804688 -0.0820312 -0.0835937 -0.0859375 -0.0875 -0.0882813 -0.0898438 -0.0914062 -0.0929688 -0.09375 -0.0945313 -0.0960938 -0.096875 -0.0976562 -0.0984375 -0.0984375 -0.0992187 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.0992187 -0.0992187 -0.0984375 -0.0976562 -0.096875 -0.0960938 -0.0953125 -0.0945313 -0.0929688 -0.0921875 -0.090625 -0.0890625 -0.0875 -0.0859375 -0.084375 -0.0828125 -0.08125 -0.0789063 -0.0773438 -0.075 -0.0726563 -0.0710938 -0.06875 -0.0664062 -0.0640625 -0.0617188 -0.0585938 -0.05625 -0.0539063 -0.0507812 -0.0484375 -0.0453125 -0.0429688 -0.0398437 -0.0367188 -0.034375 -0.03125 -0.028125 -0.025 -0.021875 -0.01875 -0.015625 -0.0132813 -0.0101563 -0.00703125 -0.00390625 -0.00078125 0.00234375 0.00546875 0.00859375 0.0117188 0.0148437 0.0179687 0.0210938 0.0242188 0.0273438 0.0296875 0.0328125 0.0359375 0.0390625 0.0414063 0.0445313 0.046875 0.05 0.0523438 0.0546875 0.0578125 0.0601563 0.0625 0.0648438 0.0671875 0.0695313 0.0710938 0.0734375 0.0757812 0.0773438 0.0796875 0.08125 0.0828125 0.084375 0.0859375 0.0875 0.0890625 0.0898438 0.0914062 0.0921875 0.0929688 0.0945313 0.0953125 0.0960938 0.0960938 0.096875 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.0976562 0.096875 0.096875 0.0960938 0.0953125 0.0945313 0.09375 0.0929688 0.0921875 0.090625 0.0898438 0.0882813 0.0875 0.0859375 0.084375 0.0828125 0.0804688 0.0789063 0.0773438 0.075 0.0734375 0.0710938 0.06875 0.0664062 0.0640625 0.0617188 0.059375 0.0570313 0.0546875 0.0515625 0.0492188 0.046875 0.04375 0.0414063 0.0382813 0.0351562 0.0320312 0.0296875 0.0265625 0.0234375 0.0203125 0.0171875 0.0140625 0.0109375 0.0078125 0.00546875 0.00234375 -0.00078125 -0.00390625 -0.00703125 -0.0101563 -0.0132813 -0.0164063 -0.0195312 -0.0226563 -0.0257812 -0.0289063 -0.0320312 -0.034375 -0.0375 -0.040625 -0.0429688 -0.0460938 -0.0492188 -0.0515625 -0.0539063 -0.0570313 -0.059375 -0.0617188 -0.0640625 -0.0664062 -0.06875 -0.0710938 -0.0734375 -0.0757812 -0.0773438 -0.0796875 -0.08125 -0.0828125 -0.0851563 -0.0867188 -0.0882813 -0.0890625 -0.090625 -0.0921875 -0.0929688 -0.0945313 -0.0953125 -0.0960938 -0.096875 -0.0976562 -0.0984375 -0.0992187 -0.0992187 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.0992187 -0.0984375 -0.0984375 -0.0976562 -0.096875 -0.0953125 -0.0945313; #X coords 0 1 899 -1 200 140 1; #X restore 689 52 graph; #X obj 460 140 tabwrite~ array1; #X msg 541 79 bang; #X obj 458 47 *~ 0.1; #N canvas 404 187 494 344 META 0; #X text 12 124 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 25 LICENSE Tcl/Tk; #X text 12 105 AUTHOR Guenter Geiger; #X text 12 5 KEYWORDS signal network; #X text 12 45 DESCRIPTION needs a description; #X text 12 65 INLET_0 signal format disconnect connect float; #X text 12 85 OUTLET_0 float; #X restore 882 458 pd META; #X connect 1 0 29 0; #X connect 2 0 29 0; #X connect 3 0 4 0; #X connect 4 0 2 0; #X connect 7 0 33 0; #X connect 9 0 29 0; #X connect 10 0 29 0; #X connect 11 0 29 0; #X connect 14 0 29 0; #X connect 20 0 29 0; #X connect 21 0 29 0; #X connect 26 0 29 0; #X connect 27 0 29 0; #X connect 29 0 0 0; #X connect 32 0 31 0; #X connect 33 0 8 0; #X connect 33 0 8 1; #X connect 33 0 31 0; ggee-0.28/signal/streamout~.c000066400000000000000000000170211402462307700162220ustar00rootroot00000000000000 /* (C) Guenter Geiger */ #include #include "stream.h" #include #include #include #ifdef _WIN32 #include #else #include #include #include #include #include #define SOCKET_ERROR -1 #endif #ifdef __APPLE__ #include #endif /* Utility functions */ static void sys_sockerror(char *s) { #ifdef _WIN32 int err = WSAGetLastError(); if (err == 10054) return; #else int err = errno; #endif post("%s: %s (%d)\n", s, strerror(err), err); } static void sys_closesocket(int fd) { #ifdef UNIX close(fd); /* shutdown() ?? */ #endif #ifdef _WIN32 closesocket(fd); #endif } /* ------------------------ streamout~ ----------------------------- */ static t_class *streamout_class; typedef struct _streamout { t_object x_obj; int x_fd; int x_protocol; t_tag x_tag; t_symbol* hostname; int portno; short* cbuf; int nsamples; int tbufsize; } t_streamout; static void streamout_tempbuf(t_streamout *x,int size) { if (x->cbuf && x->tbufsize) freebytes(x->cbuf,x->tbufsize); x->tbufsize=size*sizeof(float)*x->x_tag.channels; if (!x->cbuf) x->cbuf = getbytes(x->tbufsize); x->nsamples = size; } static void streamout_disconnect(t_streamout *x) { if (x->x_fd >= 0) { sys_closesocket(x->x_fd); x->x_fd = -1; outlet_float(x->x_obj.ob_outlet, 0); } } static void streamout_connect(t_streamout *x, t_symbol *hostname, t_floatarg fportno) { struct sockaddr_in server; struct hostent *hp; int sockfd; int portno = fportno; x->hostname = hostname; if (!fportno) x->portno = 4267; else x->portno = (int) fportno; x->x_tag.count = 0; if (x->x_fd >= 0) { post("streamout~: already connected"); return; } /* create a socket */ sockfd = socket(AF_INET, x->x_protocol, 0); if (sockfd < 0) { post("streamout: Connection to %s on port %d failed",hostname->s_name,portno); sys_sockerror("socket"); return; } /* connect socket using hostname provided in command line */ server.sin_family = AF_INET; hp = gethostbyname(x->hostname->s_name); if (hp == 0) { post("bad host?\n"); return; } memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); /* assign client port number */ server.sin_port = htons((u_short)portno); /* try to connect. LATER make a separate thread to do this because it might block */ if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0) { sys_sockerror("connecting stream socket"); sys_closesocket(sockfd); return; } post("connected host %s on port %d",hostname->s_name, portno); x->x_fd = sockfd; outlet_float(x->x_obj.ob_outlet, 1); } static t_int *streamout_perform(t_int *w) { t_streamout* x = (t_streamout*) (w[1]); t_float *in[4]; char* bp; int n; int length; int sent = 0; int i; int chans = x->x_tag.channels; for (i=0;ix_tag.format)*chans; if (n != x->nsamples) streamout_tempbuf(x,n); x->x_tag.framesize=length; x->x_tag.count++; /* format the buffer */ switch (x->x_tag.format) { case SF_FLOAT: { float* cibuf =(float*) x->cbuf; bp = (char*) x->cbuf; for (i=0;icbuf; bp = (char*) x->cbuf; for (i=0;icbuf; bp = (char*) x->cbuf; for (i=0;ix_fd > 0) { /* send the format tag */ #ifdef __APPLE__ if (send(x->x_fd,(char*)&x->x_tag,sizeof(t_tag),SO_NOSIGPIPE) < 0) #elif defined unix if (send(x->x_fd,(char*)&x->x_tag,sizeof(t_tag),/*MSG_DONTWAIT|*/MSG_NOSIGNAL) < 0) #else if (send(x->x_fd,(char*)&x->x_tag,sizeof(t_tag),0) < 0) #endif { sys_sockerror("streamout"); streamout_disconnect(x); return (w+4); } /* send the buffer */ for (sent = 0; sent < length;) { int res = 0; #ifdef __APPLE__ res = send(x->x_fd, bp, length-sent, SO_NOSIGPIPE); #elif defined unix res = send(x->x_fd, bp, length-sent, /*MSG_DONTWAIT|*/MSG_NOSIGNAL); #else res = send(x->x_fd, bp, length-sent, 0); #endif if (res <= 0) { sys_sockerror("streamout"); streamout_disconnect(x); break; } else { sent += res; bp += res; } } } return (w+3+chans); } static void streamout_dsp(t_streamout *x, t_signal **sp) { switch (x->x_tag.channels) { case 1: dsp_add(streamout_perform, 3, x,sp[0]->s_vec, sp[0]->s_n); post("one channel mode"); break; case 2: dsp_add(streamout_perform, 4, x,sp[0]->s_vec, sp[1]->s_vec,sp[0]->s_n); post("two channel mode"); break; case 4: dsp_add(streamout_perform, 6, x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec,sp[3]->s_vec,sp[0]->s_n); post("four channel mode"); break; default: post("streamout: %d channels not supported",x->x_tag.channels); } } static void streamout_format(t_streamout *x,t_symbol* form) { if (!strncmp(form->s_name,"float",5)) x->x_tag.format = (int) SF_FLOAT; if (!strncmp(form->s_name,"16bit",5)) x->x_tag.format = (int) SF_16BIT; if (!strncmp(form->s_name,"8bit",4)) x->x_tag.format = (int) SF_8BIT; post ("format set to %s", form->s_name); } static void streamout_host(t_streamout *x,t_symbol* host) { if (host != &s_) x->hostname = host; if (x->x_fd >= 0) { streamout_connect(x,x->hostname,(float) x->portno); } } static void streamout_float(t_streamout* x,t_float arg) { if (arg == 0.0) streamout_disconnect(x); else streamout_connect(x,x->hostname,(float) x->portno); } static void *streamout_new(t_symbol* prot,float channels) { t_streamout *x = (t_streamout *)pd_new(streamout_class); outlet_new(&x->x_obj, &s_float); if (channels == 0) channels = 1; x->hostname = gensym("localhost"); x->portno = 3000; x->x_fd = -1; x->x_protocol = SOCK_STREAM; if (prot != &s_) if (!strncmp(prot->s_name,"udp",3)) x->x_protocol = SOCK_DGRAM; x->x_tag.format = SF_FLOAT; x->x_tag.channels = channels; x->x_tag.version = 1; x->cbuf = NULL; streamout_tempbuf(x,64); return (x); } static void streamout_free(t_streamout* x) { if (x->cbuf && x->tbufsize) freebytes(x->cbuf,x->tbufsize); } void streamout_tilde_setup(void) { streamout_class = class_new(gensym("streamout~"), (t_newmethod) streamout_new, (t_method) streamout_free, sizeof(t_streamout), 0, A_DEFSYM,A_DEFFLOAT, 0); class_addmethod(streamout_class, (t_method) streamout_connect, gensym("connect"), A_SYMBOL, A_DEFFLOAT, 0); class_addmethod(streamout_class, (t_method) streamout_disconnect, gensym("disconnect"), 0); class_addfloat(streamout_class,streamout_float); class_addmethod(streamout_class, nullfn, gensym("signal"), 0); class_addmethod(streamout_class, (t_method) streamout_dsp, gensym("dsp"), 0); class_addmethod(streamout_class, (t_method)streamout_format,gensym("format"),A_SYMBOL,0); class_addmethod(streamout_class, (t_method)streamout_host,gensym("host"),A_DEFSYM,0); }