96 lines
2.3 KiB
C
96 lines
2.3 KiB
C
/**
|
|
* @file motifs.c
|
|
*
|
|
* Ce module implémente les fonctions du fichier motifs.h
|
|
*
|
|
* @version 1
|
|
* @author Module CSC3502 : Projet Informatique 1ère année TELECOM SudParis
|
|
* @date Mai 2014
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include "motifs.h"
|
|
|
|
int getIdMotif(Motif* m){
|
|
if (m == NULL) {
|
|
return 0;
|
|
} else {
|
|
return getIdMotif(m->suivant)+1;
|
|
}
|
|
}
|
|
|
|
void ajouterMotif(Motif** pliste, int nbrTmp, int nbrPortees){
|
|
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);
|
|
int i;
|
|
for (i=0; i<nbrPortees; i++) {
|
|
(*m->motif)[i] = calloc(DEFNBRTMP,sizeof(Note));
|
|
}
|
|
*pliste = m;
|
|
}
|
|
|
|
void definirNomMotif(Motif* m, char* nom){
|
|
strcpy(m->nom,nom);
|
|
}
|
|
|
|
void supprimerMotif(Motif** cellule, int nbrPortees){
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|