Commit important : maintenant, y a des trucs qui marchent :)

This commit is contained in:
Raspbeguy
2014-04-06 20:08:43 +02:00
parent 33e4ec7e4a
commit 9a8c5c711a
6 changed files with 54 additions and 24 deletions

View File

@@ -9,29 +9,30 @@ int getIdMotif(Motif* m){
}
}
void ajouterMotif(Motif* liste, int nbrTmp, int nbrPortees){
void ajouterMotif(Motif** pliste, int nbrTmp, int nbrPortees){
Motif* m = malloc(sizeof(Motif));
m->nbrTmp = DEFNBRTMP;
m->suivant = liste;
m->motif = malloc(nbrPortees*sizeof(Portee));
char* nombre = NULL;
m->suivant = *pliste;
m->motif = malloc(nbrPortees*sizeof(Portee*));
strcpy(m->nom,"Motif ");
char nombre[10];
sprintf(nombre,"%d",getIdMotif(m));
m->nom = strcat("Motif ", nombre);
strcat(m->nom, nombre);
int i;
for (i=0; i<nbrPortees; i++) {
m->motif[i] = calloc(DEFNBRTMP,sizeof(Note));
(*m->motif)[i] = calloc(DEFNBRTMP,sizeof(Note));
}
liste = m;
*pliste = m;
}
void definirNomMotif(Motif* m, char* nom){
m->nom = 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))[i]);
}
free((*cellule)->motif);
Motif* aux = (*cellule)->suivant;
@@ -40,25 +41,25 @@ void supprimerMotif(Motif** cellule, int nbrPortees){
}
void definirNote(Motif* m, int portee, int tmp, int note){
m->motif[portee][tmp]->note = note;
(*(*m->motif)[portee])[tmp].note = note;
}
void definirOctave(Motif* m, int portee, int tmp, int octave){
m->motif[portee][tmp]->octave = octave;
(*(*m->motif)[portee])[tmp].octave = octave;
}
void definirInstrument(Motif* m, int portee, int tmp, int instrument){
m->motif[portee][tmp]->instrument = instrument;
(*(*m->motif)[portee])[tmp].instrument = instrument;
}
void definirVolume(Motif* m, int portee, int tmp, int volume){
m->motif[portee][tmp]->volume = volume;
(*(*m->motif)[portee])[tmp].volume = volume;
}
void definirEffet(Motif* m, int portee, int tmp, int effet){
m->motif[portee][tmp]->effet = effet;
(*(*m->motif)[portee])[tmp].effet = effet;
}
void supprimerNote(Motif* m, int portee, int tmp){
m->motif[portee][tmp]->note = 0;
(*(*m->motif)[portee])[tmp].note = 0;
}

View File

@@ -14,18 +14,20 @@ typedef struct _note{
int effet;
} Note;
typedef Note** Portee;
typedef Note Portee[];
typedef Portee* Mesure[];
typedef struct _motif{
char* nom;
char nom[10];
int nbrTmp;
Portee* motif;
Mesure* motif;
struct _motif* suivant;
} Motif;
int getIdMotif(Motif* m);
void ajouterMotif(Motif* liste, int nbrTmp, int nbrPortees);
void ajouterMotif(Motif** pliste, int nbrTmp, int nbrPortees);
void definirNomMotif(Motif* m, char* nom);