51 lines
972 B
C
51 lines
972 B
C
/**
|
|
* @file samples.c
|
|
*
|
|
* Implémentation de samples.h
|
|
*
|
|
* @version 1
|
|
* @author Guy
|
|
* @date Mai 2014
|
|
*/
|
|
|
|
#include "samples.h"
|
|
|
|
int doitEtreSauvegarde(Sample* tab[], int i) {
|
|
return !(tab[i]->chemin[0]=='.' && tab[i]->chemin[1]=='/');
|
|
}
|
|
|
|
void setSauvegarde(Sample* tab[], int i) {
|
|
sprintf(tab[i]->chemin,"./%d.wav",i);
|
|
}
|
|
|
|
void ajouterSample(Sample* tab[], int i, char* chemin) {
|
|
tab[i] = calloc(1,sizeof(Sample));
|
|
sprintf(tab[i]->nom,"Sample %d",i);
|
|
}
|
|
|
|
void supprimerSample(Sample* tab[], int i, Poubelle** poub) {
|
|
if (!(doitEtreSauvegarde(tab, i))) {
|
|
Poubelle* p = malloc(sizeof(Poubelle));
|
|
strcpy(p->chemin, tab[i]->chemin);
|
|
p->suiv = *poub;
|
|
*poub = p;
|
|
}
|
|
free(tab[i]);
|
|
}
|
|
|
|
void setNom(Sample* sample, char nom[]) {
|
|
strcpy(sample->nom,nom);
|
|
}
|
|
|
|
void setHauteur(Sample* sample, float hauteur) {
|
|
sample->hauteur_ref = hauteur;
|
|
}
|
|
|
|
char* getNom(Sample* sample) {
|
|
return sample->nom;
|
|
}
|
|
|
|
float getHauteur(Sample* sample) {
|
|
return sample->hauteur_ref;
|
|
}
|