[PD-cvs] externals/frankenstein Makefile, 1.3, 1.4 common.c, 1.6, 1.7 common.h, 1.6, 1.7

dmorelli morellid at users.sourceforge.net
Sun Dec 4 03:03:42 CET 2005


Update of /cvsroot/pure-data/externals/frankenstein
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19423

Modified Files:
	Makefile common.c common.h 
Log Message:
changed from durations to start style

Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile	3 Dec 2005 01:49:01 -0000	1.3
--- Makefile	4 Dec 2005 02:03:40 -0000	1.4
***************
*** 2,7 ****
  #VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
  VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
! PDPATH="H:\PureData\pd-0.38-3.msw\pd"
! #PDPATH="C:\Documents and Settings\Davide\Documenti\personali\pd-0.38-3.msw\pd"
  
  
--- 2,7 ----
  #VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
  VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
! #PDPATH="H:\PureData\pd-0.38-3.msw\pd"
! PDPATH="C:\Documents and Settings\Davide\Documenti\personali\pd-0.38-3.msw\pd"
  
  

Index: common.h
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/common.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** common.h	3 Dec 2005 01:49:01 -0000	1.6
--- common.h	4 Dec 2005 02:03:40 -0000	1.7
***************
*** 13,17 ****
  typedef struct t_note
  {
- 	unsigned short int played; // 0 if is a rest, 1 if played
  	unsigned short int chord; // 0 if is not a chord (strong) note, 1 if it is
  	unsigned short int diatonic; // 0 if is a note not belonging to this tonality
--- 13,16 ----
***************
*** 27,31 ****
  	unsigned short int voice;
  	t_note note;
! 	t_duration duration;
  	t_note_event *previous; // this is a list, link to the previous element
  	t_note_event *next;  // this is a list, link to the next element
--- 26,31 ----
  	unsigned short int voice;
  	t_note note;
! 	t_duration start; // moment of the noteon event
! 	t_duration duration; // duration of this event
  	t_note_event *previous; // this is a list, link to the previous element
  	t_note_event *next;  // this is a list, link to the next element
***************
*** 42,47 ****
  {
  	unsigned short int voice;
! 	unsigned short int played; // 0 if is a rest, 1 if played
! 	t_duration duration;
  	t_rhythm_event *previous; // this is a list, link to the previous element
  	t_rhythm_event *next;  // this is a list, link to the next element
--- 42,47 ----
  {
  	unsigned short int voice;
! 	t_duration start; // moment of the noteon event
! 	t_duration duration; // duration of this event
  	t_rhythm_event *previous; // this is a list, link to the previous element
  	t_rhythm_event *next;  // this is a list, link to the next element
***************
*** 61,65 ****
  struct t_rhythm_memory_node
  {
! 	t_duration duration;
  	t_rhythm_memory_arc *arcs; // the list of arcs to other nodes
  } ;
--- 61,70 ----
  struct t_rhythm_memory_node
  {
! 	// start is implicit:
! 	// this is in an array
! 	// use int2duration and duration2int 
! 	// against the index in the array to get its value
! 	unsigned short int first; // how many times this has been the first event
! 	unsigned short int weight; // how many times this has been an event
  	t_rhythm_memory_arc *arcs; // the list of arcs to other nodes
  } ;
***************
*** 67,72 ****
  struct t_rhythm_memory_arc
  {
! 	unsigned short int weight;
! 	t_rhythm_memory_node *to_node; // the target of this link (arc)
  	t_rhythm_memory_arc *next_arc; // next link in the list
  } ;
--- 72,76 ----
  struct t_rhythm_memory_arc
  {
! 	unsigned short int to_node_index; // the target of this link (arc)
  	t_rhythm_memory_arc *next_arc; // next link in the list
  } ;
***************
*** 79,82 ****
--- 83,87 ----
  typedef struct t_rhythm_memory_representation t_rhythm_memory_representation;
  typedef struct t_rhythm_memory_element t_rhythm_memory_element;
+ typedef struct t_rhythm_memory_first_node t_rhythm_memory_first_node;
  // element of a list of rhythms
  struct t_rhythm_memory_element
***************
*** 93,96 ****
--- 98,102 ----
  	t_rhythm_memory_element *main_rhythm;
  	t_rhythm_memory_node *transitions;
+ 	unsigned short int max_weight;
  	t_rhythm_memory_element *similar_rhythms;
  } ;
***************
*** 100,107 ****
  // ----------- rhythm manipolation functions
  
- // TODO: 
- // - from data structures to lists of numbers and vice versa
- // - from a (voice, duration) representation to (voice, start, duration) and viceversa
- 
  // converts from integer to duration: used to know this table index
  // what corresponds in terms of duration
--- 106,109 ----
***************
*** 122,150 ****
  
  // set the first beat of a sequence
! void setFirstBeat(t_rhythm_event **firstEvent, unsigned short int voice, float fduration, unsigned short int played);
  
  //adds a beat at the end of this list
! void concatenateBeat(t_rhythm_event *currentEvent, unsigned short int voice, float fduration, unsigned short int played);
  
  // used to free the memory allocated by this list
  void freeBeats(t_rhythm_event *currentEvent);
  
- // change rhythm description protocol
- 
- // from (duration) to (start) style
- // the (start) style is a list of noteon events, the order is not important
- void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle);
- 
- // from (start) to (duration)
- // the (duration) style is a linked list of duration of both notes or rests, the order is important
- void swap_rhythm_to_duration(t_rhythm_event *oldStyle, t_rhythm_event **newStyle);
  
  // --- memory representation of rhythms
  
  // add an arc to this node
! void add_t_rhythm_memory_arc(t_rhythm_memory_node *srcNode, t_rhythm_memory_node *dstNode);
  
! // initialize this representation, allocates memory for the pointers
! void init_rhythm_memory_representation(t_rhythm_memory_representation *this_rep);
  
  // add a new rhythm in the list of similar rhythms related to one main rhythm
--- 124,144 ----
  
  // set the first beat of a sequence
! // this also creates a new rhythm
! void setFirstBeat(t_rhythm_event **firstEvent, unsigned short int voice, float fstart, float fduration);
  
  //adds a beat at the end of this list
! void concatenateBeat(t_rhythm_event *currentEvent, unsigned short int voice, float fstart, float fduration);
  
  // used to free the memory allocated by this list
  void freeBeats(t_rhythm_event *currentEvent);
  
  
  // --- memory representation of rhythms
  
  // add an arc to this node
! void add_t_rhythm_memory_arc(t_rhythm_memory_node *srcNode, unsigned short int dstNode);
  
! // create and initialize this representation, allocate memory for the pointers
! void create_rhythm_memory_representation(t_rhythm_memory_representation **this_rep);
  
  // add a new rhythm in the list of similar rhythms related to one main rhythm
***************
*** 154,159 ****
  void free_memory_representation(t_rhythm_memory_representation *this_rep);
  
! // functions needed to fill and use the memory table
! 
  
  
--- 148,154 ----
  void free_memory_representation(t_rhythm_memory_representation *this_rep);
  
! // compares this rhythm to this representation
! // and tells you how close it is to it
! // TODO !!!!!!!!!!!!!!!!!!
  
  
***************
*** 161,168 ****
  
  // set the first beat of a sequence
! void setFirstNote(t_note_event **firstEvent, unsigned short int voice, float fduration, t_note note);
  
  //adds a beat at the end of this list
! void concatenateNote(t_note_event *currentEvent, unsigned short int voice, float fduration, t_note note);
  
  // used to free the memory allocated by this list
--- 156,163 ----
  
  // set the first beat of a sequence
! void setFirstNote(t_note_event **firstEvent, unsigned short int voice, float fstart, float fduration, t_note note);
  
  //adds a beat at the end of this list
! void concatenateNote(t_note_event *currentEvent, unsigned short int voice, float fstart, float fduration, t_note note);
  
  // used to free the memory allocated by this list

Index: common.c
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/common.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** common.c	3 Dec 2005 01:49:01 -0000	1.6
--- common.c	4 Dec 2005 02:03:40 -0000	1.7
***************
*** 101,105 ****
  }
  
