[PD-cvs] externals/frankenstein common.c,1.2,1.3 common.h,1.2,1.3
dmorelli
morellid at users.sourceforge.net
Thu Dec 1 13:09:07 CET 2005
Update of /cvsroot/pure-data/externals/frankenstein
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30171
Modified Files:
common.c common.h
Log Message:
going on with functions
Index: common.h
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/common.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** common.h 30 Nov 2005 17:31:33 -0000 1.2
--- common.h 1 Dec 2005 12:09:05 -0000 1.3
***************
*** 28,36 ****
} t_note_event;
- // manipolation functions
-
- // TODO:
- // - from data structures to lists of numbers and vice versa
- // - from a (voice, rest, duration) representation to (voice, start, duration) and viceversa
// --------- rhythm notation
--- 28,31 ----
***************
*** 82,86 ****
int possible_durations();
! // manipolation functions
// TODO:
--- 77,81 ----
int possible_durations();
! // ----------- rhythm manipolation functions
// TODO:
***************
*** 101,103 ****
// used to free the memory allocated by this list
! void freeBeats(t_rhythm_event *currentEvent);
\ No newline at end of file
--- 96,110 ----
// used to free the memory allocated by this list
! void freeBeats(t_rhythm_event *currentEvent);
!
! // -------- notes manipulation functions
!
! // 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
! void freeNotes(t_note_event *currentEvent);
!
Index: common.c
===================================================================
RCS file: /cvsroot/pure-data/externals/frankenstein/common.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** common.c 30 Nov 2005 17:31:33 -0000 1.2
--- common.c 1 Dec 2005 12:09:05 -0000 1.3
***************
*** 157,159 ****
--- 157,229 ----
} while(next);
+ }
+
+
+ // 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;
+ t_note_event *newElement;
+ // convert from float to duration
+ res = float2duration(fduration);
+ // allocate a new element of the list
+ newElement = malloc(sizeof(t_note_event));
+ // set the pointers
+ newElement->previous = 0;
+ newElement->next = 0;
+ newElement->voice=voice;
+ newElement->note.played = note.played;
+ newElement->note.chord = note.chord;
+ newElement->note.diatonic = note.diatonic;
+ newElement->note.interval = note.interval;
+ 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;
+ t_note_event *newElement, *lastElement;
+ lastElement = currentEvent;
+ while(lastElement->next)
+ lastElement = lastElement->next;
+ // convert from float to duration
+ res = float2duration(fduration);
+ // allocate a new element of the list
+ newElement = (t_rhythm_event *) malloc(sizeof(t_note_event));
+ // set the pointers
+ newElement->previous = lastElement;
+ newElement->next = 0;
+ lastElement->next = newElement;
+ newElement->voice=voice;
+ newElement->note.played = note.played;
+ newElement->note.chord = note.chord;
+ newElement->note.diatonic = note.diatonic;
+ newElement->note.interval = note.interval;
+ newElement->duration.numerator = res.numerator;
+ newElement->duration.denominator = res.denominator;
+
+ }
+
+ // used to free the memory allocated by this list
+ void freeNotes(t_note_event *currentEvent)
+ {
+ t_note_event *prev;
+ t_note_event *next;
+
+ // go to the first element of the list
+ while(currentEvent->previous)
+ currentEvent = currentEvent->previous;
+
+ // now free each element
+ next=currentEvent->next;
+ do
+ {
+ prev = currentEvent;
+ next = currentEvent->next;
+ free(currentEvent);
+ } while(next);
+
}
\ No newline at end of file
More information about the Pd-cvs
mailing list