ponytracker/sources/motifs/motifs.c

86 lines
2.1 KiB
C
Raw Normal View History

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;
}
}
void ajouterMotif(Motif** pliste, int nbrTmp, int nbrPortees){
2014-04-01 13:48:39 +02:00
Motif* m = malloc(sizeof(Motif));
m->nbrTmp = DEFNBRTMP;
m->suivant = *pliste;
m->motif = malloc(nbrPortees*sizeof(Portee*));
strcpy(m->nom,"Motif ");
char nombre[10];
sprintf(nombre,"%d",getIdMotif(m));
strcat(m->nom, nombre);
2014-04-01 13:48:39 +02:00
int i;
for (i=0; i<nbrPortees; i++) {
(*m->motif)[i] = calloc(DEFNBRTMP,sizeof(Note));
2014-04-01 13:48:39 +02:00
}
*pliste = m;
2014-03-29 18:00:23 +01:00
}
void definirNomMotif(Motif* m, char* nom){
strcpy(m->nom,nom);
2014-04-01 13:48:39 +02:00
}
void supprimerMotif(Motif** cellule, int nbrPortees){
2014-04-01 13:48:39 +02:00
int i;
for (i=0; i<nbrPortees; i++) {
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){
(*(*m->motif)[portee])[tmp].note = note;
2014-04-01 13:48:39 +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
void definirInstrument(Motif* m, int portee, int tmp, int instrument){
(*(*m->motif)[portee])[tmp].instrument = instrument;
2014-04-01 13:48:39 +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
}
void definirEffet(Motif* m, int portee, int tmp, int effet){
(*(*m->motif)[portee])[tmp].effet = effet;
2014-04-01 13:48:39 +02:00
}
void supprimerNote(Motif* m, int portee, int tmp){
(*(*m->motif)[portee])[tmp].note = 0;
}
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;
}