ERG::physicalcomputing

De {}
Aller à la navigation Aller à la recherche

projet : Assigner un programme différent à chaque octave de la voix. Donc avec un système de détection des notes et des hauteurs. Chacune des notes seraient assignée à un effet de type stéréo, réverbe, granulator...

Capture d’écran 2018-10-01 à 12.01.14.png

Capture d’écran 2018-10-08 à 09.35.54.png

Utilisation de processing.

- Réaliser du code qui récupère les données enregistrées par un Micro externe, analyser ces données.

Exo 1 : traduire par une couleur des paliers sur la hauteur du son enregistré.



Code utilisé :

-FFT à partir d'un enregistrement micro input -Retour Micro -Changement de couleur du fond en fonction d'une hauteur

ATTENTION UTILISER CASQUE AUDIO SINON LARSEN

import processing.sound.*;

// Declare the sound source and FFT analyzer variables
FFT fft;
AudioIn in;

// Define how many FFT bands to use (this needs to be a power of two)
int bands = 128;

// Define a smoothing factor which determines how much the spectrums of consecutive
// points in time should be combined to create a smoother visualisation of the spectrum.
// A smoothing factor of 1.0 means no smoothing (only the data from the newest analysis
// is rendered), decrease the factor down towards 0.0 to have the visualisation update
// more slowly, which is easier on the eye.
float smoothingFactor = 0.2;

// Create a vector to store the smoothed spectrum data in
float[] sum = new float[bands];

// Variables for drawing the spectrum:
// Declare a scaling factor for adjusting the height of the rectangles
int scale = 5;
// Declare a drawing variable for calculating the width of the 
float barWidth;

public void setup() {
  size(640, 360);
  background(255);

  // Calculate the width of the rects depending on how many bands we have
  barWidth = width/float(bands);

  // Load and play a soundfile and loop it.
  fft = new FFT(this, bands);
  in = new AudioIn(this, 0);
  
  // Create the FFT analyzer and connect the playing soundfile to it.
  in.start();
  fft.input(in);
  //retour micro
  in.play();
}

public void draw() {
 

  // Perform the analysis
  fft.analyze();
  int currentBand = 0;
  float maxVal = 0;
  
  for (int i = 0; i < bands; i++) {
    
    if(fft.spectrum[i] > maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    }
   
    
  }
  
  if(currentBand > 10){
    background(0);
  }else{
    background(255);
  }
  
  
}



Effets vocaux :

Dispo dans les exemple de la librairie Sound : https://processing.org/reference/libraries/sound/index.html

Il reste à les coder pour les appliqués à des paliers de hauteur.


Exemple code avec ajout d'un effet à une hauteur donnée :

/**
 * This sketch shows how to use the FFT class to analyze a stream
 * of sound. Change the number of bands to get more spectral bands
 * (at the expense of more coarse-grained time resolution of the spectrum).
 */

import processing.sound.*;

// Declare the sound source and FFT analyzer variables
FFT fft;
AudioIn in;
Delay delay;

// Define how many FFT bands to use (this needs to be a power of two)
int bands = 128;

// Define a smoothing factor which determines how much the spectrums of consecutive
// points in time should be combined to create a smoother visualisation of the spectrum.
// A smoothing factor of 1.0 means no smoothing (only the data from the newest analysis
// is rendered), decrease the factor down towards 0.0 to have the visualisation update
// more slowly, which is easier on the eye.
float smoothingFactor = 0.2;

// Create a vector to store the smoothed spectrum data in
float[] sum = new float[bands];

// Variables for drawing the spectrum:
// Declare a scaling factor for adjusting the height of the rectangles
int scale = 5;
// Declare a drawing variable for calculating the width of the 
float barWidth;

public void setup() {
  size(640, 360);
  background(255);

  // Calculate the width of the rects depending on how many bands we have
  barWidth = width/float(bands);

  // Load and play a soundfile and loop it.
  fft = new FFT(this, bands);
  in = new AudioIn(this, 0);
  
  // Create the FFT analyzer and connect the playing soundfile to it.
  in.start();
  fft.input(in);
  //retour micro
  in.play();
}

public void draw() {
 

  // Perform the analysis
  fft.analyze();
  int currentBand = 0;
  float maxVal = 0;
  
  for (int i = 0; i < bands; i++) {
    
    if(fft.spectrum[i] > maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    }
   
    
  }
  
  if(currentBand > 10){
    background(0);
  }else{
    delay = new Delay(this);
    delay.process(in, 5);
    delay.time(0.5);
  
    background(255);
  }
  
  
}



Code, Retard appliqué à une hauteur + reverb pas encore active

import processing.sound.*;

FFT fft; AudioIn in; Delay delay; Reverb reverb;

int bands = 128;

float smoothingFactor = 0.2;

float[] sum = new float[bands];

