From 2928c5869d425a4e776621808c5dc32364673f94 Mon Sep 17 00:00:00 2001 From: Raspbeguy Date: Thu, 15 May 2014 20:38:24 +0200 Subject: [PATCH] =?UTF-8?q?Module=20instrument=20qui=20compile,=20mais=20q?= =?UTF-8?q?ui=20reste=20=C3=A0=20tester.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +++- sources/instruments/instruments.c | 39 ++++++++++++++++++++++++++++++ sources/instruments/instruments.h | 33 ++++++++++++++++++++++--- sources/samples/.samples.c.swp | Bin 12288 -> 0 bytes 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 sources/instruments/instruments.c delete mode 100644 sources/samples/.samples.c.swp 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 4375de50ddd887a70c31792295950ad4270a7b89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2KWh|07{(`JbH=D>FOv&N?v~5_NrDO?F^!lgkw8$yaL8nDE;n&+cbT2NaM9=| z@K50W#%Ee!e`# z@HxfU)Hk#8@Zv{yVTm!L*5j@n|Hns!p(i(ld#CILuJHO+-|sc7Xc-2PGJ#eys)T{x zH5zlJu0%nsU5rJdjfQ*IvfH;KJs<;Q;NS*^*wkdLYU@Yx!~D$Y>j$4om1KYnkO4A4 z2FL&zAOmE83>fDDiUGC&5% zz#%js8jLLuGB$l2;qm|f?C<~YCmH(!K7)5)7wmxN;3;?l9)m5=1y{fj7zD?_rxT35 z1#iF(xCd^6DNqAd@O6l>_uv`W1{uuh;FJnFZ0 zi6`OG@+?YZv>SE{S!+Zof#QC*-{X|H&B{@>TF=@vwUh-T)>c&=b92~Z&IyBf4f#Uc z=fa7(C{`WZ_J-|Hx-y=)E!kFni6`^3d)p_sj2_bSq{BnZZ3_>_tP7Fal0mbOJuBKu z)#QcYLL*S-lF@QS#2vXVbfXul#8t6qlO~4ZFx09ob@JWpxwfm; z_8DQSZ<^^=C+4iLeA0-IHu5E9vn2aKUYrQGd26LKaZ+gW_L7K=0PoJVw_DN+N zyRpvxpuX>NBg%KZxFLByO3u5NTY1K~QvrOwA&lfpLh;FJZMrvtAEs8I`DGl*w*?)k mBNh0(hC4g3h%@uMFWS;K!q{;%-s_u|%r}*{KkBlI