[PD-cvs] externals/frankenstein rhythms_memory.c,1.6,1.7
dmorelli
morellid at users.sourceforge.net
Mon Dec 26 12:55:26 CET 2005
Update of /cvsroot/pure-data/externals/frankenstein
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12198
Modified Files:
rhythms_memory.c
Log Message:
working on rhythms output
Index: rhythms_memory.c
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/rhythms_memory.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rhythms_memory.c 22 Dec 2005 23:21:04 -0000 1.6
--- rhythms_memory.c 26 Dec 2005 11:55:23 -0000 1.7
***************
*** 1,4 ****
/*
! just a dummy rhythms_memory patch
*/
--- 1,16 ----
/*
! rhythms_memory
! by Davide Morelli www.davidemorelli.it 2005
!
! a working version of rhythms_memory
!
! uses graphs to store rhythms
!
! TODO:
! * test and debug core functionalities
! * memory save/load to file
! * output rhythms in realtime (BANGs)
! * output rhythms in the form of list of floats
! * add velo
*/
***************
*** 27,34 ****
--- 39,55 ----
t_rhythm_event *curr_seq;
int seq_initialized;
+ // the memory
t_rhythm_memory_representation *rhythms_memory;
+ // measure length
double measure_start_time;
double measure_length;
+ // input rhythm's events
event *events;
+ // output rhythm's events
+ unsigned short int next_main_rhythm_out;
+ unsigned short int next_sub_rhythm_out;
+ event *events_out;
+ t_clock *x_clock;
+ double x_deltime;
} t_rhythms_memory;
***************
*** 40,43 ****
--- 61,66 ----
if (x->rhythms_memory)
rhythm_memory_free(x->rhythms_memory);
+
+ clock_free(x->x_clock);
}
***************
*** 85,88 ****
--- 108,115 ----
int counter;
t_atom *lista;
+ // these 2 are for output rhythm
+ int rhythm_found;
+ t_rhythm_event *wanted_rhythm;
+
// I call the pd functions to get a representation
// of this very moment
***************
*** 143,146 ****
--- 170,213 ----
x->curr_seq = 0;
}
+
+ // I free the list of events_out (if present)
+ currEvent = x->events_out;
+ // this is not the first event
+ while(currEvent)
+ {
+ lastEvent = currEvent;
+ currEvent = currEvent->next;
+ free(lastEvent);
+ }
+ x->events_out = 0;
+ // i set up the list of events_out
+ // for the wanted rhythm
+ if (x->next_main_rhythm_out)
+ {
+ // ask the memory for the wanted rhythm
+ rhythm_found = rhythm_memory_get_rhythm(x->rhythms_memory, // the memory
+ wanted_rhythm, // a pointer to the returned rhythm
+ // the id of the main rhythm wanted
+ x->next_main_rhythm_out,
+ // the sub-id of the sub-rhythm wanted
+ x->next_sub_rhythm_out);
+ if (rhythm_found==0)
+ {
+ post("rhythms_memory: rhythm %i %i was not found ", x->next_main_rhythm_out, x->next_sub_rhythm_out);
+ return 0;
+ }
+
+ // now I setup the events_out list
+ // for each event in wanted_rhythm
+ // allocate and link an element of elements_out
+
+ //--> TODO <--
+
+ // also setup the timer for the first event
+
+ //--> TODO <--
+
+ }
+
// also start the new measure!
start_measure(x);
***************
*** 149,152 ****
--- 216,257 ----
}
+ // this function is called by pd
+ // when the timer bangs
+ static void delay_tick(t_rhythms_memory *x)
+ {
+ // here i must:
+ // take the next element in x->events_out
+ // and compute when I'll need to schedule next event
+ // (next_event - curr_event)
+
+ // TODO
+
+ // set the next element as the current one
+ // and free the memory allocated for the old curr event
+
+ // TODO
+
+ // set up the timer
+
+ // TODO
+ }
+
+ // the user wants me to play a rhythm in the next measure
+ // the user MUST pass 2 args: main_rhythm and sub_rhythm wanted
+ static void ask_rhythm(t_rhythms_memory *x, t_symbol *s, int argc, t_atom *argv)
+ {
+ if (argc<3)
+ {
+ error("this method needs at least 2 floats: main_rhythm and sub_rhythm wanted");
+ return;
+ }
+ argv++;
+ x->next_main_rhythm_out = atom_getfloat(argv++);
+ x->next_sub_rhythm_out = atom_getfloat(argv);
+ // i have nothing left to do:
+ // when this measure will end a list of events_out will be set
+ // from the current values of x->next_main_rhythm_out and x->next_sub_rhythm_out
+ }
+
static void rhythms_memory_bang(t_rhythms_memory *x) {
***************
*** 211,217 ****
class_addmethod(rhythms_memory_class, (t_method)end_measure, gensym("measure"), 0);
class_doaddfloat(rhythms_memory_class, (t_method)add_event);
-
class_addmethod(rhythms_memory_class, (t_method)crash, gensym("crash"), 0);
!
}
--- 316,323 ----
class_addmethod(rhythms_memory_class, (t_method)end_measure, gensym("measure"), 0);
class_doaddfloat(rhythms_memory_class, (t_method)add_event);
class_addmethod(rhythms_memory_class, (t_method)crash, gensym("crash"), 0);
! // the user asks for a rhythm
! class_addmethod(rhythms_memory_class, (t_method)ask_rhythm, gensym("rhythm"),
! A_GIMME, 0);
}
More information about the Pd-cvs
mailing list