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-01 21:31:20 +02:00
|
|
|
void ajouterMotif(){
|
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-01 13:48:39 +02:00
|
|
|
m->suivant = liste;
|
2014-04-01 14:11:27 +02:00
|
|
|
m->motif = malloc(nbrPortees*sizeof(Portee));
|
|
|
|
char* nombre = NULL;
|
|
|
|
sprintf(nombre,"%d",getIdMotif(m));
|
|
|
|
m->nom = strcat("Motif ", nombre);
|
2014-04-01 13:48:39 +02:00
|
|
|
int i;
|
|
|
|
for (i=0; i<nbrPortees; i++) {
|
2014-04-01 21:31:20 +02:00
|
|
|
m->motif[i] = calloc(DEFNBRTMP,sizeof(Note));
|
2014-04-01 13:48:39 +02:00
|
|
|
}
|
|
|
|
liste = 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-01 13:48:39 +02:00
|
|
|
m->nom = nom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void supprimerMotif(Motif** cellule){
|
|
|
|
int i;
|
|
|
|
for (i=0; i<nbrPortees; i++) {
|
|
|
|
free((*cellule)->motif[i]);
|
|
|
|
}
|
|
|
|
free((*cellule)->motif);
|
|
|
|
Motif* aux = (*cellule)->suivant;
|
|
|
|
free((*cellule));
|
|
|
|
*cellule = aux;
|
|
|
|
}
|
|
|
|
|
|
|
|
void definirNote(Motif* m, int portee, int tmp, int note){
|
2014-04-01 14:11:27 +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){
|
|
|
|
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){
|
|
|
|
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){
|
|
|
|
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){
|
|
|
|
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-01 13:48:39 +02:00
|
|
|
m->motif[portee][tmp]->note = 0;
|
|
|
|
}
|