Update of /cvsroot/pure-data/externals/unauthorized/blinkenlights In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16546
Modified Files: CHANGES.LOG blinkenlights-help.pd blinkenlights.c Log Message: added changes by Chun Lee : scratching
Index: CHANGES.LOG =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/blinkenlights/CHANGES.LOG,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CHANGES.LOG 16 Aug 2003 08:37:03 -0000 1.1 --- CHANGES.LOG 27 Oct 2005 15:06:31 -0000 1.2 *************** *** 1,2 **** --- 1,4 ---- + 0.2 + incorporate changes from Chun Lee ( chun@goto10.org ) : scratch, automatic vj mode 0.1 first implementation
Index: blinkenlights.c =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/blinkenlights/blinkenlights.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** blinkenlights.c 19 Apr 2005 00:17:25 -0000 1.5 --- blinkenlights.c 27 Oct 2005 15:06:33 -0000 1.6 *************** *** 27,30 **** --- 27,37 ---- /* ---------------------------------------------------------------------------- */
+ //added functions: + //"static void blinkenlights_findframes(t_blinkenlights *x)" + //this is to remember the frame positions in the .blm file + + //"static void blinkenlights_goto(t_blinkenlights* x, t_float frame)" + //with a "goto $1" message, you can stratch the blm film. note that the + //range of $1 is 0 to 1
*************** *** 36,40 **** #include <fcntl.h> #include <sys/stat.h> ! #ifndef __APPLE__ #include <malloc.h> #endif --- 43,47 ---- #include <fcntl.h> #include <sys/stat.h> ! #ifndef MACOSX #include <malloc.h> #endif *************** *** 47,51 **** #include "g_canvas.h" /* some pd's graphical functions */
! static char *blinkenlights_version = "blinkenlights: a blinkenlights movies player version 0.1 ( bugs @ ydegoyon@free.fr )";
static int guidebug=0; --- 54,58 ---- #include "g_canvas.h" /* some pd's graphical functions */
! static char *blinkenlights_version = "blinkenlights: a blinkenlights movies player version 0.2 ( bugs @ ydegoyon@free.fr and chun@goto10.org )";
static int guidebug=0; *************** *** 108,111 **** --- 115,125 ---- t_int *x_frame; /* frame contents */ t_clock *x_clock; /* clock used for reading frames */ + t_outlet *outlet_bang; + t_int frame_no; + t_int frame_pos[BL_MAX_LENGTH]; + t_clock *x_clock2; + t_int x_timer2; + t_float frame_inc; + } t_blinkenlights;
*************** *** 126,129 **** --- 140,148 ---- clock_free( x->x_clock ); } + if ( x->x_clock2 != NULL ) + { + clock_unset( x->x_clock2 ); + clock_free( x->x_clock2 ); + } post( "blinkenlights : done" ); } *************** *** 163,166 **** --- 182,189 ---- strncpy( x->x_foreground, BL_FOREGROUND_COLOR, 7 ); x->x_foreground[7] = '\0'; + x->x_timer2 = 40; + x->frame_inc = 0; + + x->outlet_bang = outlet_new(&x->x_obj, &s_bang);
return(x); *************** *** 448,451 **** --- 471,476 ---- t_int flineno = 0; t_int width, height, nwidth; + + //post( "blinkenlights: being readframe:>%s<", lineread );
if ( !x->x_ecanvas ) *************** *** 464,473 **** // skip header and empty lines while ( lineread[0] == '#' || lineread[0] == '\n' || lineread[0] == '\0' ) ! { ! // post( "blinkenlights : skipped line : >%s<", lineread ); if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == 0 ) { post( "blinkenlights : end of file detected : looping..." ); fseek( x->x_filed, 0L, SEEK_SET ); } } --- 489,500 ---- // skip header and empty lines while ( lineread[0] == '#' || lineread[0] == '\n' || lineread[0] == '\0' ) ! { ! ! //post( "blinkenlights : skipped line : >%s<", lineread ); if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == 0 ) { post( "blinkenlights : end of file detected : looping..." ); fseek( x->x_filed, 0L, SEEK_SET ); + outlet_bang(x->outlet_bang); } } *************** *** 562,565 **** --- 589,718 ---- if ( lineread ) freebytes( lineread, BL_MAX_LENGTH ); } + //------------------------------------------------------------------------- + //--chun's functions begin here... + //------------------------------------------------------------------------- + /* remember all the frame positions */ + static void blinkenlights_findframes(t_blinkenlights *x) + { + int i =0; + + x->frame_no = 0; + + for(i=0;;i++) + { + char *lineread = (char*) getbytes( BL_MAX_LENGTH ); + + fgets( lineread, BL_MAX_LENGTH, x->x_filed ); + if(strlen(lineread) == 0) break; + + if(lineread[0] == '@') + { + x->frame_pos[x->frame_no] = ftell(x->x_filed); + x->frame_no++; + } + if (lineread) freebytes( lineread, BL_MAX_LENGTH ); + } + fseek( x->x_filed, 0L, SEEK_SET ); + post("the end:: %d frames!", x->frame_no); + } + + //------------------------------------------------------------------------- + static void blinkenlights_goto(t_blinkenlights* x) + { + //char *lineread = (char*) getbytes( BL_MAX_LENGTH ); + char lineread[BL_MAX_LENGTH]; + int current_frame = x->frame_pos[(int)(x->frame_inc * (x->frame_no-1))]; + int i, n, width, newvalue, height, nwidth; + + t_int flineno = 0; + + fseek(x->x_filed, current_frame, SEEK_SET); + + height = 0; + width = 0; + while ( 1 ) + { + + if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == NULL ) + { + post( "blinkenlights : EOF not expected here !!! "); + blinkenlights_close(x); + return; + } + else + { + if ( (lineread[0] == '\0') || (lineread[0] == '#') || (lineread[0] == '\n') ) break; + // post( "blinkenlights : lineread : %s", lineread ); + + nwidth = strlen( lineread )-1; // because of the carriage return + flineno++; + height = flineno; + if ( ( nwidth != width ) && ( width != 0 ) ) + { + post( "blinkenlights : weird file : width has changed (nwidth=%d) (width=%d)", nwidth, width ); + blinkenlights_close( x ); + return; + } + width = nwidth; + if ( x->x_frame != NULL ) + { + t_int pint = 0; + t_int newvalue; + + while ( pint < width ) + { + newvalue = (int) *(lineread+pint) - 48 /* ascii value for '0' */; + if ( newvalue != *(x->x_frame+(flineno-1)*x->x_width+pint ) ) + { + *(x->x_frame+(flineno-1)*x->x_width+pint ) = newvalue; + switch ( newvalue ) + { + case 0: + // post( "pixoff %d %d", pint+1, flineno ); + blinkenlights_pixoff( x, pint+1, flineno ); + break; + case 1: + // post( "pixon %d %d", pint+1, flineno ); + blinkenlights_pixon( x, pint+1, flineno ); + break; + default: + // post("blinkenlights : wrong value found for pixel : %d (c=%c)", newvalue, *(lineread+pint) ); + break; + } + } + pint++; + } + } + if ( x->x_frame == NULL ) x->x_height++; + } + } + if ( x->x_frame == NULL ) + { + if ( x->x_filed != NULL ) if ( fseek(x->x_filed, 0L, SEEK_SET) < 0 ) + { + post( "blinkenlights : could not rewind file" ); + blinkenlights_close( x ); + return; + } + blinkenlights_width(x, width); + blinkenlights_height(x, height); + x->x_frame = ( t_int* ) getbytes( x->x_width*x->x_height*sizeof(t_int) ); + blinkenlights_readframe(x); + } + + } + + static void blinkenlights_frame_pos(t_blinkenlights* x, t_float pos) + { + if(pos > 1 | pos < 0) post ("dude, don't be crazy!"); + else x->frame_inc = pos;; + //post("frame %d", x->frame_inc); + } + + static void blinkenlights_timer2(t_blinkenlights* x, t_float timer) + { + x->x_timer2 = timer; + //post("frame %d", x->frame_inc); + }
/* open movie */ *************** *** 572,576 **** }
! blinkenlights_close(x);
if ( ( x->x_filed = fopen( sfile->s_name, "r" ) ) == NULL ) --- 725,743 ---- }
! //---------------------------------- ! /* closing previous file descriptor */ ! if ( x->x_filed != NULL ) { ! if(fclose(x->x_filed) < 0) ! { ! perror( "blinkenlights : closing file" ); ! } ! x->x_filed = NULL; ! } ! if ( x->x_frame ) ! { ! blinkenlights_clear(x); ! } ! ! //--------------------------------
if ( ( x->x_filed = fopen( sfile->s_name, "r" ) ) == NULL ) *************** *** 580,585 **** } post( "blinkenlights : opened >%s<", sfile->s_name); ! ! blinkenlights_readframe(x); }
--- 747,753 ---- } post( "blinkenlights : opened >%s<", sfile->s_name); ! // don't read the first frame when open.. ! //blinkenlights_readframe(x); ! blinkenlights_findframes(x); }
*************** *** 591,594 **** --- 759,769 ---- }
+ /* play frames2 */ + static void blinkenlights_playframes2(t_blinkenlights *x) + { + blinkenlights_goto(x); + clock_delay( x->x_clock2, (double)x->x_timer2 ); + } + /* play movie */ static void blinkenlights_play(t_blinkenlights *x) *************** *** 611,614 **** --- 786,816 ---- }
+ /* vj movie */ + static void blinkenlights_vj(t_blinkenlights *x, t_float start_vj) + { + if ( !x->x_ecanvas ) + { + post("blinkenlights : play : canvas does not exist" ); + return; + } + + if ( x->x_filed == NULL ) + { + post( "blinkenlights : no file is opened for playing" ); + blinkenlights_close(x); + return; + } + + if(start_vj) + { + if ( x->x_clock2 == NULL ) x->x_clock2 = clock_new( x, (t_method)blinkenlights_playframes2); + clock_delay( x->x_clock2, (double)x->x_timer2 ); + } + else + { + clock_unset( x->x_clock2 ); + } + } + /* stop movie */ static void blinkenlights_stop(t_blinkenlights *x) *************** *** 633,638 **** }
- - /* jump to next frame */ static void blinkenlights_next(t_blinkenlights *x) --- 835,838 ---- *************** *** 657,660 **** --- 857,863 ---- class_addmethod( blinkenlights_class, (t_method)blinkenlights_play, gensym("play"), 0); class_addmethod( blinkenlights_class, (t_method)blinkenlights_stop, gensym("stop"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_frame_pos, gensym("goto"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_vj, gensym("vj"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_timer2, gensym("timer2"), A_FLOAT, 0); class_addmethod( blinkenlights_class, (t_method)blinkenlights_background, gensym("background"), A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod( blinkenlights_class, (t_method)blinkenlights_foreground, gensym("foreground"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
Index: blinkenlights-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/unauthorized/blinkenlights/blinkenlights-help.pd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** blinkenlights-help.pd 25 Sep 2003 20:58:53 -0000 1.1 --- blinkenlights-help.pd 27 Oct 2005 15:06:33 -0000 1.2 *************** *** 1,9 **** ! #N canvas 80 -6 868 605 10; ! #X text 495 569 Comments and bugs @ ydegoyon@noos.fr; ! #X text 496 555 Part of unauthorized PD; ! #X text 430 493 blinkenlights is a blinkenlights movies player; ! #X text 430 507 but it's also a pixel grid than you can use for ASCII art...; ! #X text 430 523 Constructor : blinkenlights <width> <height> <x pixel size> <y pixel size>; #X msg 125 10 create; --- 1,8 ---- ! #N canvas 484 81 885 735 10; ! #X text 334 640 Part of unauthorized PD; ! #X text 480 570 blinkenlights is a blinkenlights movies player; ! #X text 480 584 but it's also a pixel grid than you can use for ASCII art...; ! #X text 480 600 Constructor : blinkenlights <width> <height> <x pixel size> <y pixel size>; #X msg 125 10 create; *************** *** 17,21 **** #X msg 285 266 bang; #X msg 122 267 pixoff $1 $2; ! #X obj 34 562 blinkenlights 18 8 32 32; #X msg 125 152 foreground 124 78 89; #X obj 347 277 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 --- 16,20 ---- #X msg 285 266 bang; #X msg 122 267 pixoff $1 $2; ! #X obj 87 618 blinkenlights 18 8 32 32; #X msg 125 152 foreground 124 78 89; #X obj 347 277 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 *************** *** 26,32 **** #X text 352 213 Set a pixel on; #X obj 346 232 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 ! -1 -1 0 1; #X obj 335 205 vsl 8 32 1 32 0 0 empty empty empty 0 -8 0 8 -262144 ! -1 -1 0 1; #X msg 338 309 bang; #X obj 400 320 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 --- 25,31 ---- #X text 352 213 Set a pixel on; #X obj 346 232 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 ! -1 -1 1600 1; #X obj 335 205 vsl 8 32 1 32 0 0 empty empty empty 0 -8 0 8 -262144 ! -1 -1 1400 1; #X msg 338 309 bang; #X obj 400 320 hsl 32 8 1 32 0 0 empty empty empty -2 -6 0 8 -262144 *************** *** 56,61 **** #X text 552 187 ========================================; #X text 550 -6 ========================================; ! #X text 547 394 ========================================; ! #X text 117 394 =========================================== Movies Functions; #X text 122 -6 =========================================== Grid Actions --- 55,60 ---- #X text 552 187 ========================================; #X text 550 -6 ========================================; ! #X text 539 472 ========================================; ! #X text 112 472 =========================================== Movies Functions; #X text 122 -6 =========================================== Grid Actions *************** *** 71,138 **** #X text 275 37 Set the width ( number of pixels ); #X text 275 56 Set the height ( number of pixels ); ! #X msg 120 416 open ./blm/ascii_people.blm; ! #X msg 328 416 play; ! #X msg 370 416 stop; ! #X msg 120 443 open $1; ! #X msg 411 416 next; ! #X obj 451 415 metro 100; ! #X msg 524 416 bang; ! #X msg 564 415 stop; ! #X obj 195 453 playlist .blm 200 100; ! #X msg 434 472 location /usr/local/pd/externs/blinkenlights/blm; ! #X obj 434 450 loadbang; ! #X connect 5 0 15 0; ! #X connect 6 0 15 0; ! #X connect 8 0 15 0; ! #X connect 11 0 15 0; #X connect 12 0 50 0; ! #X connect 13 0 51 0; ! #X connect 14 0 15 0; ! #X connect 16 0 15 0; ! #X connect 17 0 51 0; ! #X connect 18 0 13 0; ! #X connect 18 0 51 1; ! #X connect 21 0 50 0; ! #X connect 22 0 12 0; ! #X connect 22 0 50 1; ! #X connect 23 0 52 0; ! #X connect 24 0 52 0; ! #X connect 25 0 23 0; ! #X connect 25 0 52 1; ! #X connect 27 0 15 0; ! #X connect 28 0 34 0; ! #X connect 29 0 34 1; ! #X connect 30 0 34 2; ! #X connect 31 0 34 3; ! #X connect 32 0 34 4; ! #X connect 33 0 15 0; ! #X connect 34 0 33 0; ! #X connect 35 0 40 0; ! #X connect 35 1 41 0; ! #X connect 35 2 30 0; ! #X connect 35 3 31 0; ! #X connect 35 4 32 0; ! #X connect 36 0 39 0; ! #X connect 38 0 39 0; ! #X connect 39 0 35 0; #X connect 40 0 28 0; ! #X connect 41 0 29 0; ! #X connect 42 0 15 0; ! #X connect 50 0 11 0; ! #X connect 51 0 14 0; ! #X connect 52 0 27 0; ! #X connect 53 0 15 0; ! #X connect 54 0 15 0; ! #X connect 56 0 15 0; ! #X connect 57 0 15 0; ! #X connect 60 0 15 0; ! #X connect 61 0 15 0; ! #X connect 62 0 15 0; ! #X connect 63 0 15 0; ! #X connect 64 0 15 0; #X connect 65 0 64 0; ! #X connect 66 0 65 0; ! #X connect 67 0 65 0; ! #X connect 68 0 63 0; ! #X connect 69 0 68 0; ! #X connect 70 0 69 0; --- 70,156 ---- #X text 275 37 Set the width ( number of pixels ); #X text 275 56 Set the height ( number of pixels ); ! #X msg 127 495 open ./blm/ascii_people.blm; ! #X msg 335 495 play; ! #X msg 377 495 stop; ! #X msg 127 522 open $1; ! #X msg 418 495 next; ! #X obj 458 494 metro 100; ! #X msg 531 495 bang; ! #X msg 571 494 stop; ! #X obj 188 521 openpanel; ! #X obj 261 522 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 ! -1; ! #X floatatom 615 495 5 0 0 0 - - -; ! #X text 534 401 ========================================; ! #X text 116 400 =============================================== VJ ! function; ! #X msg 132 444 vj $1; ! #X msg 363 444 goto $1; ! #X obj 366 423 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144 ! -1 -1 5600 1; ! #X obj 132 424 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 ! 1; ! #X text 507 420 <- look! you can also scratch the film!; ! #X text 530 434 be sure the window is created first....; ! #X text 154 420 <- switch to the scratch mode; ! #X text 333 654 Comments and bugs @ ydegoyon@free.fr and chun@goto10.org ! ; ! #X connect 4 0 14 0; ! #X connect 5 0 14 0; ! #X connect 7 0 14 0; ! #X connect 10 0 14 0; ! #X connect 11 0 49 0; #X connect 12 0 50 0; ! #X connect 13 0 14 0; ! #X connect 15 0 14 0; ! #X connect 16 0 50 0; ! #X connect 17 0 12 0; ! #X connect 17 0 50 1; ! #X connect 20 0 49 0; ! #X connect 21 0 11 0; ! #X connect 21 0 49 1; ! #X connect 22 0 51 0; ! #X connect 23 0 51 0; ! #X connect 24 0 22 0; ! #X connect 24 0 51 1; ! #X connect 26 0 14 0; ! #X connect 27 0 33 0; ! #X connect 28 0 33 1; ! #X connect 29 0 33 2; ! #X connect 30 0 33 3; ! #X connect 31 0 33 4; ! #X connect 32 0 14 0; ! #X connect 33 0 32 0; ! #X connect 34 0 39 0; ! #X connect 34 1 40 0; ! #X connect 34 2 29 0; ! #X connect 34 3 30 0; ! #X connect 34 4 31 0; ! #X connect 35 0 38 0; ! #X connect 37 0 38 0; ! #X connect 38 0 34 0; ! #X connect 39 0 27 0; #X connect 40 0 28 0; ! #X connect 41 0 14 0; ! #X connect 49 0 10 0; ! #X connect 50 0 13 0; ! #X connect 51 0 26 0; ! #X connect 52 0 14 0; ! #X connect 53 0 14 0; ! #X connect 55 0 14 0; ! #X connect 56 0 14 0; ! #X connect 59 0 14 0; ! #X connect 60 0 14 0; ! #X connect 61 0 14 0; ! #X connect 62 0 14 0; ! #X connect 63 0 14 0; ! #X connect 64 0 63 0; #X connect 65 0 64 0; ! #X connect 66 0 64 0; ! #X connect 67 0 62 0; ! #X connect 68 0 67 0; ! #X connect 69 0 64 1; ! #X connect 72 0 14 0; ! #X connect 73 0 14 0; ! #X connect 74 0 73 0; ! #X connect 75 0 72 0;