! void setFirstBeat(t_rhythm_event **firstEvent, unsigned short int voice, float fduration, unsigned short int played)
  {
  	t_duration res;
--- 101,105 ----
  }
  
! void setFirstBeat(t_rhythm_event **firstEvent, unsigned short int voice, float fstart, float fduration)
  {
  	t_duration res;
***************
*** 113,123 ****
  	newElement->next = 0;
  	newElement->voice=voice;
- 	newElement->played=played;
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
  	*firstEvent = newElement;
  }
  
! void concatenateBeat(t_rhythm_event *currentEvent, unsigned short int voice, float fduration, unsigned short int played)
  {
  	t_duration res;
--- 113,125 ----
  	newElement->next = 0;
  	newElement->voice=voice;
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
+ 	res = float2duration(fstart);
+ 	newElement->start.numerator = res.numerator;
+ 	newElement->start.denominator = res.denominator;
  	*firstEvent = newElement;
  }
  
! void concatenateBeat(t_rhythm_event *currentEvent, unsigned short int voice, float fstart, float fduration)
  {
  	t_duration res;
***************
*** 135,142 ****
  	lastElement->next = newElement;
  	newElement->voice=voice;
- 	newElement->played=played;
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
! 
  }
  
--- 137,145 ----
  	lastElement->next = newElement;
  	newElement->voice=voice;
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
! 	res = float2duration(fstart);
! 	newElement->start.numerator = res.numerator;
! 	newElement->start.denominator = res.denominator;
  }
  
