Francky Goes To Pointe à Pitre

Ce wiki a été archivé en 2018.

Le nouveau wiki se trouve à: ressources.labomedia.org

Les fonctionnalités sont désactivées: vous pouvez faire une recherche sur Google site:https://wiki.labomedia.org et découvrir La Labomedia.

De Centre de Ressources Numériques - Labomedia
Aller à : navigation, rechercher

Projets

Projeter des visuels durant le concert du groupe Francky goes to Pointe à Pitre

Principe

Charger une image, l'afficher sans effets puis la réafficher en appliquant des effets visuels et mouvements psychés

Exemple de rendu

Visuel test.png

Etat du projet

Affiche l'image du groupe jusqu'à que le touche 'g' soit enfoncée. Deux modes : manuel (par défaut) et auto :

  • Manuel : les effets ne changent pas en fonction du niveau d'entrée sonore
  • Auto : les effets changent en fonction du niveau d'entrée sonore

Touches

  • 'g' lance le programme (débloque de l'image d'accueil)
  • 'e' change l'effet
  • 'i' change l'image
  • 'up' increment la valeur du seuil de détection sonore
  • 'down' decrement la valeur du seuil de détection sonore
  • autres touches : change l'effet et l'image


A ajouter

  • Diversifier les effets
  • Diversifier les mouvements
  • Faire changer l'image et l'effet non simultanément en fonction de la musique (exemple : cymbale fait changer les images et grosses caisses les effets)

Compte rendu de la prestation #1 23/04/2015

Utilisation du mode manuel uniquement, beaucoup plus simple et efficace. A améliorer :

  • latence : précharger les images dans un tableau
  • saccade : ne pas reprendre à l'origine le mouvement circulaire


Code

/** Written by Zedkuesde
 * Labomedia - April 2015
 */
import ddf.minim.*; //library for audio


//audio variable
Minim minim;
AudioInput in;

//constant
final int maxEffects = 8; //maximum number of effect
final int longueur = 1280; //width of the window
final int hauteur = 1024 ; //heigth of the window
int maxImage = 18; //max number of image to display
int treshSon = 30; //threshold for the sound detection

PImage img; //will contain the image 
int imgID = 0; //id of the current image
int cx = 0; //absciss origin
int cy = 0; //ordinate origin
int r = 15; //radius
int effects = 0; //initiate effects to 0
float speed = 400.f; // initiate speed to a standard 400
boolean bool = true; //boolean used to decide clockwise or anticlockwise
boolean go = false; //boolean used to display the picture "Francky goes to pointre a pitre" for the beginning
boolean manuel = true;

int n_x ; //absciss for the modified image
int n_y; // ordinate for the modified image



/**
 * This function display an image with a color filter and make it move following a circle
 * @param rayon : radius of the circle
 * @param r : red value
 * @param g : green value
 * @param b : blue value
 * @param trans : transparency value
 * @param vitesse : speed of the movement
 **/
void movingTint( int rayon, int r, int g, int b, int trans, float vitesse) {
  float t = millis()/vitesse; //compute the t used to compute the coordonate of x and y 

  tint(r, g, b, trans);//apply the filter
  n_x = (int)(cx+rayon*cos(t)); //compute the new x position
  n_y = (int)(cy+rayon*sin(t)); //compute the new y position
  image(img, n_x, n_y, longueur, hauteur); //display the modified picture
}

/**
 * This function apply a filter and moved the image following a circle
 * @param rayon : radius of the circle
 * @param trans : transparency of the new image
 * @param vitesse : speed of the movement
 * @param sens : TRUE clockwise / FALSE anticlockwise
 * @param whichEffect : keyword to apply the right filter
 **/
void movingFilter(int rayon, int trans, float vitesse, boolean sens, int whichEffect) {
  float t = millis()/vitesse;

  tint(255, trans); //apply the transparent tint
  if (whichEffect == POSTERIZE) //POSTERIZE needs an additionnal value
    filter(whichEffect, 4); //apply the filter
  else
    filter(whichEffect); //apply the filter
    
  //invert t if we want the movement to be anticlockwise
  if (sens == false) {
    n_x = (int)(cx+rayon*cos(-t));
    n_y = (int)(cy+rayon*sin(-t));
  } else {
    n_x = (int)(cx+rayon*cos(t));
    n_y = (int)(cy+rayon*sin(t));
  }

  image(img, n_x, n_y, longueur, hauteur); //display the image
}

