aboutsummaryrefslogtreecommitdiff
path: root/probalizer
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-07-31 03:59:16 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:23:30 +0200
commitd145fa6f792d6c44da2feec90507adb94e40323e (patch)
treeae3aaf213dbb4273331745802ef1259dce8e2986 /probalizer
parent67af8f6b3f179d5b4ba0747ab971abbeecbedd45 (diff)
got everything building using the template Makefile
svn path=/trunk/externals/unauthorized/; revision=15173
Diffstat (limited to 'probalizer')
-rw-r--r--probalizer/INSTALL14
-rw-r--r--probalizer/probalizer-help.pd53
-rw-r--r--probalizer/probalizer.c703
-rw-r--r--probalizer/probalizer.h26
-rw-r--r--probalizer/probalizer.tk113
-rwxr-xr-xprobalizer/probalizer.tk2c87
-rwxr-xr-xprobalizer/tk2c.bash24
7 files changed, 0 insertions, 1020 deletions
diff --git a/probalizer/INSTALL b/probalizer/INSTALL
deleted file mode 100644
index 17ecb34..0000000
--- a/probalizer/INSTALL
+++ /dev/null
@@ -1,14 +0,0 @@
-untar in /my/pd/dir/externs
-
-cd /my/pd/dir/externs/probalizer
-
-make clean
-
-make
-
-make install
-
-open help-probalizer.pd
-
-comments and bugs @ ydegoyon@free.fr
-Yves/
diff --git a/probalizer/probalizer-help.pd b/probalizer/probalizer-help.pd
deleted file mode 100644
index b3baa89..0000000
--- a/probalizer/probalizer-help.pd
+++ /dev/null
@@ -1,53 +0,0 @@
-#N canvas 191 -6 970 685 10;
-#X text 374 167 (invoke with <right mouse>Properties );
-#X text 375 156 You can set the following properties :;
-#X text 395 188 * Width : graphical x size;
-#X text 395 200 * Height : graphical y size;
-#X text 442 506 bugs and comments @ ydegoyon@free.fr;
-#X msg 404 603 \; pd dsp 0;
-#X msg 470 603 \; pd dsp 1;
-#X text 376 110 Probalizer output serial of integers according to the
-probability curve;
-#X obj 470 581 loadbang;
-#X obj 64 92 probalizer 200 200 10 100 1 0 42 1 66 2 86 3 67 4 36 5
-40 6 2 7 53 8 63 9 14;
-#X text 395 213 * Values : number of values ( range is [ 1 \, nvalues
-] );
-#X msg 93 54 bang;
-#X msg 93 4 bang;
-#X text 389 458 but without repetitions;
-#X msg 295 16 zero;
-#X msg 294 40 equi;
-#X text 389 433 Note = If the probabilities are all equal to 1 \,;
-#X msg 293 64 reset;
-#X text 338 63 Reset output;
-#X text 396 227 * Max Occurrences : max number of occurences in a serial
-;
-#X obj 68 358 probalizer 200 200 10 100 1 0 0 1 0 2 0 3 0 4 0 5 0 6
-0 7 0 8 0 9 0;
-#X obj 193 331 loadbang;
-#X msg 145 331 zero;
-#X text 306 345 The output of first probalizer;
-#X text 306 357 is stored in the second one;
-#X floatatom 187 30 5 0 0;
-#X msg 187 5 bang;
-#X text 276 281 End of the serial;
-#X text 390 445 probalizer behaves as a random object;
-#X obj 276 308 print probalizer::end;
-#X text 47 6 Start;
-#X text 332 42 Set equal probabilities;
-#X obj 93 29 metro 10;
-#X connect 8 0 6 0;
-#X connect 9 0 20 0;
-#X connect 9 1 22 0;
-#X connect 9 1 29 0;
-#X connect 11 0 9 0;
-#X connect 12 0 32 0;
-#X connect 14 0 9 0;
-#X connect 15 0 9 0;
-#X connect 17 0 9 0;
-#X connect 21 0 22 0;
-#X connect 22 0 20 0;
-#X connect 25 0 9 0;
-#X connect 26 0 25 0;
-#X connect 32 0 11 0;
diff --git a/probalizer/probalizer.c b/probalizer/probalizer.c
deleted file mode 100644
index c6fe338..0000000
--- a/probalizer/probalizer.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/* ---------------------------------------------------------------------------- */
-/* Copyright (c) 2002 Yves Degoyon. */
-/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */
-/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-/* */
-/* probalizer : outputs integer values according to a drawn probability curve */
-/* */
-/* This program is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU General Public License */
-/* as published by the Free Software Foundation; either version 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* See file LICENSE for further informations on licensing terms. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with this program; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* */
-/* Based on PureData by Miller Puckette and others. */
-/* */
-/* Made while listening to : */
-/* */
-/* "I am a product, I am a sample" */
-/* "I'm hopeless, aimless" */
-/* Crass -- Feeding of the 5000 */
-/* ---------------------------------------------------------------------------- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <math.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "m_imp.h"
-#include "g_canvas.h"
-
-#include "probalizer.h"
-
-#ifdef NT
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#define DEFAULT_PROBALIZER_WIDTH 200
-#define DEFAULT_PROBALIZER_HEIGHT 200
-#define DEFAULT_PROBALIZER_NBVALUES 100
-#define DEFAULT_PROBALIZER_NBOCCURRENCES 100
-#define DEFAULT_PROB_VALUE 10
-
-static char *probalizer_version = "probalizer : outputs integer values according to a drawn probability curve , version 0.4 (ydegoyon@free.fr)";
-
-t_widgetbehavior probalizer_widgetbehavior;
-static t_class *probalizer_class;
-
-static int guidebug=0;
-static int pointsize = 5;
-
-#define SYS_VGUI2(a,b) if (guidebug) \
- post(a,b);\
- sys_vgui(a,b)
-
-#define SYS_VGUI3(a,b,c) if (guidebug) \
- post(a,b,c);\
- sys_vgui(a,b,c)
-
-#define SYS_VGUI4(a,b,c,d) if (guidebug) \
- post(a,b,c,d);\
- sys_vgui(a,b,c,d)
-
-#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \
- post(a,b,c,d,e);\
- sys_vgui(a,b,c,d,e)
-
-#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \
- post(a,b,c,d,e,f);\
- sys_vgui(a,b,c,d,e,f)
-
-#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \
- post(a,b,c,d,e,f,g);\
- sys_vgui(a,b,c,d,e,f,g)
-
-#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \
- post(a,b,c,d,e,f,g,h);\
- sys_vgui(a,b,c,d,e,f,g,h)
-
-#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \
- post(a,b,c,d,e,f,g,h,i);\
- sys_vgui(a,b,c,d,e,f,g,h,i)
-
-#define SYS_VGUI13(a,b,c,d,e,f,g,h,i,j,k,l,m) if (guidebug) \
- post(a,b,c,d,e,f,g,h,i,j,k,l,m);\
- sys_vgui(a,b,c,d,e,f,g,h,i,j,k,l,m)
-
-/* drawing functions */
-static void probalizer_draw_new(t_probalizer *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- t_int ei;
-
- SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #6790E2 -tags %xPROBALIZER\n",
- canvas, 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);
- SYS_VGUI5(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0\" -tags %xLTCAPTION\n",
- canvas, text_xpix(&x->x_obj, glist)-15, text_ypix(&x->x_obj, glist) + x->x_height, x );
- SYS_VGUI6(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%d\" -tags %xLBCAPTION\n",
- canvas, text_xpix(&x->x_obj, glist)-15, text_ypix(&x->x_obj, glist), x->x_noccurrences, x );
- SYS_VGUI5(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"1\" -tags %xBLCAPTION\n",
- canvas, text_xpix(&x->x_obj, glist)+2, text_ypix(&x->x_obj, glist) + x->x_height + 10, x );
- SYS_VGUI6(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%d\" -tags %xBRCAPTION\n",
- canvas, text_xpix(&x->x_obj, glist) + x->x_width-5, text_ypix(&x->x_obj, glist) + x->x_height + 10, x->x_nvalues, x );
- SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN\n",
- canvas, text_xpix(&x->x_obj, glist),
- text_ypix(&x->x_obj, glist) - 2,
- text_xpix(&x->x_obj, glist) + 5,
- text_ypix(&x->x_obj, glist) ,
- x);
- SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT\n",
- canvas, text_xpix(&x->x_obj, glist),
- text_ypix(&x->x_obj, glist) + x->x_height,
- text_xpix(&x->x_obj, glist) + 5,
- text_ypix(&x->x_obj, glist) + x->x_height + 2,
- x);
- SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT2\n",
- canvas, text_xpix(&x->x_obj, glist) + x->x_width -5,
- text_ypix(&x->x_obj, glist) + x->x_height,
- text_xpix(&x->x_obj, glist) + x->x_width,
- text_ypix(&x->x_obj, glist) + x->x_height + 2,
- x);
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #118373 -tags %xPROB%d\n",
- canvas,
- text_xpix(&x->x_obj, glist) + ei * x->x_width/x->x_nvalues,
- text_ypix(&x->x_obj, glist) + x->x_height - ( *(x->x_probs+ei) * x->x_height / x->x_noccurrences ),
- text_xpix(&x->x_obj, glist) + (ei+1) * x->x_width/x->x_nvalues,
- text_ypix(&x->x_obj, glist) + x->x_height,
- x, ei);
- }
- canvas_fixlinesfor( canvas, (t_text*)x );
-}
-
-static void probalizer_draw_update(t_probalizer *x)
-{
- t_canvas *canvas=glist_getcanvas(x->x_glist);
- t_int ei;
-
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- SYS_VGUI8(".x%x.c coords %xPROB%d %d %d %d %d\n",
- canvas, x, ei,
- text_xpix(&x->x_obj, x->x_glist) + ei * x->x_width / x->x_nvalues,
- text_ypix(&x->x_obj, x->x_glist) + x->x_height - ( *(x->x_probs+ei) * x->x_height / x->x_noccurrences ),
- text_xpix(&x->x_obj, x->x_glist) + (ei+1) * x->x_width / x->x_nvalues,
- text_ypix(&x->x_obj, x->x_glist) + x->x_height );
- }
- canvas_fixlinesfor( canvas, (t_text*)x );
-}
-
-static void probalizer_draw_move(t_probalizer *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- t_int ei;
-
- SYS_VGUI7(".x%x.c coords %xPROBALIZER %d %d %d %d \n",
- canvas, 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
- );
- SYS_VGUI7(".x%x.c coords %xIN %d %d %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist),
- text_ypix(&x->x_obj, glist) - 2,
- text_xpix(&x->x_obj, glist) + 5,
- text_ypix(&x->x_obj, glist)
- );
- SYS_VGUI7(".x%x.c coords %xOUT %d %d %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist),
- text_ypix(&x->x_obj, glist) + x->x_height,
- text_xpix(&x->x_obj, glist) + 5,
- text_ypix(&x->x_obj, glist) + x->x_height + 2
- );
- SYS_VGUI7(".x%x.c coords %xOUT2 %d %d %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist) + x->x_width - 5,
- text_ypix(&x->x_obj, glist) + x->x_height,
- text_xpix(&x->x_obj, glist) + x->x_width,
- text_ypix(&x->x_obj, glist) + x->x_height + 2
- );
- SYS_VGUI5(".x%x.c coords %xLTCAPTION %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist)-15,
- text_ypix(&x->x_obj, glist) + x->x_height
- );
- SYS_VGUI5(".x%x.c coords %xLBCAPTION %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist)-15,
- text_ypix(&x->x_obj, glist)
- );
- SYS_VGUI5(".x%x.c coords %xBLCAPTION %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist)+2,
- text_ypix(&x->x_obj, glist) + x->x_height + 10
- );
- SYS_VGUI5(".x%x.c coords %xBRCAPTION %d %d\n",
- canvas, x, text_xpix(&x->x_obj, glist) + x->x_width - 5,
- text_ypix(&x->x_obj, glist) + x->x_height + 10
- );
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- SYS_VGUI8(".x%x.c coords %xPROB%d %d %d %d %d\n",
- canvas, x, ei,
- text_xpix(&x->x_obj, glist) + ei * x->x_width / x->x_nvalues,
- text_ypix(&x->x_obj, glist) + x->x_height - ( *(x->x_probs+ei) * x->x_height / x->x_noccurrences ),
- text_xpix(&x->x_obj, glist) + (ei+1) * x->x_width / x->x_nvalues,
- text_ypix(&x->x_obj, glist) + x->x_height );
- }
- canvas_fixlinesfor( canvas, (t_text*)x );
-}
-
-static void probalizer_draw_erase(t_probalizer* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int i, ei, gi;
-
- SYS_VGUI3(".x%x.c delete %xPROBALIZER\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xIN\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xOUT\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xOUT2\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xLTCAPTION\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xLBCAPTION\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xBLCAPTION\n", canvas, x );
- SYS_VGUI3(".x%x.c delete %xBRCAPTION\n", canvas, x );
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- SYS_VGUI4(".x%x.c delete %xPROB%d\n", canvas, x, ei );
- }
-}
-
-static void probalizer_draw_select(t_probalizer* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_selected)
- {
- /* sets the main item in blue */
- SYS_VGUI3(".x%x.c itemconfigure %xPROBALIZER -outline #0000FF\n", glist_getcanvas(glist), x);
-
- }
- else
- {
- /* sets the main item in black */
- SYS_VGUI3(".x%x.c itemconfigure %xPROBALIZER -outline #000000\n", glist_getcanvas(glist), x);
- }
-}
-
-/* ------------------------ probalizer widgetbehaviour----------------------------- */
-
-
-static void probalizer_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_probalizer* x = (t_probalizer*)z;
-
- *xp1 = text_xpix(&x->x_obj, owner);
- *yp1 = text_ypix(&x->x_obj, owner);
- *xp2 = text_xpix(&x->x_obj, owner)+x->x_width;
- *yp2 = text_ypix(&x->x_obj, owner)+x->x_height;
-}
-
-static void probalizer_save(t_gobj *z, t_binbuf *b)
-{
- t_probalizer *x = (t_probalizer *)z;
- int ei,gi;
-
- binbuf_addv(b, "ssiisiiiii", 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->x_width, x->x_height,
- x->x_nvalues, x->x_noccurrences, x->x_save );
- if ( x->x_save )
- {
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- // post( "probalizer : saving ( %d, %d )", ei, gi );
- binbuf_addv(b, "ii", ei, *(x->x_probs+ei) );
- }
- }
- binbuf_addv(b, ";");
-}
-
-static void probalizer_properties(t_gobj *z, t_glist *owner)
-{
- char buf[800];
- t_probalizer *x=(t_probalizer *)z;
-
- sprintf(buf, "pdtk_probalizer_dialog %%s %d %d %d %d %d\n",
- x->x_width, x->x_height, x->x_nvalues, x->x_noccurrences, x->x_save );
- // post("probalizer_properties : %s", buf );
- gfxstub_new(&x->x_obj.ob_pd, x, buf);
-}
-
-static void probalizer_select(t_gobj *z, t_glist *glist, int selected)
-{
- t_probalizer *x = (t_probalizer *)z;
-
- x->x_selected = selected;
- probalizer_draw_select( x, glist );
-}
-
-static void probalizer_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_probalizer *x = (t_probalizer *)z;
- t_rtext *y;
-
- // post("probalizer_vis : %d", vis );
- if (vis)
- {
- probalizer_draw_new( x, glist );
- }
- else
- {
- probalizer_draw_erase( x, glist );
- }
-}
-
- /* handle parameters sent by the property dialog */
-static void probalizer_dialog(t_probalizer *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_int onvalues, owidth, ei, gi, bi;
- t_canvas *canvas=glist_getcanvas(x->x_glist);
-
- if ( !x ) {
- post( "probalizer : error :tried to set properties on an unexisting object" );
- }
- onvalues = x->x_nvalues;
- owidth = x->x_width;
- probalizer_draw_erase(x, x->x_glist);
- if ( argc < 5 )
- {
- post( "probalizer : error in the number of arguments ( %d )", argc );
- return;
- }
- if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ||
- argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ||
- argv[4].a_type != A_FLOAT )
- {
- post( "probalizer : wrong arguments" );
- return;
- }
-
- x->x_width = argv[0].a_w.w_float;
- if ( x->x_width <= 0 ) x->x_width = 100;
- x->x_height = argv[1].a_w.w_float;
- if ( x->x_height <= 0 ) x->x_height = 100;
- x->x_nvalues = argv[2].a_w.w_float;
- if ( x->x_nvalues < 1 ) x->x_nvalues = 1;
- x->x_noccurrences = argv[3].a_w.w_float;
- if ( x->x_noccurrences < 1 ) x->x_noccurrences = 1;
- x->x_save = argv[4].a_w.w_float;
-
- // re-allocate arrays of values
- post( "probalizer : re-allocate values" );
- if ( onvalues != x->x_nvalues )
- {
- t_int mvalues = ( onvalues > x->x_nvalues ) ? x->x_nvalues : onvalues;
- t_int *newprobs, *newovalues;
-
- newprobs = (t_int*) getbytes( x->x_nvalues*sizeof(t_int) );
- newovalues = (t_int*) getbytes( x->x_nvalues*sizeof(t_int) );
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- *(newprobs+ei)=DEFAULT_PROB_VALUE;
- }
- memset( newovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- for ( ei=0; ei<mvalues; ei++ )
- {
- *(newprobs+ei ) = *(x->x_probs+ei);
- }
- if ( x->x_probs )
- freebytes( x->x_probs, onvalues*sizeof(t_int) );
- x->x_probs = newprobs;
- if ( x->x_ovalues )
- freebytes( x->x_ovalues, onvalues*sizeof(t_int) );
- x->x_ovalues = newovalues;
- }
-
- probalizer_draw_new(x, x->x_glist);
- canvas_fixlinesfor( canvas, (t_text*)x );
-}
-
-static void probalizer_delete(t_gobj *z, t_glist *glist)
-{
- canvas_deletelinesfor(glist, (t_text *)z);
-}
-
-static void probalizer_displace(t_gobj *z, t_glist *glist, int dx, int dy)
-{
- t_probalizer *x = (t_probalizer *)z;
- int xold = text_xpix(&x->x_obj, glist);
- int yold = text_ypix(&x->x_obj, glist);
-
- // post( "probalizer_displace dx=%d dy=%d", dx, dy );
-
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix)
- {
- probalizer_draw_move(x, x->x_glist);
- }
-}
-
-static int probalizer_click(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_probalizer* x = (t_probalizer *)z;
- t_canvas *canvas=glist_getcanvas(glist);
- t_int nevent, npix;
-
- if ( doit)
- {
- int nevent;
- int newvalue;
-
- nevent = ((float)( xpix - text_xpix(&x->x_obj, glist) ))/((float)x->x_width/(float)x->x_nvalues);
- newvalue = ((float)(text_ypix(&x->x_obj, glist) + x->x_height - ypix))/( (float)x->x_height/(float)x->x_noccurrences);
-
- // post( "changed %d to %d", nevent, newvalue );
-
- // consistency check
- if ( nevent < 0 )
- {
- post( "probalizer : warning : negative event : %d", nevent );
- nevent = 0;
- }
- if ( nevent > x->x_nvalues - 1 )
- {
- post( "probalizer : warning : event bigger than number of values: %d", nevent );
- nevent = x->x_nvalues - 1 ;
- }
- if ( newvalue < 0 )
- {
- post( "probalizer : warning : negative value : %d", newvalue );
- newvalue = 0;
- }
- if ( newvalue > x->x_noccurrences )
- {
- post( "probalizer : warning : value bigger than max occurrences : %d", newvalue );
- newvalue = x->x_noccurrences ;
- }
-
- *( x->x_probs + nevent ) = newvalue;
- // reset all counters
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- probalizer_draw_update( x );
- }
- return (1);
-}
-
-static t_probalizer *probalizer_new(t_symbol *s, int argc, t_atom *argv)
-{
- int bi, i, ei;
- t_probalizer *x;
- t_pd *x2;
-
- // post( "probalizer_new : create : %s argc =%d", s->s_name, argc );
-
- x = (t_probalizer *)pd_new(probalizer_class);
- // create float output
- outlet_new(&x->x_obj, &s_float);
- // create bang output
- x->x_endoutlet = outlet_new(&x->x_obj, &s_bang);
-
- // new probalizer created from the gui
- if ( argc != 0 )
- {
- if ( argc < 5 )
- {
- post( "probalizer : error in the number of arguments ( %d )", argc );
- return NULL;
- }
- if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ||
- argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ||
- argv[4].a_type != A_FLOAT )
- {
- post( "probalizer : wrong arguments" );
- return NULL;
- }
-
- x->x_width = argv[0].a_w.w_float;
- x->x_height = argv[1].a_w.w_float;
- x->x_nvalues = argv[2].a_w.w_float;
- if ( x->x_nvalues < 1 ) x->x_nvalues = 1;
- x->x_noccurrences = argv[3].a_w.w_float;
- if ( x->x_noccurrences < 1 ) x->x_noccurrences = 1;
- x->x_save = argv[4].a_w.w_float;
- }
- else
- {
- x->x_width = DEFAULT_PROBALIZER_WIDTH;
- x->x_height = DEFAULT_PROBALIZER_HEIGHT;
- x->x_nvalues = DEFAULT_PROBALIZER_NBVALUES;
- x->x_noccurrences = DEFAULT_PROBALIZER_NBOCCURRENCES;
- x->x_save = 1;
- }
- // common fields for new and restored probalizers
- x->x_probs = (t_int*) getbytes( x->x_nvalues*sizeof(t_int) );
- if ( !x->x_probs )
- {
- error( "probalizer : could not allocate buffer" );
- return NULL;
- }
- x->x_ovalues = (t_int*) getbytes( x->x_nvalues*sizeof(t_int) );
- if ( !x->x_ovalues )
- {
- error( "probalizer : could not allocate buffer" );
- return NULL;
- }
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- *(x->x_probs+ei)=DEFAULT_PROB_VALUE;
- }
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- x->x_selected = 0;
- x->x_glist = (t_glist *) canvas_getcurrent();
-
- // post( "probalizer : argc : %d", argc );
- if ( ( argc != 0 ) && ( x->x_save ) )
- {
- int ai = 5;
- int si = 0;
-
- while ( ai < argc - 1 )
- {
- *(x->x_probs + (int)argv[ai].a_w.w_float) = (int)argv[ai+1].a_w.w_float;
- ai += 2;
- }
- }
- // post( "probalizer_new width: %d height : %d", x->x_width, x->x_height );
-
- return (x);
-}
-
-/* zero counters */
-static void probalizer_zero(t_probalizer *x)
-{
- t_int ei;
-
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- *(x->x_probs+ei)=0;
- }
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- probalizer_draw_update( x );
-}
-
-/* the core of it, output an integer value out of the serial */
-static void probalizer_bang(t_probalizer *x)
-{
- t_int ei, ci;
- t_int *candidates;
- t_int nbcandidates = 0;
- t_int nevalues=0;
-
- // calculate number of eligible values
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- nevalues += ( *(x->x_probs+ei) - *(x->x_ovalues+ei) );
- }
-
- if ( nevalues == 0 )
- {
- error( "probalizer : probabilities are null, sorry" );
- return;
- }
-
- candidates = ( t_int* ) getbytes( nevalues*sizeof( t_int ) );
- if ( !candidates )
- {
- error( "probalizer : could not allocate buffer for internal computation" );
- return;
- }
-
- // select eligible values
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- if( *(x->x_ovalues+ei) < *(x->x_probs+ei) )
- {
- for ( ci=0; ci<*(x->x_probs+ei) - *(x->x_ovalues+ei); ci++)
- {
- *(candidates+nbcandidates) = ei;
- nbcandidates++;
- }
- }
- }
-
- // output one of the values
- {
- int chosen = random() % nbcandidates;
- int volue = *(candidates+chosen);
-
- outlet_float( x->x_obj.ob_outlet, volue+1 );
- *(x->x_ovalues+volue) = *(x->x_ovalues+volue) + 1;
- // for ( ei=0; ei<nbcandidates; ei++ )
- // {
- // post( "probalizer : output : %d", *(x->x_ovalues+*(candidates+ei)) );
- // }
-
- // test end of the serial
- if (nbcandidates == 1 )
- {
- // post( "probalizer : end of the serial" );
- outlet_bang( x->x_endoutlet );
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- }
- }
-
- if ( candidates )
- {
- freebytes( candidates, nevalues*sizeof( t_int ) );
- }
-}
-
-/* increase a probability if possible */
-static void probalizer_float(t_probalizer *x, t_float fvalue)
-{
- if ( ( (fvalue-1 ) < 0 ) || ( (fvalue-1 ) >= x->x_nvalues ) )
- {
- post( "probalizer : wrong float value : %d", (int)fvalue );
- return;
- }
- if ( ( *(x->x_probs+(int)(fvalue-1))+1 ) <= x->x_noccurrences )
- {
- *(x->x_probs+(int)(fvalue-1))+=1;
- probalizer_draw_update( x );
- }
-}
-
-/* reset output */
-static void probalizer_reset(t_probalizer *x)
-{
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
-}
-
-/* equi probability */
-static void probalizer_equi(t_probalizer *x)
-{
- t_int ei;
-
- for ( ei=0; ei<x->x_nvalues; ei++ )
- {
- *(x->x_probs+ei)=1;
- }
- memset( x->x_ovalues, 0x0, x->x_nvalues*sizeof(t_int) );
- probalizer_draw_update( x );
-}
-
-static void probalizer_free(t_probalizer *x)
-{
- t_int ei;
-
- if ( x->x_probs )
- {
- freebytes( x->x_probs, x->x_nvalues*sizeof(int) );
- }
- if ( x->x_ovalues )
- {
- freebytes( x->x_ovalues, x->x_nvalues*sizeof(int) );
- }
-}
-
-void probalizer_setup(void)
-{
- post( probalizer_version );
-#include "probalizer.tk2c"
- probalizer_class = class_new(gensym("probalizer"), (t_newmethod)probalizer_new,
- (t_method)probalizer_free, sizeof(t_probalizer), 0, A_GIMME, 0);
- class_addmethod(probalizer_class, (t_method)probalizer_dialog, gensym("dialog"), A_GIMME, 0);
- class_addmethod(probalizer_class, (t_method)probalizer_float, &s_float, A_FLOAT, 0);
- class_addmethod(probalizer_class, (t_method)probalizer_bang, &s_bang, 0);
- class_addmethod(probalizer_class, (t_method)probalizer_zero, gensym("zero"), 0);
- class_addmethod(probalizer_class, (t_method)probalizer_equi, gensym("equi"), 0);
- class_addmethod(probalizer_class, (t_method)probalizer_reset, gensym("reset"), 0);
- probalizer_widgetbehavior.w_getrectfn = probalizer_getrect;
- probalizer_widgetbehavior.w_displacefn = probalizer_displace;
- probalizer_widgetbehavior.w_selectfn = probalizer_select;
- probalizer_widgetbehavior.w_activatefn = NULL;
- probalizer_widgetbehavior.w_deletefn = probalizer_delete;
- probalizer_widgetbehavior.w_visfn = probalizer_vis;
- probalizer_widgetbehavior.w_clickfn = probalizer_click;
-
-#if PD_MINOR_VERSION >= 37
- class_setpropertiesfn(probalizer_class, probalizer_properties);
- class_setsavefn(probalizer_class, probalizer_save);
-#else
- probalizer_widgetbehavior.w_propertiesfn = probalizer_properties;
- probalizer_widgetbehavior.w_savefn = probalizer_save;
-#endif
-
- class_setwidget(probalizer_class, &probalizer_widgetbehavior);
-
-}
diff --git a/probalizer/probalizer.h b/probalizer/probalizer.h
deleted file mode 100644
index 51c9711..0000000
--- a/probalizer/probalizer.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (c) 2002 Yves Degoyon
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* probalizer : outputs integer values according to a drawn probability curve
-*/
-
-#ifndef __G_PROBALIZER_H
-#define __G_PROBALIZER_H
-
-typedef struct _probalizer
-{
- t_object x_obj;
- t_glist *x_glist;
- t_int x_height; /* height of the probalizer */
- t_int x_width; /* width of the probalizer */
- t_int x_nvalues; /* number of values */
- t_int x_noccurrences; /* max number of occurrences in a serial */
- t_int *x_probs; /* probability of each event */
- t_int *x_ovalues; /* number of outputs of each event */
- int x_selected; /* stores selected state */
- int x_save; /* saving contents flag */
- t_outlet *x_endoutlet; /* outlet to signal the end of the serial */
-} t_probalizer;
-
-#endif
diff --git a/probalizer/probalizer.tk b/probalizer/probalizer.tk
deleted file mode 100644
index 2f069e9..0000000
--- a/probalizer/probalizer.tk
+++ /dev/null
@@ -1,113 +0,0 @@
-############ probalizer procedures -- ydegoyon@free.fr #########
-
-proc probalizer_apply {id} {
-# strip "." from the TK id to make a variable name suffix
- set vid [string trimleft $id .]
-# for each variable, make a local variable to hold its name...
- set var_graph_width [concat graph_width_$vid]
- global $var_graph_width
- set var_graph_height [concat graph_height_$vid]
- global $var_graph_height
- set var_graph_nvalues [concat graph_nvalues_$vid]
- global $var_graph_nvalues
- set var_graph_noccurrences [concat graph_noccurrences_$vid]
- global $var_graph_noccurrences
- set var_graph_save [concat graph_save_$vid]
- global $var_graph_save
-
- set cmd [concat $id dialog \
- [eval concat $$var_graph_width] \
- [eval concat $$var_graph_height] \
- [eval concat $$var_graph_nvalues] \
- [eval concat $$var_graph_noccurrences] \
- [eval concat $$var_graph_save] \;]
- #puts stderr $cmd
- pd $cmd
-}
-
-proc probalizer_cancel {id} {
- set cmd [concat $id cancel \;]
- #puts stderr $cmd
- pd $cmd
-}
-
-proc probalizer_ok {id} {
- probalizer_apply $id
- probalizer_cancel $id
-}
-
-proc pdtk_probalizer_dialog {id width height nvalues noccurrences save } {
- set vid [string trimleft $id .]
-
- set var_graph_width [concat graph_width_$vid]
- global $var_graph_width
- set var_graph_height [concat graph_height_$vid]
- global $var_graph_height
- set var_graph_nvalues [concat graph_nvalues_$vid]
- global $var_graph_nvalues
- set var_graph_noccurrences [concat graph_noccurrences_$vid]
- global $var_graph_noccurrences
- set var_graph_save [concat graph_save_$vid]
- global $var_graph_save
-
- set $var_graph_width $width
- set $var_graph_height $height
- set $var_graph_nvalues $nvalues
- set $var_graph_noccurrences $noccurrences
- set $var_graph_save $save
-
- toplevel $id
- wm title $id {probalizer}
- wm protocol $id WM_DELETE_WINDOW [concat probalizer_cancel $id]
-
- label $id.label -text {PROBALIZER PROPERTIES}
- pack $id.label -side top
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "probalizer_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "probalizer_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "probalizer_ok $id"
- pack $id.buttonframe.cancel -side left -expand 1
- pack $id.buttonframe.apply -side left -expand 1
- pack $id.buttonframe.ok -side left -expand 1
-
- frame $id.1rangef
- pack $id.1rangef -side top
- label $id.1rangef.lwidth -text "Width :"
- entry $id.1rangef.width -textvariable $var_graph_width -width 7
- pack $id.1rangef.lwidth $id.1rangef.width -side left
-
- frame $id.2rangef
- pack $id.2rangef -side top
- label $id.2rangef.lheight -text "Height :"
- entry $id.2rangef.height -textvariable $var_graph_height -width 7
- pack $id.2rangef.lheight $id.2rangef.height -side left
-
- frame $id.3rangef
- pack $id.3rangef -side top
- label $id.3rangef.lnvalues -text "Values :"
- entry $id.3rangef.nvalues -textvariable $var_graph_nvalues -width 7
- pack $id.3rangef.lnvalues $id.3rangef.nvalues -side left
-
- frame $id.4rangef
- pack $id.4rangef -side top
- label $id.4rangef.lnoccurrences -text "Max Occurrences :"
- entry $id.4rangef.noccurrences -textvariable $var_graph_noccurrences -width 7
- pack $id.4rangef.lnoccurrences $id.4rangef.noccurrences -side left
-
- checkbutton $id.save -text {Save contents} -variable $var_graph_save \
- -anchor w
- pack $id.save -side top
-
- bind $id.1rangef.width <KeyPress-Return> [concat probalizer_ok $id]
- bind $id.2rangef.height <KeyPress-Return> [concat probalizer_ok $id]
- bind $id.3rangef.nvalues <KeyPress-Return> [concat probalizer_ok $id]
- bind $id.4rangef.noccurrences <KeyPress-Return> [concat probalizer_ok $id]
- focus $id.1rangef.width
-}
-
-############ probalizer procedures END -- ydegoyon@free.fr #########
diff --git a/probalizer/probalizer.tk2c b/probalizer/probalizer.tk2c
deleted file mode 100755
index b4a608c..0000000
--- a/probalizer/probalizer.tk2c
+++ /dev/null
@@ -1,87 +0,0 @@
-// ########### probalizer procedures -- ydegoyon@free.fr #########
-sys_gui("proc probalizer_apply {id} {\n");
-// strip "." from the TK id to make a variable name suffix
-sys_gui("set vid [string trimleft $id .]\n");
-// for each variable, make a local variable to hold its name...
-sys_gui("set var_graph_width [concat graph_width_$vid]\n");
-sys_gui("global $var_graph_width\n");
-sys_gui("set var_graph_height [concat graph_height_$vid]\n");
-sys_gui("global $var_graph_height\n");
-sys_gui("set var_graph_nvalues [concat graph_nvalues_$vid]\n");
-sys_gui("global $var_graph_nvalues\n");
-sys_gui("set var_graph_noccurrences [concat graph_noccurrences_$vid]\n");
-sys_gui("global $var_graph_noccurrences\n");
-sys_gui("set var_graph_save [concat graph_save_$vid]\n");
-sys_gui("global $var_graph_save\n");
-sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_nvalues] [eval concat $$var_graph_noccurrences] [eval concat $$var_graph_save] \\;]\n");
-// puts stderr $cmd
-sys_gui("pd $cmd\n");
-sys_gui("}\n");
-sys_gui("proc probalizer_cancel {id} {\n");
-sys_gui("set cmd [concat $id cancel \\;]\n");
-// puts stderr $cmd
-sys_gui("pd $cmd\n");
-sys_gui("}\n");
-sys_gui("proc probalizer_ok {id} {\n");
-sys_gui("probalizer_apply $id\n");
-sys_gui("probalizer_cancel $id\n");
-sys_gui("}\n");
-sys_gui("proc pdtk_probalizer_dialog {id width height nvalues noccurrences save } {\n");
-sys_gui("set vid [string trimleft $id .]\n");
-sys_gui("set var_graph_width [concat graph_width_$vid]\n");
-sys_gui("global $var_graph_width\n");
-sys_gui("set var_graph_height [concat graph_height_$vid]\n");
-sys_gui("global $var_graph_height\n");
-sys_gui("set var_graph_nvalues [concat graph_nvalues_$vid]\n");
-sys_gui("global $var_graph_nvalues\n");
-sys_gui("set var_graph_noccurrences [concat graph_noccurrences_$vid]\n");
-sys_gui("global $var_graph_noccurrences\n");
-sys_gui("set var_graph_save [concat graph_save_$vid]\n");
-sys_gui("global $var_graph_save\n");
-sys_gui("set $var_graph_width $width\n");
-sys_gui("set $var_graph_height $height\n");
-sys_gui("set $var_graph_nvalues $nvalues\n");
-sys_gui("set $var_graph_noccurrences $noccurrences\n");
-sys_gui("set $var_graph_save $save\n");
-sys_gui("toplevel $id\n");
-sys_gui("wm title $id {probalizer}\n");
-sys_gui("wm protocol $id WM_DELETE_WINDOW [concat probalizer_cancel $id]\n");
-sys_gui("label $id.label -text {PROBALIZER PROPERTIES}\n");
-sys_gui("pack $id.label -side top\n");
-sys_gui("frame $id.buttonframe\n");
-sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n");
-sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"probalizer_cancel $id\"\n");
-sys_gui("button $id.buttonframe.apply -text {Apply} -command \"probalizer_apply $id\"\n");
-sys_gui("button $id.buttonframe.ok -text {OK} -command \"probalizer_ok $id\"\n");
-sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n");
-sys_gui("pack $id.buttonframe.apply -side left -expand 1\n");
-sys_gui("pack $id.buttonframe.ok -side left -expand 1\n");
-sys_gui("frame $id.1rangef\n");
-sys_gui("pack $id.1rangef -side top\n");
-sys_gui("label $id.1rangef.lwidth -text \"Width :\"\n");
-sys_gui("entry $id.1rangef.width -textvariable $var_graph_width -width 7\n");
-sys_gui("pack $id.1rangef.lwidth $id.1rangef.width -side left\n");
-sys_gui("frame $id.2rangef\n");
-sys_gui("pack $id.2rangef -side top\n");
-sys_gui("label $id.2rangef.lheight -text \"Height :\"\n");
-sys_gui("entry $id.2rangef.height -textvariable $var_graph_height -width 7\n");
-sys_gui("pack $id.2rangef.lheight $id.2rangef.height -side left\n");
-sys_gui("frame $id.3rangef\n");
-sys_gui("pack $id.3rangef -side top\n");
-sys_gui("label $id.3rangef.lnvalues -text \"Values :\"\n");
-sys_gui("entry $id.3rangef.nvalues -textvariable $var_graph_nvalues -width 7\n");
-sys_gui("pack $id.3rangef.lnvalues $id.3rangef.nvalues -side left\n");
-sys_gui("frame $id.4rangef\n");
-sys_gui("pack $id.4rangef -side top\n");
-sys_gui("label $id.4rangef.lnoccurrences -text \"Max Occurrences :\"\n");
-sys_gui("entry $id.4rangef.noccurrences -textvariable $var_graph_noccurrences -width 7\n");
-sys_gui("pack $id.4rangef.lnoccurrences $id.4rangef.noccurrences -side left\n");
-sys_gui("checkbutton $id.save -text {Save contents} -variable $var_graph_save -anchor w\n");
-sys_gui("pack $id.save -side top\n");
-sys_gui("bind $id.1rangef.width <KeyPress-Return> [concat probalizer_ok $id]\n");
-sys_gui("bind $id.2rangef.height <KeyPress-Return> [concat probalizer_ok $id]\n");
-sys_gui("bind $id.3rangef.nvalues <KeyPress-Return> [concat probalizer_ok $id]\n");
-sys_gui("bind $id.4rangef.noccurrences <KeyPress-Return> [concat probalizer_ok $id]\n");
-sys_gui("focus $id.1rangef.width\n");
-sys_gui("}\n");
-// ########### probalizer procedures END -- ydegoyon@free.fr #########
diff --git a/probalizer/tk2c.bash b/probalizer/tk2c.bash
deleted file mode 100755
index 9dfeb03..0000000
--- a/probalizer/tk2c.bash
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-#set -x
-
-while read line
-do
- for word in $line
- do
- if [ "X"$word != "X"${word#\#} ]
- then
- echo // ${line#\#}
- break
- else
- line=${line//\'/\\\'}
-#useless, slashes never gets in
- line=${line//\\/\\\\}
-#this one's dirty, i know
- line=${line//;/\\\\;}
- line=${line//\"/\\\"}
- echo 'sys_gui("'$line'\n");'
- break
- fi
- done
-done