***************
*** 161,165 ****
  }
  
! void add_t_rhythm_memory_arc(t_rhythm_memory_node *srcNode, t_rhythm_memory_node *dstNode)
  {
  	t_rhythm_memory_arc *newArc;
--- 164,168 ----
  }
  
! void add_t_rhythm_memory_arc(t_rhythm_memory_node *srcNode, unsigned short int dstNode)
  {
  	t_rhythm_memory_arc *newArc;
***************
*** 168,173 ****
  	// create a new arc
  	newArc = (t_rhythm_memory_arc *) malloc(sizeof(t_rhythm_memory_arc));
! 	newArc->to_node = dstNode;
! 	newArc->weight = 1;
  	// go to the last arc in the list
  	// and add this arc as the last
--- 171,175 ----
  	// create a new arc
  	newArc = (t_rhythm_memory_arc *) malloc(sizeof(t_rhythm_memory_arc));
! 	newArc->to_node_index = dstNode;
  	// go to the last arc in the list
  	// and add this arc as the last
***************
*** 187,195 ****
  
  // initialize this representation, allocates memory for the pointers
! void init_rhythm_memory_representation(t_rhythm_memory_representation *this_rep)
  {
! 	this_rep->transitions = (t_rhythm_memory_node *) malloc(sizeof(t_rhythm_memory_node) * possible_durations());
! 	this_rep->main_rhythm = 0;
! 	this_rep->similar_rhythms = 0;
  }
  
--- 189,208 ----
  
  // initialize this representation, allocates memory for the pointers
! void create_rhythm_memory_representation(t_rhythm_memory_representation **this_rep)
  {
! 	int i;
! 	// allocate space for the data structure
! 	*this_rep = (t_rhythm_memory_representation *)malloc(sizeof(t_rhythm_memory_representation));
! 	// space for transitions
! 	(*this_rep)->transitions = (t_rhythm_memory_node *) malloc(sizeof(t_rhythm_memory_node) * possible_durations());
! 	// initialize transitions
! 	for (i=0; i<possible_durations(); i++)
! 	{
! 		(*this_rep)->transitions[i].first=0;
! 		(*this_rep)->transitions[i].weight=0;
! 		(*this_rep)->transitions[i].arcs=0;
! 	}
! 	(*this_rep)->main_rhythm = 0;
! 	(*this_rep)->similar_rhythms = 0;
  }
  
***************
*** 199,202 ****
--- 212,219 ----
  	t_rhythm_memory_element *curr;
  	t_rhythm_memory_element *newElement;
+ 	t_rhythm_event *currEvent;
+ 	t_rhythm_memory_arc *currArc, *newArc, *prevArc;
+ 	unsigned short int last;
+ 	int i, arcFound;
  	// creates a new element of the list of similar rhythms
  	newElement = (t_rhythm_memory_element *) malloc(sizeof(t_rhythm_memory_element));
***************
*** 216,288 ****
  	}
  	// now update the transition table..
! }
! 
! // from (duration) to (start) style
! void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
! {
! 	t_rhythm_event *oldCurr, *newElement, *oldPrev, *newPrev;
! 	float diff, currMoment;
! 	t_duration dur_tmp;
! 
! 	// allocate the first event
! 	oldCurr = oldStyle;
! 	oldPrev = 0;
! 	currMoment = 0;
! 	newPrev = 0;
! 	
! 	// look for the first beat played in old rhythm
! 	while (oldCurr && (! (oldCurr->played)))
! 	{
! 		// prepare for the next event
! 		dur_tmp.numerator = oldCurr->duration.numerator;
! 		dur_tmp.denominator = oldCurr->duration.denominator;
! 		currMoment = duration2float(dur_tmp);
! 		oldPrev = oldCurr;
! 		oldCurr = oldCurr->next;
! 	}
! 
! 	if (currMoment == 0)
! 		return; // empty rhythm?!?
! 
! 	// now in currMoment there is the moment of the first played beat
! 	// i can set the first one and initialize the new style
! 	newElement = (t_rhythm_event *) malloc(sizeof(t_rhythm_event));
! 	*newStyle = newElement;
! 	dur_tmp = float2duration(currMoment);
! 	newElement->duration.numerator = dur_tmp.numerator;
! 	newElement->duration.denominator = dur_tmp.denominator;
! 	newElement->previous = newPrev;
! 	newPrev = newElement;
! 
! 	while (oldCurr)
  	{
! 		if (oldCurr->played)
  		{
! 			// allocate a new element
! 			newElement = (t_rhythm_event *) malloc(sizeof(t_rhythm_event));
! 			// set its value
! 			dur_tmp = float2duration(currMoment);
! 			newElement->duration.numerator = dur_tmp.numerator;
! 			newElement->duration.denominator = dur_tmp.denominator;
! 			newElement->previous = newPrev;
! 			if (newPrev)
! 				newPrev->next = newElement;
! 			newPrev = newElement;
  		}
! 		// prepare for the next event
! 		dur_tmp.numerator = oldCurr->duration.numerator;
! 		dur_tmp.denominator = oldCurr->duration.denominator;
! 		currMoment = duration2float(dur_tmp);
! 		oldPrev = oldCurr;
! 		oldCurr = oldCurr->next;
  	}
  }
  
