// dire à Processing d'ajouter les fonctions d'analyse audio et de lecture video import krister.Ess.*; import processing.video.*; // ces variables seront notre moyen acces a Ess AudioInput entree_son; FFT analyse_son; // declaration du movie Movie myMovie; // declaration des images (bandeau haut) PImage img; // declarations des variables i=incrementation X du trajet bateau 1 et bateau 2 int i; int i2; // longueur jauge rouge float lj; //variable random float et int Y de chaque bateau float r; int s; //recuperer annee en cours sur ordi hote int recup_annee = year(); // declarer variable pour affichage via texte sur chacun des 2 bateaux int annee; int annee2; // //variable construction geometrique bateau avec comme repere la pointe gche du premier triangle //bato 1 int monx; int mony; //bato 2 int monx2; int mony2; // declarations des variables bateau a gauche ou a droite int bato_01; int bato_02; // declaration de typo PFont maTypo; ////////////////////////////////////////// void setup() { // taille scene // 2D parce que size(510,375, P2D); //cadence frameRate(60); //declarer nom movie et parametre lecture du debut myMovie = new Movie(this, "cardiff_11.mov"); myMovie.loop(); // chargement du fichier externe bandeau d'introduction dans img img = loadImage("bandeau_bas.jpg"); // demarrer Ess Ess.start(this); // creer un accès à l'entrer audio entree_son=new AudioInput(); // demarrer l'analyseur audio (FFT) analyse_son=new FFT(); // lancer l'analyse entree_son.start(); // //i est la variable au X bateau i=4; //longueur jauge nulle puisque debut lj=0; //bato 1 est sur l'ecran, bateau 2 en attente a droite bato_01=1; bato_02=0; //repere initial bateau 1 monx=100; mony=225; //repere initial bateau 2 monx2=535; mony2=300; // choix de la typo sur le bateau PFont maTypo = loadFont("Univers-Condensed-48.vlw"); // //affichage annee sur bateaux annee=recup_annee; annee2=annee+1; } //////////////////////////////////////// void movieEvent(Movie myMovie) { myMovie.read(); } //////////////////////////////////////////// void draw() { // fond noir background(0); // chercher le niveau d'entree et tentative de normalisation*50 float niveau = analyse_son.getLevel(entree_son) * 50; // //MOVIE image(myMovie,0,0,width,375); //declaration variables pour lecture du movie float md = myMovie.duration(); float mt = myMovie.time(); //BANDEAU souffleur image(img,0,0); // afficher regle graduee strokeWeight(1); stroke(255); line(100,20,100,30); line(300,20,300,30); line(500,20,500,30); // stroke(200); line(200,25,200,30); line(400,25,400,30); // stroke(150); line(150,22,150,30); line(250,22,250,30); line(350,22,350,30); line(450,22,450,30); // stroke(0); strokeWeight(2); line(0,50,510,50); //jauge niveau avant souffle vict lj=niveau/5*400; noStroke(); if(niveau > 1.2) { // vert fill(131,151,0); }else{ //rouge fill(150,0,0); } rect(100,14,lj,1); //je triche un peu je ferme la jauge avec un rectangle noir fill(0); rect(500,12,10,4); ///// //fonction //si NIVEAU AUDIBLE if(niveau > 0.5) { myMovie.speed(-1); //incrementation negative bateau if (bato_01==1) { if (monx>525){ i=0; monx=535; monx2=-200; annee2=annee-1; bato_01=0; bato_02=1; }else{ i=15; monx=monx+i; } } if (bato_02==1) { if (monx2>525){ i2=0; monx=-200; monx2=535; annee=annee2-1; bato_01=1; bato_02=0; }else{ i2=15; monx2=monx2+i2; } } //boucle du movie quand lecture inverse – retour a la fin pas automatique if(mt < 0.1) { myMovie.jump(md); } } else { //si NIVEAU PAS AUDIBLE myMovie.speed(1); if (bato_01==1) { if (monx<-218){ i=0; monx=-219; monx2=510; mony2=s; annee2=annee+1; bato_01=0; bato_02=1; }else{ i=8; monx=monx-i; } } if (bato_02==1) { if (monx2<-218){ i2=0; monx=510; mony=s; monx2=-219; annee=annee2+1; bato_01=1; bato_02=0; }else{ i2=8; monx2=monx2-i2; } } } //je place les deux bateaux //repere initial bateau 1 fill(255); smooth(); //petit triangle gauche triangle(monx-15,mony, monx+36,mony, monx+18,mony+30); //gd gauche triangle(monx+20,mony+30, monx+100,mony-110, monx+100,mony+30); //gd droite triangle(monx+102,mony-110, monx+102,mony+30, monx+182,mony+30); //petit dte triangle(monx+166,mony, monx+217,mony, monx+184,mony+30); // // charger typo PFont maTypo = loadFont("Univers-CondensedBold-48.vlw"); // Definition de la taille de la typo textFont(maTypo, 12); //couleur typo fill(0); // ecriture d'un texte text(annee,monx+1,mony+13); // //repere initial bateau 2 fill(255); smooth(); //petit triangle gauche triangle(monx2-15,mony2, monx2+36,mony2, monx2+18,mony2+30); //gd gauche triangle(monx2+20,mony2+30, monx2+100,mony2-110, monx2+100,mony2+30); //gd roite triangle(monx2+102,mony2-110, monx2+102,mony2+30, monx2+182,mony2+30); //petit dte triangle(monx2+166,mony2, monx2+217,mony2, monx2+184,mony2+30); // // Definition de la taille de la typo textFont(maTypo, 12); //coul noir fill(0); // ecriture d'un texte text(annee2,monx2+1,mony2+13); } /////////////////////////////////////////////////////// /* Fermer entree audio à la fin */ public void stop() { Ess.stop(); super.stop(); }