aboutsummaryrefslogtreecommitdiff
path: root/pianoroll
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 08:42:27 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 08:42:27 +0000
commit42750d74dc03be5fc10e56f3c534e854680c7d17 (patch)
tree560c964aefcbf20791f8ab9bce9176088160126b /pianoroll
parentdf8f6ea4605606562341adf83cd4fc450490ccb6 (diff)
added files straight from Yves' sources
svn path=/trunk/externals/unauthorized/; revision=859
Diffstat (limited to 'pianoroll')
-rw-r--r--pianoroll/CHANGES.LOG16
-rw-r--r--pianoroll/INSTALL15
-rw-r--r--pianoroll/README18
-rw-r--r--pianoroll/help-pianoroll.pd80
-rw-r--r--pianoroll/pattern#11
-rw-r--r--pianoroll/pianoroll.c806
-rw-r--r--pianoroll/pianoroll.h40
-rw-r--r--pianoroll/pianoroll.tk164
8 files changed, 1140 insertions, 0 deletions
diff --git a/pianoroll/CHANGES.LOG b/pianoroll/CHANGES.LOG
new file mode 100644
index 0000000..59034b6
--- /dev/null
+++ b/pianoroll/CHANGES.LOG
@@ -0,0 +1,16 @@
+0.7
+ added "pitch x y" and "volume x y" messages
+0.6
+ added capability of saving and restoring patterns with "save" and "load" messages
+0.5
+ added init message
+0.4
+ fixed : last volume was not restored properly
+0.3
+ added the ability to be scanned backwards
+0.2
+ added interpolation : getting values for non-integer input
+ this enables glissando
+ fixed double-view pitches
+0.1
+ basic implementation of a sequencer's like pianoroll
diff --git a/pianoroll/INSTALL b/pianoroll/INSTALL
new file mode 100644
index 0000000..b7c38be
--- /dev/null
+++ b/pianoroll/INSTALL
@@ -0,0 +1,15 @@
+untar in /my/pd/dir/externs
+
+cd /my/pd/dir/externs/pianoroll
+
+make clean
+
+make
+
+make install
+
+open help-pianoroll.pd
+
+Thanx for getting here.
+Yves/
+comments and bugs @ ydegoyon@free.fr
diff --git a/pianoroll/README b/pianoroll/README
new file mode 100644
index 0000000..dfbf642
--- /dev/null
+++ b/pianoroll/README
@@ -0,0 +1,18 @@
+Version 0.01
+copyleft 2001 by Yves Degoyon
+tarballs and updates available @ http://ydegoyon.free.fr
+
+pianoroll : a graphical sequencer controller
+
+To install pianoroll, follow the steps from INSTALL
+
+This software is published under GPL terms.
+
+This is software with ABSOLUTELY NO WARRANTY.
+Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing
+due to a bug or for other reasons.
+We do not warrant that the program is free of infringement of any third-party
+patents.
+
+*****************************************************************************
+
diff --git a/pianoroll/help-pianoroll.pd b/pianoroll/help-pianoroll.pd
new file mode 100644
index 0000000..809fec9
--- /dev/null
+++ b/pianoroll/help-pianoroll.pd
@@ -0,0 +1,80 @@
+#N canvas 90 41 827 643 10;
+#X floatatom 71 402 5 0 0;
+#X floatatom 258 400 5 0 0;
+#X text 523 112 (invoke with <right mouse>Properties );
+#X text 524 101 You can set the following properties :;
+#X text 548 141 * Width : graphical x size;
+#X text 548 152 * Height : graphical y size;
+#X text 488 548 bugs and comments @ ydegoyon@free.fr;
+#X msg 587 271 \; pd dsp 0;
+#X msg 653 271 \; pd dsp 1;
+#X text 548 129 * Name;
+#X text 119 401 Pitch;
+#X text 304 399 Volume ( scaled to [0 \, 1] );
+#X text 547 164 * Pitch min : minimum value delivered by left outlet
+;
+#X text 547 176 * Pitch max : maximum value delivered by left outlet
+;
+#X text 547 200 * Step number : number of steps;
+#X text 524 79 ( pitch & volume originally but \, really \, anything
+you like );
+#X msg 238 87 transpose \$1;
+#X floatatom 334 89 5 0 0;
+#X text 240 104 You can transpose the melody ( ?? );
+#X text 241 115 with a float value;
+#X text 548 211 * Default value : must be in [min \, max];
+#X obj 65 165 pianoroll pianoroll1 400 192 -15 15 32 16 0 0 1 -12.0968
+0.741935 -3.3871 0.16129 5.32258 0.16129 -4.35484 0.354839 6.29032
+0.322581 6.29032 1 5.32258 1 -12.0968 0.290323 -10.1613 0.290323 -8.22581
+0.580645 -5.32258 1 7.25807 1 -10.1613 0.580645 -15 0.612903 -15 0.580645
+-15 1;
+#X msg 47 18 bang;
+#X obj 46 80 f;
+#X obj 76 80 + 1;
+#X floatatom 9 104 5 0 0;
+#X obj 47 44 metro 500;
+#X text 527 65 Pianoroll controls two parameters for a sequencer;
+#X text 548 188 * Pitch grades : number of grades for the pitch;
+#X msg 82 18 stop;
+#X floatatom 13 140 5 0 0;
+#X text 57 1 forward;
+#X text 144 0 backward;
+#X msg 136 15 bang;
+#X obj 135 77 f;
+#X obj 136 41 metro 500;
+#X msg 171 16 stop;
+#X obj 165 77 - 1;
+#X msg 239 59 init;
+#X text 279 60 init to default values;
+#X msg 241 33 load pattern#1;
+#X text 352 19 load and save the patterns;
+#X text 352 31 ( values as well as steps number .... );
+#X msg 241 10 save pattern#1;
+#X text 544 383 you can set the pitch and;
+#X text 544 397 the volume with messages;
+#X text 544 409 ( positions start at zero );
+#X msg 541 358 volume 3 0.345;
+#X msg 542 334 pitch 3 -5;
+#X connect 16 0 21 0;
+#X connect 17 0 16 0;
+#X connect 21 0 0 0;
+#X connect 21 1 1 0;
+#X connect 22 0 26 0;
+#X connect 23 0 21 0;
+#X connect 23 0 24 0;
+#X connect 23 0 25 0;
+#X connect 24 0 23 1;
+#X connect 26 0 23 0;
+#X connect 29 0 26 0;
+#X connect 30 0 21 0;
+#X connect 33 0 35 0;
+#X connect 34 0 37 0;
+#X connect 34 0 21 0;
+#X connect 35 0 34 0;
+#X connect 36 0 35 0;
+#X connect 37 0 34 1;
+#X connect 38 0 21 0;
+#X connect 40 0 21 0;
+#X connect 43 0 21 0;
+#X connect 47 0 21 0;
+#X connect 48 0 21 0;
diff --git a/pianoroll/pattern#1 b/pianoroll/pattern#1
new file mode 100644
index 0000000..e9e4ecb
--- /dev/null
+++ b/pianoroll/pattern#1
@@ -0,0 +1 @@
+400 192 -15.000000 15.000000 32 16 0 0.000000 1 -12.096774 0.741935 -3.387097 0.258065 5.322581 0.161290 3.387097 0.032258 -5.322581 0.322581 10.161290 1.000000 5.322581 1.000000 -12.096774 0.290323 -10.161290 0.290323 -8.225806 0.580645 -5.322581 1.000000 7.258065 1.000000 -10.161290 0.580645 -15.000000 0.612903 -15.000000 0.580645 -15.000000 1.000000 \ No newline at end of file
diff --git a/pianoroll/pianoroll.c b/pianoroll/pianoroll.c
new file mode 100644
index 0000000..9f97f05
--- /dev/null
+++ b/pianoroll/pianoroll.c
@@ -0,0 +1,806 @@
+/* Copyright (c) 1997-1999 Miller Puckette. */
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */
+/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+/* */
+/* pianoroll : a graphical object which enables */
+/* to control a sequencer ( pitch and volume ) */
+/* */
+/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */
+/* */
+/* 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. */
+/* */
+/* "If you obey society's rules" */
+/* "You'll be society's fool" */
+/* Devo - Society's rules */
+/* ---------------------------------------------------------------------------- */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <ctype.h>
+#include "m_imp.h"
+#include "g_canvas.h"
+#include "t_tk.h"
+#include "pianoroll.h"
+
+#ifdef NT
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* needed to create a pianoroll from PD's menu
+void canvas_objtext(t_glist *gl, int xpos, int ypos, int selected, t_binbuf *b);
+void canvas_startmotion(t_canvas *x);
+*/
+
+#define DEFAULT_SEQUENCER_WIDTH 200
+#define DEFAULT_SEQUENCER_HEIGHT 200
+#define DEFAULT_SEQUENCER_STEPS 16
+#define DEFAULT_SEQUENCER_NBGRADES 31
+#define DEFAULT_SEQUENCER_PITCH_MIN -15
+#define DEFAULT_SEQUENCER_PITCH_MAX 15
+
+static char *pianoroll_version = "pianoroll: a graphical sequencer controller, version 0.7 (ydegoyon@free.fr)";
+
+t_widgetbehavior pianoroll_widgetbehavior;
+static t_class *pianoroll_class;
+static int pianorollcount=0;
+
+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_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_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)
+
+/* drawing functions */
+static void pianoroll_draw_update(t_pianoroll *x, t_glist *glist)
+{
+ int si;
+
+ t_canvas *canvas=glist_getcanvas(glist);
+ for ( si=0; si<x->x_nbsteps; si++ )
+ {
+ int vi = (int)((1.0-x->x_volumes[si])*(x->x_nbgrades-1));
+ int pi = (int)((x->x_pmax-x->x_peaches[si])/(x->x_pmax-x->x_pmin)*(x->x_nbgrades-1));
+
+ x->x_ivolumes[ si ] = vi;
+ x->x_ipeaches[ si ] = pi;
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, pi);
+ SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, vi);
+ }
+}
+
+static void pianoroll_draw_new(t_pianoroll *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ // draw the grid
+ {
+ int gi, gj;
+ t_float xgstep = x->x_width/x->x_nbsteps;
+ t_float ygstep = x->x_height/x->x_nbgrades;
+ for ( gi=0; gi<x->x_nbsteps; gi++ )
+ {
+ for ( gj=0; gj<x->x_nbgrades; gj++ )
+ {
+ SYS_VGUI9(".x%x.c create rectangle %d %d %d %d -fill #771623 -outline #998121 -tags %xPITCH%.4d%.4d\n",
+ canvas,
+ x->x_obj.te_xpix+(int)(gi*xgstep),
+ x->x_obj.te_ypix+(int)(gj*ygstep),
+ x->x_obj.te_xpix+(int)(gi*xgstep)+(int)(2*xgstep/3),
+ x->x_obj.te_ypix+(int)((gj+1)*ygstep),
+ x, gi, gj );
+ SYS_VGUI9(".x%x.c create rectangle %d %d %d %d -fill #562663 -outline #998121 -tags %xVOLUME%.4d%.4d\n",
+ canvas,
+ x->x_obj.te_xpix+(int)(gi*xgstep)+(int)(2*xgstep/3),
+ x->x_obj.te_ypix+(int)(gj*ygstep),
+ x->x_obj.te_xpix+(int)((gi+1)*xgstep),
+ x->x_obj.te_ypix+(int)((gj+1)*ygstep),
+ x, gi, gj );
+ }
+ }
+ // adjust height and width
+ x->x_width = (int)((x->x_nbsteps)*xgstep);
+ x->x_height = (int)((x->x_nbgrades)*ygstep);
+ }
+ SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xIN\n",
+ canvas, x->x_obj.te_xpix, x->x_obj.te_ypix - 1,
+ x->x_obj.te_xpix+7, x->x_obj.te_ypix,
+ x);
+ SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xOUTL\n",
+ canvas, x->x_obj.te_xpix, x->x_obj.te_ypix + x->x_height+1,
+ x->x_obj.te_xpix+7, x->x_obj.te_ypix + x->x_height+2,
+ x);
+ SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xOUTR\n",
+ canvas, x->x_obj.te_xpix+x->x_width-7, x->x_obj.te_ypix + x->x_height+1,
+ x->x_obj.te_xpix+x->x_width, x->x_obj.te_ypix + x->x_height+2,
+ x);
+
+ canvas_fixlinesfor( canvas, (t_text*)x );
+}
+
+static void pianoroll_draw_move(t_pianoroll *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ // move the grid
+ {
+ int gi, gj;
+ t_float xgstep = x->x_width/x->x_nbsteps;
+ t_float ygstep = x->x_height/x->x_nbgrades;
+ for ( gi=0; gi<x->x_nbsteps; gi++ )
+ {
+ for ( gj=0; gj<x->x_nbgrades; gj++ )
+ {
+ SYS_VGUI9(".x%x.c coords %xPITCH%.4d%.4d %d %d %d %d\n",
+ canvas, x, gi, gj,
+ x->x_obj.te_xpix+(int)(gi*xgstep),
+ x->x_obj.te_ypix+(int)(gj*ygstep),
+ x->x_obj.te_xpix+(int)(gi*xgstep)+(int)(2*xgstep/3),
+ x->x_obj.te_ypix+(int)((gj+1)*ygstep)
+ );
+ SYS_VGUI9(".x%x.c coords %xVOLUME%.4d%.4d %d %d %d %d\n",
+ canvas, x, gi, gj,
+ x->x_obj.te_xpix+(int)(gi*xgstep)+(int)(2*xgstep/3),
+ x->x_obj.te_ypix+(int)(gj*ygstep),
+ x->x_obj.te_xpix+(int)((gi+1)*xgstep),
+ x->x_obj.te_ypix+(int)((gj+1)*ygstep)
+ );
+ }
+ }
+ }
+ SYS_VGUI7(".x%x.c coords %xIN %d %d %d %d \n",
+ canvas, x, x->x_obj.te_xpix, x->x_obj.te_ypix - 1,
+ x->x_obj.te_xpix+7, x->x_obj.te_ypix
+ );
+ SYS_VGUI7(".x%x.c coords %xOUTL %d %d %d %d\n",
+ canvas, x, x->x_obj.te_xpix, x->x_obj.te_ypix + x->x_height+1,
+ x->x_obj.te_xpix+7, x->x_obj.te_ypix + x->x_height+2
+ );
+ SYS_VGUI7(".x%x.c coords %xOUTR %d %d %d %d\n",
+ canvas, x, x->x_obj.te_xpix+x->x_width-7, x->x_obj.te_ypix + x->x_height+1,
+ x->x_obj.te_xpix+x->x_width, x->x_obj.te_ypix + x->x_height+2
+ );
+ canvas_fixlinesfor( canvas, (t_text*)x );
+}
+
+static void pianoroll_draw_erase(t_pianoroll* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int i;
+
+ SYS_VGUI3(".x%x.c delete %xIN\n", canvas, x);
+ SYS_VGUI3(".x%x.c delete %xOUTL\n", canvas, x);
+ SYS_VGUI3(".x%x.c delete %xOUTR\n", canvas, x);
+ // delete the grid
+ {
+ int gi, gj;
+ for ( gi=0; gi<x->x_nbsteps; gi++ )
+ {
+ for ( gj=0; gj<x->x_nbgrades; gj++ )
+ {
+ SYS_VGUI5(".x%x.c delete %xPITCH%.4d%.4d\n", canvas, x, gi, gj);
+ SYS_VGUI5(".x%x.c delete %xVOLUME%.4d%.4d\n", canvas, x, gi, gj);
+ }
+ }
+ }
+}
+
+static void pianoroll_draw_select(t_pianoroll* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_selected)
+ {
+ pd_bind(&x->x_obj.ob_pd, x->x_name);
+ /* sets the item in blue */
+ }
+ else
+ {
+ pd_unbind(&x->x_obj.ob_pd, x->x_name);
+ }
+}
+
+/* ------------------------ pianoroll widgetbehaviour----------------------------- */
+
+
+static void pianoroll_getrect(t_gobj *z, t_glist *owner,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_pianoroll* x = (t_pianoroll*)z;
+
+ *xp1 = x->x_obj.te_xpix;
+ *yp1 = x->x_obj.te_ypix;
+ *xp2 = x->x_obj.te_xpix+x->x_width;
+ *yp2 = x->x_obj.te_ypix+x->x_height;
+}
+
+static void pianoroll_save(t_gobj *z, t_binbuf *b)
+{
+ t_pianoroll *x = (t_pianoroll *)z;
+ int i;
+
+ // post( "saving pianoroll : %s", x->x_name->s_name );
+ binbuf_addv(b, "ssiissiiffiiifi", gensym("#X"),gensym("obj"),
+ (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
+ gensym("pianoroll"), x->x_name, x->x_width, x->x_height,
+ x->x_pmin, x->x_pmax,
+ x->x_nbgrades, x->x_nbsteps,
+ x->x_defvalue, x->x_transpose, x->x_save
+ );
+ if ( x->x_save )
+ {
+ for ( i=0; i<x->x_nbsteps; i++ )
+ {
+ binbuf_addv(b, "ff", x->x_peaches[i], x->x_volumes[i] );
+ }
+ }
+ binbuf_addv(b, ";");
+}
+
+static void pianoroll_properties(t_gobj *z, t_glist *owner)
+{
+ char buf[800];
+ t_pianoroll *x=(t_pianoroll *)z;
+
+ sprintf(buf, "pdtk_pianoroll_dialog %%s %s %d %d %.2f %.2f %d %d %d %d\n",
+ x->x_name->s_name, x->x_width, x->x_height, x->x_pmin, x->x_pmax,
+ x->x_nbgrades, x->x_nbsteps, x->x_defvalue, x->x_save );
+ // post("pianoroll_properties : %s", buf );
+ gfxstub_new(&x->x_obj.ob_pd, x, buf);
+}
+
+static void pianoroll_select(t_gobj *z, t_glist *glist, int selected)
+{
+ t_pianoroll *x = (t_pianoroll *)z;
+
+ x->x_selected = selected;
+ pianoroll_draw_select( x, glist );
+}
+
+static void pianoroll_vis(t_gobj *z, t_glist *glist, int vis)
+{
+ t_pianoroll *x = (t_pianoroll *)z;
+ t_rtext *y;
+
+ // post("pianoroll_vis : %d", vis );
+ if (vis)
+ {
+ pianoroll_draw_new( x, glist );
+ pianoroll_draw_update( x, glist );
+ }
+ else
+ {
+ pianoroll_draw_erase( x, glist );
+ }
+}
+
+static void pianoroll_dialog(t_pianoroll *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int si, onbsteps;
+ t_float *newpeaches, *newvolumes;
+
+ if ( !x ) {
+ post( "pianoroll : error :tried to set properties on an unexisting object" );
+ }
+ if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) {
+ post( "pianoroll : error : wrong number of steps or grades" );
+ return;
+ }
+ if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) {
+ post( "pianoroll : error : min pitch is >= to max pitch" );
+ return;
+ }
+ if ( argc != 9 )
+ {
+ post( "pianoroll : error in the number of arguments ( %d )", argc );
+ return;
+ }
+ if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT ||
+ argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ||
+ argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ||
+ argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT ||
+ argv[8].a_type != A_FLOAT
+ ) {
+ post( "pianoroll : wrong arguments" );
+ return;
+ }
+ pianoroll_draw_erase(x, x->x_glist);
+ x->x_name = argv[0].a_w.w_symbol;
+ x->x_width = (int)argv[1].a_w.w_float;
+ x->x_height = (int)argv[2].a_w.w_float;
+ x->x_pmin = argv[3].a_w.w_float;
+ x->x_pmax = argv[4].a_w.w_float;
+ x->x_nbgrades = argv[5].a_w.w_float;
+ onbsteps = x->x_nbsteps;
+ x->x_nbsteps = argv[6].a_w.w_float;
+ x->x_defvalue = argv[7].a_w.w_float;
+ x->x_save = argv[8].a_w.w_float;
+
+ if ( onbsteps != x->x_nbsteps )
+ {
+ int cmindex = ( onbsteps > x->x_nbsteps ) ? x->x_nbsteps : onbsteps;
+
+ newpeaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) );
+ newvolumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) );
+ for ( si=0; si<cmindex ; si++ )
+ {
+ newpeaches[si] = x->x_peaches[si];
+ newvolumes[si] = x->x_volumes[si];
+ }
+ freebytes( x->x_peaches, onbsteps*sizeof( t_float ) );
+ freebytes( x->x_volumes, onbsteps*sizeof( t_float ) );
+ x->x_peaches = newpeaches;
+ x->x_volumes = newvolumes;
+ for ( si=onbsteps; si<x->x_nbsteps; si++ )
+ {
+ x->x_peaches[si] = x->x_defvalue;
+ x->x_volumes[si] = 1.0;
+ }
+ freebytes( x->x_ipeaches, onbsteps*sizeof( t_int ) );
+ freebytes( x->x_ivolumes, onbsteps*sizeof( t_int ) );
+ x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) );
+ }
+ pianoroll_draw_new(x, x->x_glist);
+ pianoroll_draw_update(x, x->x_glist);
+}
+
+static void pianoroll_delete(t_gobj *z, t_glist *glist)
+{
+ canvas_deletelinesfor( glist_getcanvas(glist), (t_text *)z);
+}
+
+static void pianoroll_displace(t_gobj *z, t_glist *glist, int dx, int dy)
+{
+ t_pianoroll *x = (t_pianoroll *)z;
+ int xold = x->x_obj.te_xpix;
+ int yold = x->x_obj.te_ypix;
+
+ // post( "pianoroll_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)
+ {
+ pianoroll_draw_move(x, x->x_glist);
+ }
+}
+
+static int pianoroll_click(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_pianoroll* x = (t_pianoroll *)z;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if ( doit)
+ {
+ // calculate position to update
+ {
+ int si, gi;
+ t_float xgstep = x->x_width/x->x_nbsteps;
+ t_float ygstep = x->x_height/x->x_nbgrades;
+
+ si = ( xpix - x->x_obj.te_xpix ) / xgstep;
+ gi = ( ypix - x->x_obj.te_ypix ) / ygstep;
+
+ // post( "pianoroll : step : %d : grade : %d", si, gi );
+
+ if ( ( xpix - x->x_obj.te_xpix ) > ( si*xgstep+2*xgstep/3 ) )
+ {
+ {
+ SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, si, x->x_ivolumes[ si ] );
+ }
+
+ x->x_volumes[ si ] = (((float)x->x_nbgrades-1-(float)gi))/(float)(x->x_nbgrades-1);
+ SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, gi);
+ x->x_ivolumes[ si ] = gi;
+ }
+ else
+ {
+ {
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, si, x->x_ipeaches[ si ]);
+ }
+
+ x->x_peaches[ si ] = x->x_pmin+(float)(x->x_nbgrades-1-gi)/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin);
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, gi);
+ x->x_ipeaches[ si ] = gi;
+ }
+ }
+
+ }
+ return (1);
+}
+
+static void pianoroll_transpose(t_pianoroll *x, t_floatarg ftranspose)
+{
+ x->x_transpose = ftranspose;
+}
+
+static void pianoroll_save_file(t_pianoroll *x, t_symbol *ffile)
+{
+ FILE *tmph;
+ t_int si;
+
+ if ( ( tmph = fopen( ffile->s_name, "w" ) ) == NULL )
+ {
+ post( "pianoroll : could not open file : %s for writing", ffile->s_name );
+ return;
+ }
+
+ // post( "saving pianoroll : %s", x->x_name->s_name );
+ fprintf(tmph, "%d %d %f %f %d %d %d %f %d ",
+ x->x_width, x->x_height,
+ x->x_pmin, x->x_pmax,
+ x->x_nbgrades, x->x_nbsteps,
+ x->x_defvalue, x->x_transpose, x->x_save );
+ for ( si=0; si<x->x_nbsteps; si++ )
+ {
+ fprintf(tmph, "%f %f ", x->x_peaches[si], x->x_volumes[si] );
+ }
+
+ if ( fclose( tmph ) == -1 )
+ {
+ post( "pianoroll : could not close file : %s ", ffile->s_name );
+ return;
+ }
+}
+
+static void pianoroll_load(t_pianoroll *x, t_symbol *ffile)
+{
+ FILE *tmph;
+ t_int si;
+
+ if ( ( tmph = fopen( ffile->s_name, "r" ) ) == NULL )
+ {
+ post( "pianoroll : could not open file : %s for reading", ffile->s_name );
+ return;
+ }
+
+ pianoroll_draw_erase(x, x->x_glist);
+ freebytes( x->x_peaches, x->x_nbsteps*sizeof( t_float ) );
+ freebytes( x->x_volumes, x->x_nbsteps*sizeof( t_float ) );
+ freebytes( x->x_ipeaches, x->x_nbsteps*sizeof( t_int ) );
+ freebytes( x->x_ivolumes, x->x_nbsteps*sizeof( t_int ) );
+
+ if ( fscanf(tmph, "%d %d %f %f %d %d %d %f %d",
+ &x->x_width, &x->x_height,
+ &x->x_pmin, &x->x_pmax,
+ &x->x_nbgrades, &x->x_nbsteps,
+ &x->x_defvalue, &x->x_transpose, &x->x_save ) != 9 )
+ {
+ post( "pianoroll : could not restore data from file : %s", ffile->s_name );
+ return;
+ }
+
+ x->x_peaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_volumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) );
+ for ( si=0; si<x->x_nbsteps ; si++ )
+ {
+ fscanf( tmph, "%f", &x->x_peaches[si] );
+ fscanf( tmph, "%f", &x->x_volumes[si] );
+ }
+
+ pianoroll_draw_new(x, x->x_glist);
+ pianoroll_draw_update(x, x->x_glist);
+
+ if ( fclose( tmph ) == -1 )
+ {
+ post( "pianoroll : could not close file : %s ", ffile->s_name );
+ return;
+ }
+}
+
+static void pianoroll_init(t_pianoroll *x)
+{
+ t_int si;
+
+ for ( si=0; si<x->x_nbsteps; si++ )
+ {
+ x->x_peaches[si] = x->x_defvalue;
+ x->x_volumes[si] = 1.0;
+ }
+ pianoroll_draw_erase(x, x->x_glist );
+ pianoroll_draw_new(x, x->x_glist );
+ pianoroll_draw_update(x, x->x_glist );
+}
+
+static void pianoroll_pitch(t_pianoroll *x, t_floatarg fpos, t_floatarg fpitch)
+{
+ t_canvas *canvas=glist_getcanvas(x->x_glist);
+ t_int ipos;
+
+ if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) )
+ {
+ post( "pianoroll : wrong pitch position : %d", fpos );
+ return;
+ }
+ ipos = (t_int) fpos;
+ if ( ( ( (t_int) fpitch ) < x->x_pmin ) || ( ( (t_int) fpitch ) > x->x_pmax ) )
+ {
+ post( "pianoroll : wrong pitch value : %d", fpitch );
+ return;
+ }
+
+ {
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, ipos, x->x_ipeaches[ ipos ]);
+
+ x->x_ipeaches[ ipos ] = (t_int) ( ( ( x->x_pmax - fpitch ) / ( x->x_pmax - x->x_pmin ) ) * ( x->x_nbgrades - 1 ) );
+ x->x_peaches[ ipos ] = x->x_pmin+(float)(x->x_nbgrades-1-x->x_ipeaches[ ipos ])/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin);
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, ipos, x->x_ipeaches[ ipos ]);
+ }
+}
+
+static void pianoroll_volume(t_pianoroll *x, t_floatarg fpos, t_floatarg fvol)
+{
+ t_canvas *canvas=glist_getcanvas(x->x_glist);
+ t_int ipos;
+
+ if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) )
+ {
+ post( "pianoroll : wrong volume position : %d", fpos );
+ return;
+ }
+ ipos = (t_int) fpos;
+ if ( ( ( (t_int) fvol ) < 0.0 ) || ( ( (t_int) fvol ) > 1.0 ) )
+ {
+ post( "pianoroll : wrong volume value : %d", fvol );
+ return;
+ }
+
+ {
+ SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, ipos, x->x_ivolumes[ ipos ] );
+
+ x->x_ivolumes[ ipos ] = (t_int) ( ( 1 - fvol ) * (x->x_nbgrades-1) );
+ x->x_volumes[ ipos ] = (((float)x->x_nbgrades-1-(float)x->x_ivolumes[ ipos ]))/(float)(x->x_nbgrades-1);
+ SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, ipos, x->x_ivolumes[ ipos ] );
+ }
+}
+
+static void pianoroll_float(t_pianoroll *x, t_floatarg fposition)
+{
+ t_int pposition, rposition, rrposition;
+ t_float fpart;
+ t_int pi;
+ t_canvas *canvas;
+
+ pposition = ( (int)fposition - 1 ) % x->x_nbsteps;
+ if ( pposition < 0 ) pposition += x->x_nbsteps;
+ rposition = ( (int)fposition ) % x->x_nbsteps;
+ if ( rposition < 0 ) rposition += x->x_nbsteps;
+ rrposition = ( (int)fposition +1 ) % x->x_nbsteps;
+ if ( rrposition < 0 ) rrposition += x->x_nbsteps;
+
+ // post ( "pposition=%d rposition=%d rrposition=%d", pposition, rposition, rrposition );
+ fpart = fposition - (int)fposition;
+ pi=-1;
+ canvas=glist_getcanvas(x->x_glist);
+
+ outlet_float( x->x_pitch, x->x_peaches[ rposition ] +
+ fpart*(x->x_peaches[ rrposition ] - x->x_peaches[ rposition ] ) +
+ x->x_transpose );
+ outlet_float( x->x_volume, x->x_volumes[ rposition ] +
+ fpart*(x->x_volumes[ rrposition ] - x->x_volumes[ rposition ] ) );
+
+ // graphical update
+ {
+ if ( x->x_scurrent != -1 )
+ {
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x,
+ x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]);
+ }
+ x->x_scurrent = rposition;
+ SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #00FF00\n", canvas, x,
+ x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]);
+ }
+}
+
+static t_pianoroll *pianoroll_new(t_symbol *s, int argc, t_atom *argv)
+{
+ int si, i, zz;
+ t_pianoroll *x;
+ t_pd *x2;
+ char *str;
+
+ // post( "pianoroll_new : create : %s argc =%d", s->s_name, argc );
+
+ x = (t_pianoroll *)pd_new(pianoroll_class);
+ // new pianoroll created from the gui
+ if ( argc != 0 )
+ {
+ if ( argc < 10 )
+ {
+ post( "pianoroll : error in the number of arguments ( %d )", argc );
+ return NULL;
+ }
+ if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) {
+ post( "pianoroll : error : wrong number of steps or grades" );
+ return NULL;
+ }
+ if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) {
+ post( "pianoroll : error : min pitch is > to max pitch" );
+ return NULL;
+ }
+ if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT ||
+ argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ||
+ argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ||
+ argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT ||
+ argv[8].a_type != A_FLOAT || argv[9].a_type != A_FLOAT ) {
+ post( "pianoroll : wrong arguments" );
+ return NULL;
+ }
+
+ // update pianoroll count
+ if (!strncmp((str = argv[0].a_w.w_symbol->s_name), "pianoroll", 9)
+ && (zz = atoi(str + 9)) > pianorollcount)
+ {
+ // post( "pianoroll : already %d objects", pianorollcount );
+ pianorollcount = zz;
+ }
+ x->x_name = argv[0].a_w.w_symbol;
+ pd_bind(&x->x_obj.ob_pd, x->x_name);
+ x->x_width = argv[1].a_w.w_float;
+ x->x_height = argv[2].a_w.w_float;
+ x->x_pmin = argv[3].a_w.w_float;
+ x->x_pmax = argv[4].a_w.w_float;
+ x->x_nbgrades = argv[5].a_w.w_float;
+ x->x_nbsteps = argv[6].a_w.w_float;
+ x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_defvalue = argv[7].a_w.w_float;
+ x->x_transpose = argv[8].a_w.w_float;
+ x->x_save = argv[9].a_w.w_float;
+ }
+ else
+ {
+ char buf[40];
+
+ sprintf(buf, "pianoroll%d", ++pianorollcount);
+ s = gensym(buf);
+
+ x->x_name = s;
+ pd_bind(&x->x_obj.ob_pd, x->x_name);
+
+ x->x_width = DEFAULT_SEQUENCER_WIDTH;
+ x->x_height = DEFAULT_SEQUENCER_HEIGHT;
+ x->x_pmin = DEFAULT_SEQUENCER_PITCH_MIN;
+ x->x_pmax = DEFAULT_SEQUENCER_PITCH_MAX;
+ x->x_nbgrades = DEFAULT_SEQUENCER_NBGRADES;
+ x->x_nbsteps = DEFAULT_SEQUENCER_STEPS;
+ x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) );
+ x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) );
+ x->x_defvalue = 0;
+ x->x_transpose = 0;
+ x->x_save = 1;
+
+ }
+
+ // common fields for new and restored pianorolls
+ x->x_selected = 0;
+ x->x_scurrent = -1;
+ x->x_glist = (t_glist *) canvas_getcurrent();
+ x->x_pitch = outlet_new(&x->x_obj, &s_float );
+ x->x_volume = outlet_new(&x->x_obj, &s_float );
+ // post( "pianoroll : argc : %d", argc );
+ if ( ( argc != 0 ) && ( x->x_save ) )
+ {
+ int ai = 10;
+ int si = 0;
+
+ while ( ai < argc )
+ {
+ x->x_peaches[si] = argv[ai++].a_w.w_float;
+ if ( ai >= argc ) break;
+ x->x_volumes[si++] = argv[ai++].a_w.w_float;
+ }
+ }
+ else // following arguments are the values of pitch, volumes
+ {
+ for ( si=0; si<x->x_nbsteps; si++ )
+ {
+ x->x_peaches[si] = x->x_defvalue;
+ x->x_volumes[si] = 1.0;
+ }
+ }
+
+ // post( "pianoroll_new name : %s width: %d height : %d", x->x_name->s_name, x->x_width, x->x_height );
+
+ return (x);
+}
+
+static void pianoroll_free(t_pianoroll *x)
+{
+ // post( "pianoroll~: pianoroll_free" );
+ if ( x->x_peaches )
+ {
+ freebytes( x->x_peaches, x->x_nbsteps*sizeof(t_float) );
+ }
+ if ( x->x_ipeaches )
+ {
+ freebytes( x->x_ipeaches, x->x_nbsteps*sizeof(t_int) );
+ }
+ if ( x->x_volumes )
+ {
+ freebytes( x->x_volumes, x->x_nbsteps*sizeof(t_float) );
+ }
+ if ( x->x_ivolumes )
+ {
+ freebytes( x->x_ivolumes, x->x_nbsteps*sizeof(t_int) );
+ }
+}
+
+void pianoroll_setup(void)
+{
+ post( pianoroll_version );
+#include "pianoroll.tk2c"
+ pianoroll_class = class_new(gensym("pianoroll"), (t_newmethod)pianoroll_new,
+ (t_method)pianoroll_free, sizeof(t_pianoroll), 0, A_GIMME, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_float, &s_float, A_FLOAT, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_transpose, gensym("transpose"),
+ A_FLOAT, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_init, gensym("init"), 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_dialog, gensym("dialog"), A_GIMME, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_save_file, gensym("save"), A_SYMBOL, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_load, gensym("load"), A_SYMBOL, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_pitch, gensym("pitch"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(pianoroll_class, (t_method)pianoroll_volume, gensym("volume"), A_FLOAT, A_FLOAT, 0);
+
+
+ pianoroll_widgetbehavior.w_getrectfn = pianoroll_getrect;
+ pianoroll_widgetbehavior.w_displacefn = pianoroll_displace;
+ pianoroll_widgetbehavior.w_selectfn = pianoroll_select;
+ pianoroll_widgetbehavior.w_activatefn = NULL;
+ pianoroll_widgetbehavior.w_deletefn = pianoroll_delete;
+ pianoroll_widgetbehavior.w_visfn = pianoroll_vis;
+ pianoroll_widgetbehavior.w_clickfn = pianoroll_click;
+ pianoroll_widgetbehavior.w_propertiesfn = pianoroll_properties;
+ pianoroll_widgetbehavior.w_savefn = pianoroll_save;
+ class_setwidget(pianoroll_class, &pianoroll_widgetbehavior);
+ class_sethelpsymbol(pianoroll_class, gensym("help-pianoroll.pd"));
+}
diff --git a/pianoroll/pianoroll.h b/pianoroll/pianoroll.h
new file mode 100644
index 0000000..4f6a783
--- /dev/null
+++ b/pianoroll/pianoroll.h
@@ -0,0 +1,40 @@
+/* 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. */
+
+/* a header for pianoroll which enables
+* to control a sequencer ( pitch and volume )
+*/
+
+#ifndef __G_PIANOROLL_H
+#define __G_PIANOROLL_H
+
+typedef struct _pianoroll
+{
+ t_object x_obj;
+ t_glist *x_glist;
+ t_symbol *x_name;
+ t_outlet *x_pitch;
+ t_outlet *x_volume;
+ int x_height; /* height of the pianoroll */
+ int x_width; /* width of the pianoroll */
+ t_float x_pmin; /* minimum value of the pitch */
+ t_float x_pmax; /* max value of the pitch */
+ t_int x_nbgrades; /* number of grades for the pitch */
+ t_int x_nbsteps; /* number of steps */
+ t_int x_defvalue; /* default value for the pitch */
+ t_float x_transpose;/* transposition value */
+ t_float *x_peaches; /* pitch for each step */
+ t_int *x_ipeaches; /* pitch index for each step */
+ t_float *x_volumes; /* volume for each step */
+ t_int *x_ivolumes; /* volume index for each step */
+ int x_selected; /* stores selected state */
+ int x_xlines; /* number of vertical lines */
+ int x_ylines; /* number of horizontal lines */
+ int x_scurrent; /* cureent step */
+ int x_save; /* saving contents flag */
+} t_pianoroll;
+
+EXTERN t_rtext *rtext_new_without_senditup(t_glist *glist, t_text *who, t_rtext *next);
+
+#endif
diff --git a/pianoroll/pianoroll.tk b/pianoroll/pianoroll.tk
new file mode 100644
index 0000000..eccadce
--- /dev/null
+++ b/pianoroll/pianoroll.tk
@@ -0,0 +1,164 @@
+############ pianoroll procedures -- ydegoyon@free.fr #########
+
+proc pianoroll_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_name [concat graph_name_$vid]
+ global $var_graph_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_pmin [concat graph_pmin_$vid]
+ global $var_graph_pmin
+ set var_graph_pmax [concat graph_pmax_$vid]
+ global $var_graph_pmax
+ set var_graph_nbgrades [concat graph_nbgrades_$vid]
+ global $var_graph_nbgrades
+ set var_graph_nbsteps [concat graph_nbsteps_$vid]
+ global $var_graph_nbsteps
+ set var_graph_defvalue [concat graph_defvalue_$vid]
+ global $var_graph_defvalue
+ set var_graph_save [concat graph_save_$vid]
+ global $var_graph_save
+
+ set cmd [concat $id dialog \
+ [eval concat $$var_graph_name] \
+ [eval concat $$var_graph_width] \
+ [eval concat $$var_graph_height] \
+ [eval concat $$var_graph_pmin] \
+ [eval concat $$var_graph_pmax] \
+ [eval concat $$var_graph_nbgrades] \
+ [eval concat $$var_graph_nbsteps] \
+ [eval concat $$var_graph_defvalue] \
+ [eval concat $$var_graph_save] \;]
+ #puts stderr $cmd
+ pd $cmd
+}
+
+proc pianoroll_cancel {id} {
+ set cmd [concat $id cancel \;]
+ #puts stderr $cmd
+ pd $cmd
+}
+
+proc pianoroll_ok {id} {
+ pianoroll_apply $id
+ pianoroll_cancel $id
+}
+
+proc pdtk_pianoroll_dialog {id name width height pmin pmax nbgrades nbsteps defvalue save } {
+ set vid [string trimleft $id .]
+ set var_graph_name [concat graph_name_$vid]
+ global $var_graph_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_pmin [concat graph_pmin_$vid]
+ global $var_graph_pmin
+ set var_graph_pmax [concat graph_pmax_$vid]
+ global $var_graph_pmax
+ set var_graph_nbgrades [concat graph_nbgrades_$vid]
+ global $var_graph_nbgrades
+ set var_graph_nbsteps [concat graph_nbsteps_$vid]
+ global $var_graph_nbsteps
+ set var_graph_defvalue [concat graph_defvalue_$vid]
+ global $var_graph_defvalue
+ set var_graph_save [concat graph_save_$vid]
+ global $var_graph_save
+
+ set $var_graph_name $name
+ set $var_graph_width $width
+ set $var_graph_height $height
+ set $var_graph_pmin $pmin
+ set $var_graph_pmax $pmax
+ set $var_graph_nbgrades $nbgrades
+ set $var_graph_nbsteps $nbsteps
+ set $var_graph_defvalue $defvalue
+ set $var_graph_save $save
+
+ toplevel $id
+ wm title $id {pianoroll}
+ wm protocol $id WM_DELETE_WINDOW [concat pianoroll_cancel $id]
+
+ label $id.label -text {PIANOROLL 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 "pianoroll_cancel $id"
+ button $id.buttonframe.apply -text {Apply}\
+ -command "pianoroll_apply $id"
+ button $id.buttonframe.ok -text {OK}\
+ -command "pianoroll_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.lname -text "Name :"
+ entry $id.1rangef.name -textvariable $var_graph_name -width 15
+ pack $id.1rangef.lname $id.1rangef.name -side left
+
+ frame $id.2rangef
+ pack $id.2rangef -side top
+ label $id.2rangef.lwidth -text "Width :"
+ entry $id.2rangef.width -textvariable $var_graph_width -width 7
+ pack $id.2rangef.lwidth $id.2rangef.width -side left
+
+ frame $id.3rangef
+ pack $id.3rangef -side top
+ label $id.3rangef.lheight -text "Height :"
+ entry $id.3rangef.height -textvariable $var_graph_height -width 7
+ pack $id.3rangef.lheight $id.3rangef.height -side left
+
+ frame $id.4rangef
+ pack $id.4rangef -side top
+ label $id.4rangef.lpmin -text "Pitch low :"
+ entry $id.4rangef.pmin -textvariable $var_graph_pmin -width 7
+ pack $id.4rangef.lpmin $id.4rangef.pmin -side left
+
+ frame $id.5rangef
+ pack $id.5rangef -side top
+ label $id.5rangef.lpmax -text "Pitch high :"
+ entry $id.5rangef.pmax -textvariable $var_graph_pmax -width 7
+ pack $id.5rangef.lpmax $id.5rangef.pmax -side left
+
+ frame $id.6rangef
+ pack $id.6rangef -side top
+ label $id.6rangef.lnbgrades -text "Grades :"
+ entry $id.6rangef.nbgrades -textvariable $var_graph_nbgrades -width 7
+ pack $id.6rangef.lnbgrades $id.6rangef.nbgrades -side left
+
+ frame $id.7rangef
+ pack $id.7rangef -side top
+ label $id.7rangef.lnbsteps -text "Steps :"
+ entry $id.7rangef.nbsteps -textvariable $var_graph_nbsteps -width 7
+ pack $id.7rangef.lnbsteps $id.7rangef.nbsteps -side left
+
+ frame $id.8rangef
+ pack $id.8rangef -side top
+ label $id.8rangef.ldefvalue -text "Default Value :"
+ entry $id.8rangef.defvalue -textvariable $var_graph_defvalue -width 7
+ pack $id.8rangef.ldefvalue $id.8rangef.defvalue -side left
+
+ checkbutton $id.save -text {Save contents} -variable $var_graph_save \
+ -anchor w
+ pack $id.save -side top
+
+ bind $id.1rangef.name <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.2rangef.width <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.3rangef.height <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.4rangef.pmin <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.5rangef.pmax <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.6rangef.nbgrades <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.7rangef.nbsteps <KeyPress-Return> [concat pianoroll_ok $id]
+ bind $id.8rangef.defvalue <KeyPress-Return> [concat pianoroll_ok $id]
+ focus $id.1rangef.name
+}
+
+############ pianoroll procedures END -- ydegoyon@free.fr #########