aboutsummaryrefslogtreecommitdiff
path: root/composer
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2009-08-20 02:28:19 +0000
committermescalinum <mescalinum@users.sourceforge.net>2009-08-20 02:28:19 +0000
commita874e13115da648dae992634c5f6ee0912f136f3 (patch)
tree74a466d84582d502de0a48c5ad5cef2cc8710c47 /composer
parent1bdf5157d0707e89b1bce0a939fbcfcf33047816 (diff)
- Added preliminary support for song view in window.tk
- Memory leak fixes - Add song save/load code svn path=/trunk/externals/ffext/; revision=11989
Diffstat (limited to 'composer')
-rw-r--r--composer/common.h12
-rw-r--r--composer/pattern.c14
-rw-r--r--composer/song.c38
-rw-r--r--composer/song_proxy.c101
-rw-r--r--composer/track.c7
-rw-r--r--composer/track_proxy.c22
-rw-r--r--composer/window.tk37
7 files changed, 171 insertions, 60 deletions
diff --git a/composer/common.h b/composer/common.h
index f9005cf..1dc78c0 100644
--- a/composer/common.h
+++ b/composer/common.h
@@ -39,7 +39,7 @@
#include <stdio.h>
#include "arraylist.h"
-#define PTR "0x%x"
+#define PTR "0x%lx"
#ifdef DEBUG
#define debugprint(args...) post( args )
#define DEBUG_BOOL 1
@@ -105,8 +105,11 @@ typedef struct _pattern
static t_song* song_new(t_symbol* song_name);
static void song_mastertrack_fix_cols(t_song* x);
static void song_free(t_song* x);
+static void song_internal_resize_cols(t_song* x, t_int sz);
static t_song* song_get(t_symbol* song_name);
static int song_exists(t_symbol* song_name);
+static void song_loaddata(t_song* x, int argc, t_atom* argv);
+static void song_binbuf_save(t_song* t, t_symbol* selector, t_binbuf* b);
static t_track* track_new(t_symbol* song_name, t_symbol* track_name, t_int columns);
static t_track* mastertrack_new(t_song* song, t_symbol* track_name, t_int columns);
@@ -114,7 +117,8 @@ static t_track* song_create_track(t_song* x, t_symbol* track_name, t_int columns
static void track_free(t_track* x);
static t_track* track_get(t_symbol* song_name, t_symbol* track_name);
static int track_exists(t_symbol* song_name, t_symbol* track_name);
-static void track_binbuf_save(t_track* x);
+static void track_binbuf_save(t_track* x, t_symbol* selector, t_binbuf* b);
+
static t_pattern* pattern_new(t_track* track, t_symbol* name, t_int rows);
static t_pattern* pattern_clone(t_pattern* src, t_symbol* newname);
@@ -122,6 +126,7 @@ static void pattern_free(t_pattern* x);
static void pattern_rename(t_pattern* x, t_symbol* newname);
static void pattern_resize(t_pattern *x, t_int newsize);
static void pattern_resize_cols(t_pattern* x, t_int newcols);
+static void pattern_init_cell(t_atom* a);
static void pattern_new_empty_row(t_pattern* x);
static t_atom* pattern_getrow(t_pattern* x, t_int row);
static t_atom* pattern_clone_row(t_pattern* x, t_atom* row);
@@ -134,6 +139,7 @@ static int pattern_exists(t_symbol* song_name, t_symbol* track_name, t_symbol* p
void song_proxy_setup(void);
static t_song_proxy* song_proxy_new(t_symbol* song_name);
static void song_proxy_free(t_song_proxy* x);
+static t_atom* song_proxy_get_pattern_names(t_song_proxy* x);
static void song_proxy_float(t_song_proxy* x, t_floatarg f);
static void song_proxy_properties(t_gobj* z, t_glist* owner);
static void song_proxy_properties_close(t_gobj* z, t_glist* owner);
@@ -143,6 +149,7 @@ static void song_proxy_gettracks_o(t_song_proxy* x);
static t_int song_proxy_gettracks_count(t_song_proxy* x);
static void song_proxy_gettracks_count_o(t_song_proxy* x);
static void song_proxy_anything(t_song_proxy* x, t_symbol* s, int argc, t_atom* argv);
+static void song_proxy_loadsonginfo(t_song_proxy* x, t_symbol* s, int argc, t_atom* argv);
static void song_proxy_loaddata(t_song_proxy* x, t_symbol* s, int argc, t_atom* argv);
static t_atom* song_proxy_getpatternlength(t_song_proxy* x, t_symbol* pat_name);
static void song_proxy_editcmd(t_song_proxy* x, t_symbol* s_, int argc, t_atom* argv_);
@@ -156,7 +163,6 @@ static t_atom* song_proxy_getcell(t_song_proxy* x, t_symbol* pat_name, t_floatar
static t_atom* song_proxy_getcell_with_header(t_song_proxy* x, t_symbol* pat_name, t_floatarg rownum, t_floatarg colnum);
static void song_proxy_getcell_o(t_song_proxy* x, t_symbol* pat_name, t_floatarg rownum, t_floatarg colnum);
static t_pattern* song_proxy_resizepattern(t_song_proxy* x, t_symbol* name, t_floatarg rows);
-static t_atom* song_proxy_get_track_names(t_song_proxy* x);
void track_proxy_setup(void);
static t_track_proxy* track_proxy_new(t_symbol* song_name, t_symbol* track_name, t_floatarg cols);
diff --git a/composer/pattern.c b/composer/pattern.c
index 819c585..42109fe 100644
--- a/composer/pattern.c
+++ b/composer/pattern.c
@@ -90,21 +90,31 @@ static void pattern_resize(t_pattern *x, t_int newsize) {
* Works only for the mastertrack (song_proxy)
*/
static void pattern_resize_cols(t_pattern* x, t_int newcols) {
- int j;
+ int i,j;
for(j = 0; j < x->x_rows_count; j++) {
if(&x->x_rows[j])
x->x_rows[j] = (t_atom*)resizebytes(x->x_rows[j], x->x_track->x_ncolumns, newcols);
else
x->x_rows[j] = (t_atom*)getbytes(sizeof(t_atom) * newcols);
}
+ if(newcols > x->x_track->x_ncolumns) {
+ for(j = 0; j < x->x_rows_count; j++) {
+ for(i = x->x_track->x_ncolumns; i < newcols; i++)
+ pattern_init_cell(&x->x_rows[j][i]);
+ }
+ }
x->x_track->x_ncolumns = newcols;
}
+static void pattern_init_cell(t_atom* a) {
+ SETSYMBOL(a, gensym("empty"));
+}
+
static void pattern_new_empty_row(t_pattern* x) {
t_atom* rowdata = (t_atom*)getbytes(sizeof(t_atom) * x->x_track->x_ncolumns);
int j;
for(j = 0; j < x->x_track->x_ncolumns; j++)
- SETSYMBOL(&(rowdata[j]), gensym("empty"));
+ pattern_init_cell(&rowdata[j]);
ArrayListAdd(x->x_rows, t_atom*, rowdata);
}
diff --git a/composer/song.c b/composer/song.c
index 424c52c..6129181 100644
--- a/composer/song.c
+++ b/composer/song.c
@@ -50,11 +50,11 @@ static void song_mastertrack_fix_cols(t_song* x) {
debugprint("song_mastertrack_fix_cols(" PTR "), new track count: %d", x, x->x_tracks_count);
debugprint("song='%s' mastertrack=" PTR, x->x_name->s_name, x->x_mastertrack);
debugprint("we have %d patterns, sir", x->x_mastertrack->x_patterns_count);
- int j;
- for(j = 0; j < x->x_mastertrack->x_patterns_count; j++) {
- if(j > 0) post("WARNING: mastertrack with more than one pattern!");
- pattern_resize_cols(x->x_mastertrack->x_patterns[j], x->x_tracks_count);
+ if(x->x_mastertrack->x_patterns_count < x->x_mastertrack->x_ncolumns) {
+ debugprint("song_mastertrack_fix_cols: still loading (apparently?), skipping.");
+ return;
}
+ song_internal_resize_cols(x, x->x_tracks_count);
}
static void song_free(t_song* x) {
@@ -64,6 +64,14 @@ static void song_free(t_song* x) {
ArrayListRemove(songs, x);
}
+static void song_internal_resize_cols(t_song* x, t_int sz) {
+ int j;
+ for(j = 0; j < x->x_mastertrack->x_patterns_count; j++) {
+ if(j > 0) post("WARNING: mastertrack with more than one pattern!");
+ pattern_resize_cols(x->x_mastertrack->x_patterns[j], sz);
+ }
+}
+
static t_song* song_get(t_symbol* song_name) {
ArrayListGetByName(songs, song_name, t_song*, result);
return result;
@@ -72,3 +80,25 @@ static t_song* song_get(t_symbol* song_name) {
static int song_exists(t_symbol* song_name) {
return song_get(song_name) != 0L;
}
+
+static void song_loaddata(t_song* x, int argc, t_atom* argv) {
+ if(argc < 2) {
+ error("song_loaddata: format error 1");
+ return;
+ }
+ if(argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT) {
+ error("song_loaddata: format error 2");
+ }
+ t_symbol* name = argv[0].a_w.w_symbol;
+ t_int ntracks = (t_int)argv[1].a_w.w_float;
+ debugprint("song_loaddata: song='%s', tracks=%d", name->s_name, ntracks);
+ song_internal_resize_cols(x, ntracks);
+}
+
+static void song_binbuf_save(t_song* t, t_symbol* selector, t_binbuf* b) {
+ // data format:
+ // SELECTOR DATA <song_name> <ntracks>
+
+ binbuf_addv(b, "sssi", selector, gensym("SONGINFO"), t->x_name, t->x_tracks_count);
+ binbuf_addv(b, ";");
+}
diff --git a/composer/song_proxy.c b/composer/song_proxy.c
index e1fd85f..00b1440 100644
--- a/composer/song_proxy.c
+++ b/composer/song_proxy.c
@@ -45,6 +45,21 @@ void song_proxy_setup(void) {
0
);
class_addfloat(song_proxy_class, song_proxy_float);
+ class_addanything(song_proxy_class, song_proxy_anything);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_properties, \
+ gensym("editor-open"), 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_properties_close, \
+ gensym("editor-close"), 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_setrow, \
+ gensym("setrow"), A_GIMME, 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_getrow_o, \
+ gensym("getrow"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_setcell, \
+ gensym("setcell"), A_GIMME, 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_getcell_o, \
+ gensym("getcell"), A_SYMBOL, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(song_proxy_class, (t_method)song_proxy_resizepattern, \
+ gensym("resizepattern"), A_SYMBOL, A_FLOAT, 0);
#if PD_MINOR_VERSION >= 37
class_setpropertiesfn(song_proxy_class, song_proxy_properties);
class_setsavefn(song_proxy_class, song_proxy_save);
@@ -58,18 +73,19 @@ static t_song_proxy* song_proxy_new(t_symbol* song_name) {
x->x_song = song_new(song_name);
x->b_editor_open = 0;
char rcv_buf[80];
- sprintf(rcv_buf, "track_proxy-%s-%s", x->x_song->x_name->s_name, x->x_song->x_mastertrack->x_name->s_name);
+ sprintf(rcv_buf, "song_proxy-%s", x->x_song->x_name->s_name);
x->rcv = gensym(rcv_buf);
pd_bind(&x->x_obj.ob_pd, x->rcv);
debugprint("created an instance of t_song_proxy: " PTR, x);
- return x;
song_proxy_properties_close((t_gobj*) x, NULL);
pd_bind(&x->x_obj.ob_pd, gensym(SONG_SELECTOR));
+ pd_bind(&x->x_obj.ob_pd, gensym(TRACK_SELECTOR));
- sys_vgui("pd::composer::init %s %s %s %d %d\n", x->rcv->s_name, x->x_song->x_name->s_name, x->x_song->x_mastertrack->x_name->s_name, x->x_song->x_mastertrack->x_ncolumns, DEBUG_BOOL);
+ debugprint("pd::composer::init %s %s %s %d %s %d\n", x->rcv->s_name, x->x_song->x_name->s_name, x->x_song->x_mastertrack->x_name->s_name, x->x_song->x_mastertrack->x_ncolumns, "Arrangement", DEBUG_BOOL);
+ sys_vgui("pd::composer::init %s %s %s %d %s %d\n", x->rcv->s_name, x->x_song->x_name->s_name, x->x_song->x_mastertrack->x_name->s_name, x->x_song->x_mastertrack->x_ncolumns, "Arrangement", DEBUG_BOOL);
return x;
}
@@ -78,14 +94,29 @@ static void song_proxy_free(t_song_proxy* x) {
song_proxy_properties_close((t_gobj*) x, NULL);
pd_unbind(&x->x_obj.ob_pd, gensym(SONG_SELECTOR));
+ pd_unbind(&x->x_obj.ob_pd, gensym(TRACK_SELECTOR));
+
/* LATER find a way to get SONG_SELECTOR unbound earlier (at end of load?) */
+ /* Was this code needed? for what?
t_pd* x2;
while (x2 = pd_findbyclass(gensym(SONG_SELECTOR), song_proxy_class))
- pd_unbind(x2, gensym(SONG_SELECTOR));
+ pd_unbind(x2, gensym(SONG_SELECTOR));*/
pd_unbind(&x->x_obj.ob_pd, x->rcv);
}
+static t_atom* song_proxy_get_pattern_names(t_song_proxy* x) {
+ if(response_row) {
+ freebytes(response_row, response_row_sz * sizeof(t_atom));
+ response_row = NULL;
+ response_row_sz = 0;
+ }
+ response_row_sz = track_get_pattern_count(x->x_song->x_mastertrack);
+ response_row = (t_atom*)getbytes(sizeof(t_atom) * response_row_sz);
+ track_get_pattern_names(x->x_song->x_mastertrack, response_row);
+ return response_row;
+}
+
static void song_proxy_float(t_song_proxy* x, t_floatarg f) {
}
@@ -106,24 +137,27 @@ static void song_proxy_properties_close(t_gobj* z, t_glist* owner) {
}
static void song_proxy_save(t_gobj* z, t_binbuf* b) {
- t_track_proxy* x = (t_track_proxy*)z;
- t_track* t = x->x_track;
+ t_song_proxy* x = (t_song_proxy*)z;
+ t_song* s = x->x_song;
+ t_track* t = s->x_mastertrack;
- binbuf_addv(b, "ssiisssi;", gensym("#X"), gensym("obj"),
+ binbuf_addv(b, "ssiiss;", gensym("#X"), gensym("obj"),
(t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
- gensym("track"), t->x_song->x_name, t->x_name, t->x_ncolumns);
+ gensym("song"), s->x_name);
+
+ song_binbuf_save(s, gensym(SONG_SELECTOR), b);
track_binbuf_save(t, gensym(TRACK_SELECTOR), b);
}
static t_atom* song_proxy_gettracks(t_song_proxy* x) {
if(response_row) {
- freebytes(response_row, response_row_sz);
+ freebytes(response_row, response_row_sz * sizeof(t_atom));
response_row = NULL;
response_row_sz = 0;
}
- response_row_sz = sizeof(t_atom) * x->x_song->x_tracks_count;
- response_row = (t_atom*)getbytes(response_row_sz);
+ response_row_sz = x->x_song->x_tracks_count;
+ response_row = (t_atom*)getbytes(response_row_sz * sizeof(t_atom));
int i;
for(i = 0; i < x->x_song->x_tracks_count; i++) {
SETSYMBOL(&response_row[i], x->x_song->x_tracks[i]->x_name);
@@ -154,12 +188,19 @@ static void song_proxy_anything(t_song_proxy* x, t_symbol* s, int argc, t_atom*
} else if(s == gensym("EDIT")) {
song_proxy_editcmd(x, s, argc, argv);
return;
+ } else if(s == gensym("SONGINFO")) {
+ song_proxy_loadsonginfo(x, s, argc, argv);
+ return;
} else {
error("unrecognized command for anything method: %s ", s->s_name);
return;
}
}
+static void song_proxy_loadsonginfo(t_song_proxy* x, t_symbol* s, int argc, t_atom* argv) {
+ song_loaddata(x->x_song, argc, argv);
+}
+
static void song_proxy_loaddata(t_song_proxy* x, t_symbol* s, int argc, t_atom* argv) {
track_loaddata(x->x_song->x_mastertrack, argc, argv);
}
@@ -202,8 +243,11 @@ static void song_proxy_editcmd(t_song_proxy* x, t_symbol* s_, int argc, t_atom*
song_proxy_properties((t_gobj*) x, NULL);
} else if(s == gensym("editor-close")) {
song_proxy_properties_close((t_gobj*) x, NULL);
+ } else if(s == gensym("getpatterns")) {
+ t_atom* rsp = song_proxy_get_pattern_names(x);
+ song_proxy_sendgui(x, gensym("patterns"), response_row_sz, rsp);
} else if(s == gensym("gettracks")) {
- t_atom* rsp = song_proxy_get_track_names(x);
+ t_atom* rsp = song_proxy_gettracks(x);
song_proxy_sendgui(x, gensym("tracks"), response_row_sz, rsp);
} else if(s == gensym("gettrackscount")) {
t_atom a;
@@ -270,21 +314,29 @@ static t_atom* song_proxy_getrow(t_song_proxy* x, t_symbol* pat_name, t_floatarg
static t_atom* song_proxy_getrow_with_header(t_song_proxy* x, t_symbol* pat_name, t_floatarg rownum) {
if(response_row) {
- freebytes(response_row, response_row_sz);
+ freebytes(response_row, response_row_sz * sizeof(t_atom));
response_row = NULL;
response_row_sz = 0;
}
t_atom* row = song_proxy_getrow(x, pat_name, rownum);
if(!row) {
- error("song: getrow: nu such patern: '%s'", pat_name->s_name);
+ error("song: getrow: no such pattern: '%s'", pat_name->s_name);
return NULL;
}
- response_row_sz = sizeof(t_atom) * (x->x_song->x_mastertrack->x_ncolumns + 2);
- t_atom* response_row = (t_atom*)getbytes(response_row_sz);
+ fprintf(stderr, "GOT A ROW " PTR ", 2 + %d (=? %d) columns, last a_type = %d\n", (long unsigned int)row, (int)x->x_song->x_mastertrack->x_ncolumns, (int)x->x_song->x_tracks_count, 0);
+ response_row_sz = x->x_song->x_mastertrack->x_ncolumns + 2;
+ t_atom* response_row = (t_atom*)getbytes(response_row_sz * sizeof(t_atom));
SETSYMBOL(&response_row[0], pat_name);
SETFLOAT(&response_row[1], rownum);
memcpy(&response_row[2], row, sizeof(t_atom) * x->x_song->x_mastertrack->x_ncolumns);
+ if(response_row[2].a_type == A_SYMBOL)
+ fprintf(stderr, "VALUE[2] = %s\n", response_row[2].a_w.w_symbol->s_name);
+ else if(response_row[2].a_type == A_FLOAT)
+ fprintf(stderr, "VALUE[2] = %f\n", response_row[2].a_w.w_float);
+ else
+ fprintf(stderr, "VALUE[2] = ? (type = %d)\n", response_row[2].a_type);
+
return &response_row[0];
}
@@ -323,7 +375,7 @@ static t_atom* song_proxy_getcell(t_song_proxy* x, t_symbol* pat_name, t_floatar
static t_atom* song_proxy_getcell_with_header(t_song_proxy* x, t_symbol* pat_name, t_floatarg rownum, t_floatarg colnum) {
t_atom* cell = song_proxy_getcell(x, pat_name, rownum, colnum);
if(!cell) {
- error("song: getcell: nu such patern: '%s'", pat_name->s_name);
+ error("song: getcell: no such pattern: '%s'", pat_name->s_name);
return NULL;
}
SETSYMBOL(&response_cell[0], pat_name);
@@ -348,18 +400,3 @@ static t_pattern* song_proxy_resizepattern(t_song_proxy* x, t_symbol* name, t_fl
pattern_resize(pat, (t_int)rows);
return pat;
}
-
-static t_atom* song_proxy_get_track_names(t_song_proxy* x) {
- if(response_row) {
- freebytes(response_row, response_row_sz);
- response_row = NULL;
- response_row_sz = 0;
- }
- response_row_sz = sizeof(t_atom) * x->x_song->x_tracks_count;
- response_row = (t_atom*)getbytes(response_row_sz);
- int i;
- for(i = 0; i < x->x_song->x_tracks_count; i++) {
- SETSYMBOL(&response_row[i], x->x_song->x_tracks[i]->x_name);
- }
- return &response_row[0];
-}
diff --git a/composer/track.c b/composer/track.c
index 269a1d9..477fdfd 100644
--- a/composer/track.c
+++ b/composer/track.c
@@ -98,6 +98,7 @@ static int track_exists(t_symbol* song_name, t_symbol* track_name) {
}
static void track_loaddata(t_track* x, int argc, t_atom* argv) {
+ debugprint("track_loaddata(" PTR ", %d, " PTR ")", x, argc, argv);
int i,base;
base = 0;
@@ -125,6 +126,8 @@ static void track_loaddata(t_track* x, int argc, t_atom* argv) {
return;
}
+ debugprint("track_loaddata: song='%s', track='%s'", song_name->s_name, track_name->s_name);
+
if(argc < (base+1) || argv[base].a_type != A_FLOAT) {
error("track: data format error 2");
return;
@@ -132,7 +135,7 @@ static void track_loaddata(t_track* x, int argc, t_atom* argv) {
t_int npatterns = (t_int)argv[base].a_w.w_float;
base += 1;
- debugprint("track: %s-%s: %d patterns to read", song_name->s_name, track_name->s_name, npatterns);
+ debugprint("track_loaddata: %d patterns to read", npatterns);
t_symbol* patname;
t_int patrows;
@@ -173,7 +176,7 @@ static void track_loaddata(t_track* x, int argc, t_atom* argv) {
}
}
-static void track_binbuf_save(t_track* x, t_symbol* selector, t_binbuf* b) {
+static void track_binbuf_save(t_track* t, t_symbol* selector, t_binbuf* b) {
// data format:
// SELECTOR DATA <song_name> <track_name> <npatterns> [<pat_name> <pat rows> RxC_atoms]*n
diff --git a/composer/track_proxy.c b/composer/track_proxy.c
index e83e474..509cccb 100644
--- a/composer/track_proxy.c
+++ b/composer/track_proxy.c
@@ -94,7 +94,8 @@ static t_track_proxy* track_proxy_new(t_symbol* song_name, t_symbol* track_name,
pd_bind(&x->x_obj.ob_pd, gensym(TRACK_SELECTOR));
- sys_vgui("pd::composer::init %s %s %s %d %d\n", x->rcv->s_name, x->x_track->x_song->x_name->s_name, x->x_track->x_name->s_name, x->x_track->x_ncolumns, DEBUG_BOOL);
+ debugprint("pd::composer::init %s %s %s %d %s %d\n", x->rcv->s_name, x->x_track->x_song->x_name->s_name, x->x_track->x_name->s_name, x->x_track->x_ncolumns, "NULL", DEBUG_BOOL);
+ sys_vgui("pd::composer::init %s %s %s %d %s %d\n", x->rcv->s_name, x->x_track->x_song->x_name->s_name, x->x_track->x_name->s_name, x->x_track->x_ncolumns, "NULL", DEBUG_BOOL);
return x;
}
@@ -112,14 +113,13 @@ static void track_proxy_free(t_track_proxy* x) {
}
static t_atom* track_proxy_get_pattern_names(t_track_proxy* x) {
- t_int n = track_get_pattern_count(x->x_track);
if(response_row) {
- freebytes(response_row, response_row_sz);
+ freebytes(response_row, response_row_sz * sizeof(t_atom));
response_row = NULL;
response_row_sz = 0;
}
- response_row_sz = sizeof(t_atom) * n;
- response_row = (t_atom*)getbytes(response_row_sz);
+ response_row_sz = track_get_pattern_count(x->x_track);
+ response_row = (t_atom*)getbytes(sizeof(t_atom) * response_row_sz);
track_get_pattern_names(x->x_track, response_row);
return response_row;
}
@@ -262,6 +262,8 @@ static void track_proxy_editcmd(t_track_proxy* x, t_symbol* s_, int argc, t_atom
t_atom* rsp = track_proxy_get_pattern_names(x);
track_proxy_sendgui(x, gensym("patterns"), response_row_sz, rsp);
}
+ } else if(s == gensym("gettracks")) {
+ // dummy STFU
} else {
error("track: editcmd: unknown command: %s", s->s_name);
}
@@ -321,18 +323,18 @@ static t_atom* track_proxy_getrow(t_track_proxy* x, t_symbol* pat_name, t_floata
static t_atom* track_proxy_getrow_with_header(t_track_proxy* x, t_symbol* pat_name, t_floatarg rownum) {
if(response_row) {
- freebytes(response_row, response_row_sz);
+ freebytes(response_row, response_row_sz * sizeof(t_atom));
response_row = NULL;
response_row_sz = 0;
}
t_atom* row = track_proxy_getrow(x, pat_name, rownum);
if(!row) {
- error("track: getrow: nu such patern: '%s'", pat_name->s_name);
+ error("track: getrow: no such pattern: '%s'", pat_name->s_name);
return NULL;
}
- response_row_sz = sizeof(t_atom) * (x->x_track->x_ncolumns + 2);
- t_atom* response_row = (t_atom*)getbytes(response_row_sz);
+ response_row_sz = x->x_track->x_ncolumns + 2;
+ t_atom* response_row = (t_atom*)getbytes(response_row_sz * sizeof(t_atom));
SETSYMBOL(&response_row[0], pat_name);
SETFLOAT(&response_row[1], rownum);
memcpy(&response_row[2], row, sizeof(t_atom) * x->x_track->x_ncolumns);
@@ -374,7 +376,7 @@ static t_atom* track_proxy_getcell(t_track_proxy* x, t_symbol* pat_name, t_float
static t_atom* track_proxy_getcell_with_header(t_track_proxy* x, t_symbol* pat_name, t_floatarg rownum, t_floatarg colnum) {
t_atom* cell = track_proxy_getcell(x, pat_name, rownum, colnum);
if(!cell) {
- error("track: getcell: nu such patern: '%s'", pat_name->s_name);
+ error("track: getcell: no such pattern: '%s'", pat_name->s_name);
return NULL;
}
SETSYMBOL(&response_cell[0], pat_name);
diff --git a/composer/window.tk b/composer/window.tk
index ac52a2b..1b90732 100644
--- a/composer/window.tk
+++ b/composer/window.tk
@@ -44,6 +44,8 @@ namespace eval pd::composer {
array set columns {}
variable patterns
array set patterns {}
+ variable tracks
+ array set tracks {}
variable quirks_fix_int_floats 0
variable symbolmap {empty {}}
@@ -153,9 +155,14 @@ namespace eval pd::composer {
variable songname
variable trackname
variable currentpattern
- set t "Song: $songname($id) Track: $trackname($id)"
- if {$currentpattern($id) != {}} {
- append t " Pattern: $currentpattern($id)"
+ set t "Song: $songname($id)"
+ if {$currentpattern($id) == "Arrangement"} {
+ append t " Arrangement"
+ } else {
+ append t " Track: $trackname($id)"
+ if {$currentpattern($id) != {}} {
+ append t " Pattern: $currentpattern($id)"
+ }
}
wm title $w($id) $t
}
@@ -181,8 +188,8 @@ namespace eval pd::composer {
set rows [dict get $length($id) $name]
set cols $columns($id)
- debugPrint "resizing tktable widget to ${rows}x${cols}"
grid $w($id).t -row 10 -column 0 -sticky news
+ debugPrint "resizing tktable widget to ${rows}x${cols}"
$w($id).t configure -state normal -variable [getDataVar $id] -rows $rows -cols [expr {1+$cols}]
$w($id).f.p configure -values $patterns($id)
$w($id).f.p current [lsearch -exact $patterns($id) $name]
@@ -343,6 +350,7 @@ namespace eval pd::composer {
set showpattern($id) 0
debugPrint "request-patterns"
sendGui [concat $id EDIT getpatterns]
+ sendGui [concat $id EDIT gettracks]
return $w($id)
}
@@ -485,7 +493,7 @@ namespace eval pd::composer {
}
#entrypoint
- proc init {id song_name track_name cols debug_flag} {
+ proc init {id song_name track_name cols set_current_pattern debug_flag} {
debugPrint [info level 0]
variable debug
set debug [expr {$debug_flag != 0}]
@@ -498,7 +506,11 @@ namespace eval pd::composer {
set w($id) .w_${song_name}_${track_name}
set songname($id) $song_name
set trackname($id) $track_name
- set currentpattern($id) {}
+ if {$set_current_pattern == {NULL}} {
+ set currentpattern($id) {}
+ } else {
+ set currentpattern($id) $set_current_pattern
+ }
set length($id) {}
set columns($id) $cols
}
@@ -528,11 +540,13 @@ namespace eval pd::composer {
variable currentpattern
variable startup
variable showpattern
+ variable columns
variable quirks_fix_int_floats
switch -exact [lindex $args 0] {
patterns {
+ # for track mode
set patterns($id) [lrange $args 1 end]
- debugPrint "tk::patterns <- $patterns($id)"
+ debugPrint "patterns <- $patterns($id)"
$w($id).f.p configure -values $patterns($id)
if {$startup($id)} {
set startup($id) 0
@@ -541,6 +555,15 @@ namespace eval pd::composer {
}
}
}
+ tracks {
+ # for song mode
+ set tracks($id) [lrange $args 1 end]
+ debugPrint "tracks <- $tracks($id)"
+ set cols [llength $tracks($id)]
+ #debugPrint "resizing tktable widget to ${cols} cols"
+ #$w($id).t configure -state normal -cols $cols
+ set columns($id) $cols
+ }
patternlength {
set pat_name [lindex $args 1]
set pat_length [lindex $args 2]