int scale = 5; float barWidth; String currentEffect;

public void setup() {

 size(640, 360);
 background(255);
 currentEffect = "rien";
 barWidth = width/float(bands);
 fft = new FFT(this, bands);
 in = new AudioIn(this, 0);
 
 in.start();
 in.amp(1);
 fft.input(in);
 //retour micro
 in.play();
 delay = new Delay(this);
 delay.process(in, 5);

}

public void draw() {

 fft.analyze();
 int currentBand = 0;
 float maxVal = 0;
 
 for (int i = 0; i < bands; i++) {
   
   if(fft.spectrum[i] > maxVal){
     currentBand = i;
     maxVal = fft.spectrum[i];
   }
  
   
 }
 print(currentBand+" ");
 
 if(currentBand < 5){
   if(currentEffect != "fondnoir"){
     background(0);
     delay.time(0);
     delay.feedback(0);
     currentEffect = "fondnoir";
   }
 }else if(currentBand < 10){
   if(currentEffect != "delai"){
     
     
     delay.time(0.5);
     delay.feedback(0.1);
     background(255);
     currentEffect = "delai";
   }
 }
 /*
 if(currentBand < 10){ 
 }else if(currentBand > 5){   
    reverb = new Reverb(this);
     reverb.process(in);
 }   */

}

</syntaxhighlight>

Tentative de mise en pause de la transformation de Fourier, car sinon le programme applique un effet sur chaque bandes qui son trop proches, les effets ne s'entendent donc pas, ou il se passes un bug.

A faire, coder les effets qui s'appliquent sur une ou plusieurs bandes distinctes, avec une pause entre chaque effet.



Le but de ce projet est de réaliser une sorte d'instrument de musique. Un micro pour enregistrement live, qui détecte la hauteur de la voix, de la musique, ou du bruit et qui lui applique des effets en fonction de celle-ci.

Le projet serait donc, d'organiser un live par exemple, ou l'instrument serait utilisé notamment pour déformer un opéra, ou d'un thérémine.

La problématique étant alors, de faire attention dans le code sur quelles hauteurs vont être utilisées. Ainsi que définir si ce qui est mis en place est en vu d'une installation, ou d'un enregistrement à but radiophonique.

Référence :

Kerlax de Remy Dury

https://www.youtube.com/watch?v=UMTjXffup6Q


Effets codés, qui s'actionnent en fonction des bandes obtenues par la transformé de Fourier :

import processing.sound.*;

FFT fft;
AudioIn in;
Delay delay;
Reverb reverb;
Pulse pulse;

int bands = 128;

float smoothingFactor = 0.2;

float[] sum = new float[bands];

int scale = 5;
float barWidth;
String currentEffect;

public void setup() {
  size(640, 360);
  // fenêtre de visualisation (largeur,hauteur)
  background(255);
  // couleur du fond
  currentEffect = "rien";
  barWidth = width/float(bands);

  fft = new FFT(this, bands);
  in = new AudioIn(this, 0);
  
  in.start();
  in.amp(1);
  fft.input(in);
  //retour micro
  in.play( );
}

public void draw() {
  fft.analyze();
  int currentBand = 0;
  float maxVal = 0;
  
  for (int i = 0; i < bands; i++) {
    // somme = somme + nombres [i]
    if(fft.spectrum[i] > maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    }  
  }
 
  
  print(currentBand+" ");
  
  if(currentBand < 5){
    if(currentEffect != "fondnoir"){
      background(0);
      currentEffect = "fondnoir";
    }
  }else if(currentBand < 10){
    if(currentEffect != "delai"){
      
      delay = new Delay(this);
      delay.process(in, 5);
      delay.time(0.5);
      background(255);
      currentEffect = "delai";
    }
  }
  
  else if(currentBand < 20){   
    if(currentEffect != "reverb"){
     reverb = new Reverb(this);
      reverb.process(in);
      reverb.wet(0.5);
      background(255, 204, 51);
      currentEffect = "reverb";
    }
  }   

  else if(currentBand < 30){
    if(currentEffect != "pulse"){
      pulse = new Pulse (this);
       pulse.play();
       background(0, 0, 255);
       currentEffect = "pulse";
    }
   }
}

Les effets se superposent, car le nombre de bandes est élevé et le son en changement constant. L'arlgorythme ne laisse donc pas le temps d'enttendre les effets appliqués.

Nous allons donc mettre en place un système de timer. Ainsi pour chaque effet sera assigné une "durée" en frame, et dés lorsqu'un effet est lancé les autres devront être bloqués.

Principe :

if timer = 0 else if -> bande audio ftt comprise entre tel et tel valeur -> on applique le timer, par exemple sur 10 frames, et on bloque les autres effets.

Rq : il va aussi falloir réflichir à peut être attendre le nombre de bandes de la FFT pour être plus précis dans la captation des voix.