ponytracker/sources/motifs/motifs.c

62 lines
1.4 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;
}
}
2014-03-29 17:47:13 +01:00
void ajouterMotif(int nbrPortees, int nbrTmp){
2014-04-01 13:48:39 +02:00
Motif* m = malloc(sizeof(Motif));
m->nbrTmp = nbrTmp;
m->suivant = liste;
m->motif = malloc(nbrPortees*sizeof(portee));
m->nom = strcat("Motif %d", getIdMotif(m));
int i;
for (i=0; i<nbrPortees; i++) {
m->motif[i] = calloc(nbrTmp,sizeof(Note));
}
liste = m;
2014-03-29 18:00:23 +01:00
}
2014-04-01 13:48:39 +02:00
void definirNomMotif(char* nom, Motif* m){
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;
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 intrument){
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;
}