diff --git a/.gitignore b/.gitignore index 6e34204..b4e0e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,7 @@ sources/GUI/coucou sources/tests/test sources/instrument/main sources/fichier/.fichier.h.swp -sources/samples/.samples.h.swp \ No newline at end of file +sources/samples/.samples.h.swp +sources/instruments/.instruments.h.swp +sources/instruments/.instruments.c.swp +sources/instruments/instruments.o \ No newline at end of file diff --git a/sources/instruments/instruments.c b/sources/instruments/instruments.c new file mode 100644 index 0000000..e27b63c --- /dev/null +++ b/sources/instruments/instruments.c @@ -0,0 +1,39 @@ +/** + * @file instruments.c + * + * Implémentation de sample.h + * + * @version 1 + * @author Guy + * @date Mai 2014 + */ + +#include "instruments.h" + +int getVolume(Instrument* inst) { + return inst->volume; +} + +int getBalance(Instrument* inst) { + return inst->balance; +} + +char* getNomInst(Instrument* inst) { + return inst->nom; +} +void setVolume(Instrument* inst, int volume) { + inst->volume = volume; +} + +void setBalance(Instrument* inst, int balance) { + inst->balance = balance; +} + +void setNomInst(Instrument* inst, char* nom) { + strcpy(inst->nom,nom); +} + +float rapportPitch(Instrument* inst, int note, int octave){ + float freq = 440*pow(2,(octave-3)+(note-11)*(1.0/12.0)); + return freq/(inst->sample->hauteur_ref); +} diff --git a/sources/instruments/instruments.h b/sources/instruments/instruments.h index ddd70a4..4d2a990 100644 --- a/sources/instruments/instruments.h +++ b/sources/instruments/instruments.h @@ -1,8 +1,21 @@ +/** + * @file instruments.h + * + * Gestion des instruments + * + * @version 1 + * @author Guy + * @date Mai 2014 + */ + + #ifndef _instruments_h #define _instruments_h #include #include +#include +#include #include "../samples/samples.h" typedef struct _enveloppe { @@ -16,10 +29,24 @@ typedef struct _intrument { Enveloppe enveloppe; int balance; int volume; - char[] nom; + char* nom; } Instrument; -// TODO -// Setters-getters et tous le bordel, rien de bien compliqué, mais j'avoue qu'à cette heure ci, j'ai un peu la flemme et je suis trop crevé. +int getVolume(Instrument* inst); + +int getBalance(Instrument* inst); + +char* getNomInst(Instrument* inst); + +void setVolume(Instrument* inst, int volume); + +void setBalance(Instrument* inst, int balance); + +void setNomInst(Instrument* inst, char* nom); + +/* + * Cette fonction prend une note et une octave en paramètre et renvoie la valeur à entrer dans le pitch shifter. + */ +float rapportPitch(Instrument* inst, int note, int octave); #endif diff --git a/sources/samples/.samples.c.swp b/sources/samples/.samples.c.swp deleted file mode 100644 index 4375de5..0000000 Binary files a/sources/samples/.samples.c.swp and /dev/null differ