diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2009-08-19 14:30:30 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2009-08-19 14:30:30 +0000 |
commit | 8835fd9e4dbeb386e044a4a6e4519639d6f50fae (patch) | |
tree | 3099947658c858d36d07dc13274b26d5e9d89024 /composer | |
parent | e6bf559fadcfe714b5c7aa900098b562a4510710 (diff) |
further fix data load/save. allow multiple tracks per patch file.
svn path=/trunk/externals/ffext/; revision=11981
Diffstat (limited to 'composer')
-rw-r--r-- | composer/pattern.c | 10 | ||||
-rw-r--r-- | composer/track_proxy.c | 37 | ||||
-rw-r--r-- | composer/window.tk | 2 |
3 files changed, 35 insertions, 14 deletions
diff --git a/composer/pattern.c b/composer/pattern.c index cf1940b..ed5bce4 100644 --- a/composer/pattern.c +++ b/composer/pattern.c @@ -38,9 +38,9 @@ static t_pattern* pattern_new(t_track* track, t_symbol* name, t_int rows) { int i; for(i = 0; i < rows; i++) { - debugprint("x->x_rows[%d] = " PTR, i, x->x_rows[i]); + //debugprint("x->x_rows[%d] = " PTR, i, x->x_rows[i]); pattern_new_empty_row(x); - debugprint("x->x_rows[%d] <- " PTR, i, x->x_rows[i]); + //debugprint("x->x_rows[%d] <- " PTR, i, x->x_rows[i]); } debugprint("created new pattern " PTR " with %d rows (x_rows = " PTR ")", x, x->x_rows_count, x->x_rows); @@ -116,16 +116,16 @@ static t_atom* pattern_getcell(t_pattern* x, t_int row, t_int col) { static void pattern_setrow(t_pattern* x, t_int row, t_atom* rowdata) { debugprint("pattern_setrow(" PTR ", %d, " PTR ")", x, row, rowdata); row = WRAP(row, x->x_rows_count); - debugprint("x->x_rows[%d] = " PTR, row, x->x_rows[row]); + //debugprint("x->x_rows[%d] = " PTR, row, x->x_rows[row]); t_atom *myrowdata = x->x_rows[row]; memcpy(myrowdata, rowdata, sizeof(t_atom) * x->x_track->x_ncolumns); - debugprint("x->x_rows[%d] <- " PTR, row, x->x_rows[row]); + //debugprint("x->x_rows[%d] <- " PTR, row, x->x_rows[row]); } static void pattern_setcell(t_pattern* x, t_int row, t_int col, t_atom* a) { row = WRAP(row, x->x_rows_count); col = WRAP(col, x->x_track->x_ncolumns); - debugprint("about to write an atom (size=%d) at address " PTR, sizeof(t_atom), &(x->x_rows[row][col])); + //debugprint("about to write an atom (size=%d) at address " PTR, sizeof(t_atom), &(x->x_rows[row][col])); memcpy(&(x->x_rows[row][col]), a, sizeof(t_atom)); } diff --git a/composer/track_proxy.c b/composer/track_proxy.c index 41a2994..b4e57ce 100644 --- a/composer/track_proxy.c +++ b/composer/track_proxy.c @@ -82,7 +82,8 @@ static t_track_proxy* track_proxy_new(t_symbol* song_name, t_symbol* track_name, sprintf(rcv_buf, "track_proxy-%s-%s", x->x_track->x_song->x_name->s_name, x->x_track->x_name->s_name); x->rcv = gensym(rcv_buf); pd_bind(&x->x_obj.ob_pd, x->rcv); - debugprint("created an instance of t_track_proxy " PTR ", to_track = " PTR, x, x->x_track); + debugprint("created an instance of t_track_proxy " PTR ", to_track=" PTR ", n=%s", + x, x->x_track, x->x_track->x_name->s_name); track_proxy_properties_close((t_gobj*) x, NULL); @@ -97,7 +98,7 @@ static void track_proxy_free(t_track_proxy* x) { track_proxy_properties_close((t_gobj*) x, NULL); pd_unbind(&x->x_obj.ob_pd, gensym(TRACK_SELECTOR)); - /* LATER find a way to get #TRACK unbound earlier (at end of load?) */ + /* LATER find a way to get TRACK_SELECTOR unbound earlier (at end of load?) */ t_pd* x2; while (x2 = pd_findbyclass(gensym(TRACK_SELECTOR), track_proxy_class)) pd_unbind(x2, gensym(TRACK_SELECTOR)); @@ -143,9 +144,10 @@ static void track_proxy_save(t_gobj* z, t_binbuf* b) { gensym("track"), t->x_song->x_name, t->x_name, t->x_ncolumns); // data format: - // #TRACK DATA <npatterns> [<pat_name> <pat rows> RxC_atoms]*n + // TRACK_SELECTOR DATA <song_name> <track_name> <npatterns> [<pat_name> <pat rows> RxC_atoms]*n - binbuf_addv(b, "ssi", gensym(TRACK_SELECTOR), gensym("DATA"), t->x_patterns_count); + binbuf_addv(b, "ssssi", gensym(TRACK_SELECTOR), gensym("DATA"), + t->x_song->x_name, t->x_name, t->x_patterns_count); int i,j,k; for(i = 0; i < t->x_patterns_count; i++) { @@ -193,15 +195,33 @@ static void track_proxy_loaddata(t_track_proxy* x, t_symbol* s, int argc, t_atom int i,base; base = 0; + if(argc < (base+2) || argv[base].a_type != A_SYMBOL || argv[base+1].a_type != A_SYMBOL) { + error("track: data format error 1"); + return; + } + t_symbol* song_name = argv[base+0].a_w.w_symbol; + t_symbol* track_name = argv[base+1].a_w.w_symbol; + base += 2; + + if(x->x_track->x_song->x_name != song_name) { + debugprint("WARNING: discarding data from another song: %s", song_name->s_name); + return; + } + + if(x->x_track->x_name != track_name) { + debugprint("WARNING: discarding data from another track: %s", track_name->s_name); + return; + } + if(argc < (base+1) || argv[base].a_type != A_FLOAT) { error("track: data format error 2"); return; } - t_int npatterns = (t_int)argv[base].a_w.w_float; - debugprint("track: %d patterns to read", npatterns); base += 1; + debugprint("track: %s-%s: %d patterns to read", song_name->s_name, track_name->s_name, npatterns); + t_symbol* patname; t_int patrows; t_pattern* pat; @@ -219,8 +239,9 @@ static void track_proxy_loaddata(t_track_proxy* x, t_symbol* s, int argc, t_atom } patname = argv[base+0].a_w.w_symbol; patrows = (t_int)argv[base+1].a_w.w_float; - debugprint("pattern %d: name='%s', length=%d, RxC=%d", i, patname->s_name, patrows, - patrows * x->x_track->x_ncolumns); + debugprint("pattern %d: %s-%s-%s, length=%d, RxC=%d", i, + song_name->s_name, track_name->s_name, patname->s_name, + patrows, patrows * x->x_track->x_ncolumns); base += 2; if(argc >= (base + patrows * x->x_track->x_ncolumns) && patrows > 0) { pat = pattern_new(x->x_track, patname, patrows); diff --git a/composer/window.tk b/composer/window.tk index bd98ca4..7f7da7d 100644 --- a/composer/window.tk +++ b/composer/window.tk @@ -538,7 +538,7 @@ namespace eval pd::composer { set pat_name [lindex $args 1] set pat_length [lindex $args 2] debugPrint "got patternlength: '$pat_name' (len=$pat_length)" - if {![dict exists $length($id) $pat_name] || [dict get $length($id) $pat_name] != $pat_length} { + if {![dict exists $length($id) $pat_name] || [dict get $length($id) $pat_name] != $pat_length || $showpattern($id)} { dict set length($id) $pat_name $pat_length for {set i 0} {$i < $pat_length} {incr i} { sendGui [concat $id EDIT getrow $pat_name $i] |