From ee77215acfe3d92c7e650869f6a5fc16d3ce574e Mon Sep 17 00:00:00 2001 From: Raspbeguy Date: Thu, 10 Apr 2014 17:44:27 +0200 Subject: [PATCH] =?UTF-8?q?Atteinte=20de=20l'objectif=20proto=20:=20=C3=A7?= =?UTF-8?q?a=20joue=20de=20la=20musique=20:)=20(et=20pas=20n'importe=20laq?= =?UTF-8?q?uelle)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/lecture/0.wav | Bin 0 -> 224 bytes sources/lecture/1.wav | Bin 0 -> 212 bytes sources/lecture/2.wav | Bin 0 -> 194 bytes sources/lecture/3.wav | Bin 0 -> 180 bytes sources/lecture/4.wav | Bin 0 -> 158 bytes sources/lecture/Saw.wav | Bin 720 -> 0 bytes sources/lecture/Square.wav | Bin 902 -> 0 bytes sources/lecture/lecture.c | 29 +++++++++++--- sources/main.c | 78 ++++++++++++++++++++++++++++++++++--- 9 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 sources/lecture/0.wav create mode 100644 sources/lecture/1.wav create mode 100644 sources/lecture/2.wav create mode 100644 sources/lecture/3.wav create mode 100644 sources/lecture/4.wav delete mode 100644 sources/lecture/Saw.wav delete mode 100644 sources/lecture/Square.wav diff --git a/sources/lecture/0.wav b/sources/lecture/0.wav new file mode 100644 index 0000000000000000000000000000000000000000..bcd0ce5063a790810f9196e820d7fd0c2526c0db GIT binary patch literal 224 zcmV<603ZKSNk&H400012K~_a(ZFC?I000010096*tN;LrSOEY601yCVVRT`%0002; zKg>TomFwHHIDitSjBb*$a!!*J&!G*vkz!$(=!0y1)!3V>F#8bv$ z$id27%{JNrB@J`F#mKjJ@1Twf^w literal 0 HcmV?d00001 diff --git a/sources/lecture/1.wav b/sources/lecture/1.wav new file mode 100644 index 0000000000000000000000000000000000000000..3861e024e035f6b6eaa05518fa435d0a3b60552c GIT binary patch literal 212 zcmV;_04x7eNk&G@00012K~_a(ZFC?I000010096*tN;LrSOEY601yCVVRT`r00016 zLsdiULMK82L4ZG}J#ahiI1x7NGJ-G5E8r)#BUm5U8Xy*25pWE92YLc?{d4$w^Ox?$ z=^y2k;62Bh#)`?E z%m>h>)05Y(+XLW+_@?zf`_Zz0JJ4yeGX1zF)sC!Dqt~#v{p*%xKVq)cx45-KpZw w=O^u*@+tVu{bd6N36Ku_6Hggv9#td#CtxgbFfBBSH-|bGJv~3~KrKS{LTz_ai2wiq literal 0 HcmV?d00001 diff --git a/sources/lecture/3.wav b/sources/lecture/3.wav new file mode 100644 index 0000000000000000000000000000000000000000..3854a704c963927d227bbc411be788d93050c828 GIT binary patch literal 180 zcmV;l089T;Nk&Gj00012K~_a(ZFC?I000010096*tN;LrSOEY601yCVVRT`L0000B zLpwv-LfJu1KrKFgJ5e~6G;%Q1E8HfCA?zCv76TB^35WwT{pj|v@SN(mMHV@`5pnD2m=r@7aJa+B(N$vFeNo` MIs81yKg&V=LKAyII{*Lx literal 0 HcmV?d00001 diff --git a/sources/lecture/Saw.wav b/sources/lecture/Saw.wav deleted file mode 100644 index f60e61c96ff02db5f10b816bbcc30a0e539961a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 720 zcmV;>0x$hiNk&G<0ssJ4K~_a(ZFC?I0000100IC+tN;KIu>t@D01yCVVRT`n0ssIA z00{ua0m}hk0%`&h0~rIh1GxiZ1Z4yU1q%hO1+@iK23H3D2K@%42cic_2ucX<2=54z z36u#r3O5Sh3fc;T3x5kH3?&T649E;@4Qve#4i65o4zdnY4^G7#A3^7_=Bp8B!VT z8SWX08jBhy8zvjY8^Rl49A6y!9Qz!X9hMz39x@)w9?%|QA8jA}9|jv=I7>_=bqAdM`>TT*F>mTdW>(%Ro?1=0)?K$o2?da{H z?wIaU?@aFi@B#3y@Urk=@ni81@)PpF^1||Q^KkPa^dR)l^w0Et^?&s%_AU0>_SyD{ z_lNg2_%`_A_~iJG`H%TL`Z@aR`sVtR`;z-W{6hTY{OSCb{hj?b{x|;l{_*~R|9Jm# C6<6K> diff --git a/sources/lecture/Square.wav b/sources/lecture/Square.wav deleted file mode 100644 index 197a3ebfc6ee496fc8f529884dc7d1bc57a20493..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 902 zcmWIYbaSg?W?%?+40BD(Em06)U|?WoU}A7t!@!`B#LB?Ipumupm|VgF6b}L7l*E$6 z1xySK9Q?g@qnN5;un!oXqnJuzP@G$kqXJB?Ffb*8fx!mGL8CMCic8pmVj%f?AWTfo zOpySxS;1lrKoSC27(lszfx*W!I0VE>Oex6$vF(6tPd_(*PiNl{B_KN}H95a1B{fAM nKTpBHT;IS%-^jqwL?JUz!8IkbI6qI1!86z`1Y{$G&%gix<^<(O diff --git a/sources/lecture/lecture.c b/sources/lecture/lecture.c index a6424b1..b8d5856 100644 --- a/sources/lecture/lecture.c +++ b/sources/lecture/lecture.c @@ -6,22 +6,39 @@ void lireTick (Motif* m, int tmp, Mix_Chunk* chunk[], int nbrPortees) { // On for (int chaine = 0; chaine < nbrPortees; chaine++) { // On va lire les chaines une à une par numéro croissant if (m != NULL) { - if (getNote(m,0,tmp) == -1) Mix_HaltChannel(chaine); // Si la note est un silence, la chaine s'arrête + if (getInstrument(m,0,tmp) == -1) Mix_HaltChannel(chaine); // Si la note est un silence, la chaine s'arrête else { - Mix_PlayChannel(-1, chunk[getInstrument(m,chaine,tmp)], -1); // Sinon le sample de la chaine est joué en boucle + if (getNote(m,0,tmp) != 0) { + Mix_PlayChannel(chaine, chunk[getInstrument(m,chaine,tmp)], -1); // Sinon le sample de la chaine est joué en boucle + } } } } - while (SDL_GetTicks() - tempsPrecedent < 250) {} // Si 250 ms se sont écoulées (il faudra régler ce temps sur le tempo) - tempsPrecedent = tempsPrecedent + 250; + while (SDL_GetTicks() - tempsPrecedent < 125) {} // Si 250 ms se sont écoulées (il faudra régler ce temps sur le tempo) + tempsPrecedent = tempsPrecedent + 125; } void lecture (int nombreChaines, Motif* melodie[]) { + // Tout ça c'est pour ouvrir le périphérique audio + int audio_rate = 44100; + Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ + int audio_channels = 1; + int audio_buffers = 4096; SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); - + if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { + printf("Unable to open audio!\n"); + exit(1); + } + //INITIALISATION SAMPLES ET CHANNELS Mix_AllocateChannels(nombreChaines); // On ouvre le nombre de chaines nécessaires dans le mixer - Mix_Chunk* chunk[2] = {Mix_LoadWAV("Square.wav"), Mix_LoadWAV("Saw.wav")}; + Mix_Chunk* chunk[5]; + chunk[0] = Mix_LoadWAV("lecture/0.wav"); + chunk[1] = Mix_LoadWAV("lecture/1.wav"); + chunk[2] = Mix_LoadWAV("lecture/2.wav"); + chunk[3] = Mix_LoadWAV("lecture/3.wav"); + chunk[4] = Mix_LoadWAV("lecture/4.wav"); + //Lecture des motifs for (courant = 0; courant < taille; courant++) { for (int i = 0; i < melodie[courant] -> nbrTmp; i++) { diff --git a/sources/main.c b/sources/main.c index 06407a0..3be054f 100644 --- a/sources/main.c +++ b/sources/main.c @@ -29,16 +29,84 @@ void afficherMotif(Motif* m, int nbrPortees){ void debut(Motif* melodie[], Motif* liste, int nbrPortees){ ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees); Motif* m = liste; - definirNote(m,0,4,5); - definirNote(m,0,2,9); + + // My Little Pony. + definirNote(m,0,0,1); + definirInstrument(m,0,0,1); + definirInstrument(m,0,2,-1); + definirNote(m,0,4,1); + definirInstrument(m,0,4,0); + definirNote(m,0,5,1); + definirInstrument(m,0,5,1); + definirInstrument(m,0,6,-1); + definirNote(m,0,7,1); + definirInstrument(m,0,7,2); + definirInstrument(m,0,8,-1); + definirNote(m,0,9,1); + definirInstrument(m,0,9,1); + definirInstrument(m,0,12,-1); + ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees); Motif* n = liste; - definirNote(n,0,10,3); - definirNote(n,0,6,7); + + // I used to wonder what friendship could be. + definirNote(n,0,1,1); + definirInstrument(n,0,1,3); + definirNote(n,0,2,1); + definirInstrument(n,0,2,3); + definirNote(n,0,3,1); + definirInstrument(n,0,3,3); + definirNote(n,0,4,1); + definirInstrument(n,0,4,3); + definirInstrument(n,0,5,-1); + definirNote(n,0,6,1); + definirInstrument(n,0,6,1); + definirNote(n,0,7,1); + definirInstrument(n,0,7,2); + definirInstrument(n,0,8,-1); + definirNote(n,0,9,1); + definirInstrument(n,0,9,1); + definirInstrument(n,0,10,-1); + definirNote(n,0,11,1); + definirInstrument(n,0,11,3); + definirInstrument(n,0,12,-1); + definirNote(n,0,13,1); + definirInstrument(n,0,13,2); + definirInstrument(n,0,14,-1); + definirNote(n,0,15,1); + definirInstrument(n,0,15,1); + + ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees); + Motif* p = liste; + + // Until you all shared its magic with me. + definirNote(p,0,0,1); + definirInstrument(p,0,0,3); + definirNote(p,0,1,1); + definirInstrument(p,0,1,4); + definirInstrument(p,0,2,-1); + definirNote(p,0,3,1); + definirInstrument(p,0,3,4); + definirInstrument(p,0,4,-1); + definirNote(p,0,5,1); + definirInstrument(p,0,5,3); + definirInstrument(p,0,6,-1); + definirNote(p,0,7,1); + definirInstrument(p,0,7,2); + definirInstrument(p,0,8,-1); + definirNote(p,0,9,1); + definirInstrument(p,0,9,1); + definirNote(p,0,10,1); + definirInstrument(p,0,10,3); + definirInstrument(p,0,11,-1); + definirNote(p,0,12,1); + definirInstrument(p,0,12,2); + definirInstrument(p,0,14,-1); + ajouterMotifVirtuel(melodie,0,m); ajouterMotifVirtuel(melodie,1,n); ajouterMotifVirtuel(melodie,2,m); - ajouterMotifVirtuel(melodie,3,n); + ajouterMotifVirtuel(melodie,3,p); } int main( int argc, char *argv[] ){