- // from (start) to (duration) style
- void swap_rhythm_to_duration(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
- {
- 
- }
- 
  void free_memory_representation(t_rhythm_memory_representation *this_rep)
  {
--- 233,293 ----
  	}
  	// now update the transition table..
! 	currEvent = new_rhythm;
! 	// set the first event..
! 	i = duration2int(new_rhythm->start);
! 	this_rep->transitions[i].first++;
! 	last = 0;
! 	while (currEvent)
  	{
! 		// get the duration and translate into an int
! 		i = duration2int(currEvent->start);
! 		if (last) // NB if last==0 then last is not set
  		{
! 			// add an arc between last and i
! 			currArc = this_rep->transitions[last].arcs;
! 			arcFound=0;
! 			// is this arc rpesent?
! 			// also i need to get to the last element of the lsit
! 			while (currArc)
! 			{
! 				// for each arc in the list
! 				if (currArc->to_node_index == i)
! 				{
! 					// this arc is already present
! 					arcFound=1;
! 				}
! 				prevArc = currArc; // last valid arc
! 				currArc = currArc->next_arc;
! 			} 
! 			if (!arcFound)
! 			{
! 				// this arc was not present, add it!
! 				newArc = (t_rhythm_memory_arc *) malloc(sizeof(t_rhythm_memory_arc));
! 				newArc->next_arc = 0; 
! 				newArc->to_node_index = i; // set my destination
! 				if (this_rep->transitions[last].arcs)
! 				{
! 					// this is not the first arc
! 					// then prevArc is set and valid
! 					prevArc->next_arc = newArc;
! 				} else
! 				{
! 					// this is the first arc
! 					this_rep->transitions[last].arcs = newArc;
! 				}
! 			}
  		}
! 		// increment the weight
! 		this_rep->transitions[i].weight++;
! 		if (this_rep->transitions[i].weight > this_rep->max_weight)
! 		{
! 			// a new champion!
! 			this_rep->max_weight = this_rep->transitions[i].weight;
! 		}
! 		last = i;
! 		currEvent = currEvent->next;
  	}
  }
  
  void free_memory_representation(t_rhythm_memory_representation *this_rep)
  {
***************
*** 327,331 ****
  
  // set the first note of a sequence
! void setFirstNote(t_note_event **firstEvent, unsigned short int voice, float fduration, t_note note)
  {
  	t_duration res;
--- 332,336 ----
  
  // set the first note of a sequence
! void setFirstNote(t_note_event **firstEvent, unsigned short int voice, float fstart, float fduration, t_note note)
  {
  	t_duration res;
***************
*** 339,343 ****
  	newElement->next = 0;
  	newElement->voice=voice;
- 	newElement->note.played = note.played;
  	newElement->note.chord = note.chord;
  	newElement->note.diatonic = note.diatonic;
--- 344,347 ----
***************
*** 345,353 ****
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
  	*firstEvent = newElement;
  }
  
  //adds a note at the end of this list
! void concatenateNote(t_note_event *currentEvent, unsigned short int voice, float fduration, t_note note)
  {
  	t_duration res;
--- 349,360 ----
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
+ 	res = float2duration(fstart);
+ 	newElement->start.numerator = res.numerator;
+ 	newElement->start.denominator = res.denominator;
  	*firstEvent = newElement;
  }
  
  //adds a note at the end of this list
! void concatenateNote(t_note_event *currentEvent, unsigned short int voice, float fstart, float fduration, t_note note)
  {
  	t_duration res;
***************
*** 365,369 ****
  	lastElement->next = newElement;
  	newElement->voice=voice;
- 	newElement->note.played = note.played;
  	newElement->note.chord = note.chord;
  	newElement->note.diatonic = note.diatonic;
--- 372,375 ----
***************
*** 371,375 ****
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
! 
  }
  
--- 377,383 ----
  	newElement->duration.numerator = res.numerator;
  	newElement->duration.denominator = res.denominator;
! 	res = float2duration(fstart);
! 	newElement->start.numerator = res.numerator;
! 	newElement->start.denominator = res.denominator;
  }
  





More information about the Pd-cvs mailing list