/*
* Used to display fullscreen
*/
boolean sketchFullScreen() {
  return false;
}

//setup function
void setup() {
  size(longueur,hauteur); // create a window of longueur x hauteur
  noCursor();
  //know the number of jpg file in the folder media/
  //open the folder
  java.io.File folder = new java.io.File(sketchPath+"/media/");

  // create a .jpg filter
  java.io.FilenameFilter jpgFilter = new java.io.FilenameFilter() {
    public boolean accept(File dir, String name) {
    return name.toLowerCase().endsWith(".jpg");
    }
  };

  //list the file with the filter
  String[] filenames = folder.list(jpgFilter);
  maxImage = filenames.length;

  minim = new Minim(this); //initate audio minim object
  in = minim.getLineIn(Minim.STEREO, 512); //get audio input
  img = loadImage("debut.jpg"); //load the first image
}

void draw() {
  background(255, 255, 255); //white background
  noTint();//be sure that no color will be add to the original image
  image(img, 0, 0, longueur, hauteur);
  //we want to display a picture until the concert begin
  //so we have a boolean go which is initiate to false, when it take the value true, we apply effects
  if(go)
  switch(effects) {
  case 0 : 
    movingTint(r, 255, 102, 0, 130, 400.f);
    break;
  case 1 : 
    movingFilter(r, 130, speed, bool, POSTERIZE);
    break;
  case 2 : 
    movingFilter(r, 40, speed, bool, INVERT);
    break;
  case 3 :
    movingFilter(r, 130, speed, bool, DILATE);
    break;
  case 4 :
    movingFilter(r, 130, speed, bool, BLUR);
    break;
  case 5 : 
    movingFilter(r, 130, speed, bool, ERODE);
    break;
  case 6 :
    movingFilter(r, 130, speed, bool, THRESHOLD);
    break;
  case 7 :
    movingTint(r, 255, 0, 255, 130, 400.f);
    break;

  default :  
    movingTint(r, 255, 102, 0, 130, 400.f);
  } 

  //get the level of the left channel, test it and call the change function
  float boxSize;
  boxSize=  in.left.level() * 1000;
  
  //if the level is upon the threshold, change the image and the picture
  if (boxSize > treshSon && !manuel) {
    changeEffectAndImage();
  }
}
/**
 * This function change the effect randomly
 **/
void changeEffect(){
  //avoid two times the same effect
  int buf = effects;
  do {
    effects = int(random(maxEffects));
  }
  while (effects == buf);

  //compute the origin coordonate in function of the image size for the effects /w a little random
  cx=0;
  cy=0;
  r = (int)random(8) +5; //random the radius between 5 and 13
  bool = ((int)random(1) == 1) ? true : false; //random the rotation direction
  speed = random(400) + 400.f; //random the speed between 400 and 800
}
/**
 * This function change the image randomly
 **/
void changeImage(){
  //avoid two times the same image
  int bufId = imgID;
  do {
    imgID = (int)random(maxImage);
  }
  while (imgID == bufId);
  img = loadImage("media/"+imgID+".jpg");
  
}
/**
 * This function change the image and the effect randomly
 **/
void changeEffectAndImage() {
  changeImage();
  changeEffect();
}

//this function is called when a key is pressed
void keyPressed() {
  
  switch(key){
    //if the key is UP or DOWN, increment or decrement the sound threshold for detection, don't change effect
    case CODED : 
      if (keyCode == UP) {
      treshSon++;
    } else if (keyCode == DOWN) {
      treshSon--;
    } 
   break;
    //never apply if g is not pushed, when it's pushed, change image and effect
   case 'g' : go = true;
    changeEffectAndImage();
   break;
   //if key is escape, close the app
   case ESC : 
      exit();
    break;
    //change only the effect
   case 'e' :  if(go) changeEffect();
   break;
   //change only the image
   case 'i' :  if(go) changeImage();
   break;
   //switch to manuel or auto mode (on sound change)
   case 'm' : manuel = !manuel;
   default:
   if(go)
    changeEffectAndImage();
  }
}

//When the app is closed, close the Minim audio classes
void stop()
{
  // always close Minim audio classes when you are done with them
  in.close();
  minim.stop();
  super.stop();
}

Fichier

Télécharger le projet Processing : Fichier:Franky v0.1.zip