ponytracker/sources/motifs/motifs.c

64 lines
1.5 KiB
C

#include <string.h>
#include "motifs.h"
int getIdMotif(Motif* m){
if (m == NULL) {
return 0;
} else {
return getIdMotif(m->suivant)+1;
}
}
void ajouterMotif(){
Motif* m = malloc(sizeof(Motif));
m->nbrTmp = DEFNBRTMP;
m->suivant = liste;
m->motif = malloc(nbrPortees*sizeof(Portee));
char* nombre = NULL;
sprintf(nombre,"%d",getIdMotif(m));
m->nom = strcat("Motif ", nombre);
int i;
for (i=0; i<nbrPortees; i++) {
m->motif[i] = calloc(DEFNBRTMP,sizeof(Note));
}
liste = m;
}
void definirNomMotif(Motif* m, char* nom){
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){
m->motif[portee][tmp]->note = note;
}
void definirOctave(Motif* m, int portee, int tmp, int octave){
m->motif[portee][tmp]->octave = octave;
}
void definirInstrument(Motif* m, int portee, int tmp, int instrument){
m->motif[portee][tmp]->instrument = instrument;
}
void definirVolume(Motif* m, int portee, int tmp, int volume){
m->motif[portee][tmp]->volume = volume;
}
void definirEffet(Motif* m, int portee, int tmp, int effet){
m->motif[portee][tmp]->effet = effet;
}
void supprimerNote(Motif* m, int portee, int tmp){
m->motif[portee][tmp]->note = 0;
}