2014-04-01 13:48:39 +02:00
|
|
|
#include <string.h>
|
2014-03-29 17:47:13 +01:00
|
|
|
#include "motifs.h"
|
|
|
|
|
2014-04-01 13:48:39 +02:00
|
|
|
int getIdMotif(Motif* m){
|
|
|
|
if (m == NULL) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return getIdMotif(m->suivant)+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-06 20:08:43 +02:00
|
|
|
void ajouterMotif(Motif** pliste, int nbrTmp, int nbrPortees){
|
2014-04-01 13:48:39 +02:00
|
|
|
Motif* m = malloc(sizeof(Motif));
|
2014-04-01 21:31:20 +02:00
|
|
|
m->nbrTmp = DEFNBRTMP;
|
2014-04-06 20:08:43 +02:00
|
|
|
m->suivant = *pliste;
|
|
|
|
m->motif = malloc(nbrPortees*sizeof(Portee*));
|
|
|
|
strcpy(m->nom,"Motif ");
|
|
|
|
char nombre[10];
|
2014-04-01 14:11:27 +02:00
|
|
|
sprintf(nombre,"%d",getIdMotif(m));
|
2014-04-06 20:08:43 +02:00
|
|
|
strcat(m->nom, nombre);
|
2014-04-01 13:48:39 +02:00
|
|
|
int i;
|
|
|
|
for (i=0; i<nbrPortees; i++) {
|
2014-04-06 20:08:43 +02:00
|
|
|
(*m->motif)[i] = calloc(DEFNBRTMP,sizeof(Note));
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
2014-04-06 20:08:43 +02:00
|
|
|
*pliste = m;
|
2014-03-29 18:00:23 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 21:31:20 +02:00
|
|
|
void definirNomMotif(Motif* m, char* nom){
|
2014-04-06 20:08:43 +02:00
|
|
|
strcpy(m->nom,nom);
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-03 12:16:16 +02:00
|
|
|
void supprimerMotif(Motif** cellule, int nbrPortees){
|
2014-04-01 13:48:39 +02:00
|
|
|
int i;
|
|
|
|
for (i=0; i<nbrPortees; i++) {
|
2014-04-06 20:08:43 +02:00
|
|
|
free((*((*cellule)->motif))[i]);
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
free((*cellule)->motif);
|
|
|
|
Motif* aux = (*cellule)->suivant;
|
|
|
|
free((*cellule));
|
|
|
|
*cellule = aux;
|
|
|
|
}
|
|
|
|
|
|
|
|
void definirNote(Motif* m, int portee, int tmp, int note){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].note = note;
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-01 14:11:27 +02:00
|
|
|
void definirOctave(Motif* m, int portee, int tmp, int octave){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].octave = octave;
|
2014-03-29 18:00:23 +01:00
|
|
|
}
|
2014-04-01 13:48:39 +02:00
|
|
|
|
2014-04-01 14:11:27 +02:00
|
|
|
void definirInstrument(Motif* m, int portee, int tmp, int instrument){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].instrument = instrument;
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-01 14:11:27 +02:00
|
|
|
void definirVolume(Motif* m, int portee, int tmp, int volume){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].volume = volume;
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-01 14:11:27 +02:00
|
|
|
void definirEffet(Motif* m, int portee, int tmp, int effet){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].effet = effet;
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-01 14:11:27 +02:00
|
|
|
void supprimerNote(Motif* m, int portee, int tmp){
|
2014-04-06 20:08:43 +02:00
|
|
|
(*(*m->motif)[portee])[tmp].note = 0;
|
2014-04-03 12:16:16 +02:00
|
|
|
}
|
2014-04-06 20:24:35 +02:00
|
|
|
|
|
|
|
int getNote(Motif* m, int portee, int tmp){
|
|
|
|
return (*(*m->motif)[portee])[tmp].note;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getOctave(Motif* m, int portee, int tmp){
|
|
|
|
return (*(*m->motif)[portee])[tmp].octave;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getInstrument(Motif* m, int portee, int tmp){
|
|
|
|
return (*(*m->motif)[portee])[tmp].instrument;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getVolume(Motif* m, int portee, int tmp){
|
|
|
|
return (*(*m->motif)[portee])[tmp].volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getEffet(Motif* m, int portee, int tmp){
|
|
|
|
return (*(*m->motif)[portee])[tmp].note;
|
|
|
|
}
|