Actions

Page web

« ERG::physicalcomputing » : différence entre les versions

De erg

Ergbot (discussion | contributions)
Aucun résumé des modifications
Ergbot (discussion | contributions)
Aucun résumé des modifications
 
(12 versions intermédiaires par le même utilisateur non affichées)
Ligne 2 : Ligne 2 :
|URL=http://curlybraces.be/wiki/index.php/ERG::physicalcomputing
|URL=http://curlybraces.be/wiki/index.php/ERG::physicalcomputing
|Title=ERG::physicalcomputing
|Title=ERG::physicalcomputing
|Updated=2018-10-08 08:33:39
|Updated=2019-05-12 16:22:33
|Site=Curlybraces
|Site=Curlybraces
|Thumbnail=Capture d’écran 2018-10-01 à 12.01.14.png
|Thumbnail=Capture d’écran 2018-10-01 à 12.01.14.png
Ligne 27 : Ligne 27 :
-----
-----


<pre>EXEMPLE DE CODE À COMPRENDRE ET REUTILISER : </pre>
Code utilisé :
//importation des différents éléments de la bibliothèque minim // importation de la base de la bibliothèque import ddf.minim.*; // importation du module de traitement de signal de la bibliothèque import ddf.minim.signals.*; // importation du module d'analyse de signal de la bibliothèque import ddf.minim.analysis.*; // importation du module d'effets sonores de la bibliothèque import ddf.minim.effects.*;


// je créé le nom de mon objet son Minim monObjetSon; // je créée le nom d'un objet entrée son AudioInput entreeSon; // je crée une variable qui me permettra de sortir la valeur du volume hors de la boucle d'itération (voir plus bas) float monVolumeSon;
-FFT à partir d'un enregistrement micro input -Retour Micro -Changement de couleur du fond en fonction d'une hauteur


void setup() {
== ATTENTION UTILISER CASQUE AUDIO SINON LARSEN ==


<pre> size (200, 200);
<pre class="de1">import processing.sound.*;
//je crée mon objet son
 
monObjetSon = new Minim(this);
// Declare the sound source and FFT analyzer variables
// je précise les caractéristiques de mon objet entreeSon : stereo, avec une memoire tampon (buffer) de 512 ko
FFT fft;
entreeSon = monObjetSon.getLineIn(Minim.STEREO, 512);</pre>
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 &lt; bands; i++) {
 
    if(fft.spectrum[i] &gt; maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    }
 
 
  }
 
  if(currentBand &gt; 10){
    background(0);
  }else{
    background(255);
  }
 
 
}</pre>
<br />
-----
== 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.''
<br /> '''Exemple code avec ajout d'un effet à une hauteur donnée :'''
<pre class="de1">/**
* 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 &lt; bands; i++) {
 
    if(fft.spectrum[i] &gt; maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    }
 
 
  }
 
  if(currentBand &gt; 10){
    background(0);
  }else{
    delay = new Delay(this);
    delay.process(in, 5);
    delay.time(0.5);
 
    background(255);
  }
 
 
}</pre>
<br />
-----
== 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() {


void draw() {
<pre> size(640, 360);
background(255);
currentEffect = &quot;rien&quot;;
barWidth = width/float(bands);</pre>
<pre> 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);</pre>
}


<pre> background(255);
public void draw() {
  // Nous avons besopin d'une iteration pour récpérer tous les échantillons sonores présents dans la mémoire tampon
 
  for (int i = 0; i &lt; entreeSon.bufferSize() - 1; i++)
<pre> fft.analyze();
{
  int currentBand = 0;
   // Je donne à ma variable monVolumeSon la somme des valeurs d'entrées gauche et droite du microphone que je multiplie par 50 pour la valeur soit exploitable
float maxVal = 0;
   monVolumeSon =  (entreeSon.left.get(i)+entreeSon.right.get(i)/2)*50;
  for (int i = 0; i &lt; bands; i++) {
    
   if(fft.spectrum[i] &gt; maxVal){
    currentBand = i;
    maxVal = fft.spectrum[i];
  }
 
 
  }
  }
  // je donne à mon épaisseur de ligne la valeur de la variable monVolumeSon définie juste au-dessus. Avec la fonction 'abs()' je transforme les valeurs de ma varibla à être positives
  print(currentBand+&quot; &quot;);
  strokeWeight(abs(monVolumeSon));
  // je donne à ma ligne la couleur rouge
  if(currentBand &lt; 5){
stroke(255, 0, 0);
  if(currentEffect != &quot;fondnoir&quot;){
  // je dessine ma ligne
    background(0);
  line(width/4, height/2, width*3/4, height/2);
    delay.time(0);
  // maintenant, quand je fais du bruit l'épaisseur de ma ligne rouge varie en fonction du volume ambiant</pre>
    delay.feedback(0);
    currentEffect = &quot;fondnoir&quot;;
  }
  }else if(currentBand &lt; 10){
  if(currentEffect != &quot;delai&quot;){
   
   
    delay.time(0.5);
    delay.feedback(0.1);
    background(255);
    currentEffect = &quot;delai&quot;;
  }
}
  /*
if(currentBand &lt; 10){
  }else if(currentBand &gt; 5){ 
    reverb = new Reverb(this);
    reverb.process(in);
  }  */</pre>
}
}


void stop() {
&lt;/syntaxhighlight&gt;
 
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.
 
<br />
 
 
-----
 
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.


<pre> // Je ferme l'entree son et arrete l'objet son quand je quitte mon sketch afin de ne pas continuer à stocker les valeurs dans la memoire tampon quand j'ai fini
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.
entreeSon.close();
 
monObjetSon.stop();</pre>
Référence :
<pre> super.stop();</pre>
 
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 :
 
<pre class="de1">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 = &quot;rien&quot;;
  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 &lt; bands; i++) {
    // somme = somme + nombres [i]
    if(fft.spectrum[i] &gt; maxVal){
      currentBand = i;
      maxVal = fft.spectrum[i];
    } 
  }
 
 
  print(currentBand+&quot; &quot;);
 
  if(currentBand &lt; 5){
    if(currentEffect != &quot;fondnoir&quot;){
      background(0);
      currentEffect = &quot;fondnoir&quot;;
    }
  }else if(currentBand &lt; 10){
    if(currentEffect != &quot;delai&quot;){
 
      delay = new Delay(this);
      delay.process(in, 5);
      delay.time(0.5);
      background(255);
      currentEffect = &quot;delai&quot;;
    }
  }
 
  else if(currentBand &lt; 20){ 
    if(currentEffect != &quot;reverb&quot;){
    reverb = new Reverb(this);
      reverb.process(in);
      reverb.wet(0.5);
      background(255, 204, 51);
      currentEffect = &quot;reverb&quot;;
    }
  } 
 
  else if(currentBand &lt; 30){
    if(currentEffect != &quot;pulse&quot;){
      pulse = new Pulse (this);
      pulse.play();
      background(0, 0, 255);
      currentEffect = &quot;pulse&quot;;
    }
  }
}</pre>
-----
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 &quot;durée&quot; en frame, et dés lorsqu'un effet est lancé les autres devront être bloqués.
Principe :
if timer = 0 else if -&gt; bande audio ftt comprise entre tel et tel valeur -&gt; 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.
<br />
<br />
-----
-----
-----
-----
CHANGEMENT DE PROJET :
-----
-----
-----
-----
[[Fichier:4bis.png|4bis.png|link=http://curlybraces.be/wiki/Fichier:1.png|[[Image:http://curlybraces.be/wiki/images/4/4a/1.png|1.png|thumb|none]]] [http://curlybraces.be/wiki/Fichier:2bis.png [[Fichier:2bis.png|2bis.png|thumb|none]]] [http://curlybraces.be/wiki/Fichier:3bis.png [[Fichier:3bis.png|3bis.png|thumb|none]]] [http://curlybraces.be/wiki/Fichier:4bis.png]]
-----
-----
PROBLÈME RÉSOLU :
-----
-----
[[Fichier:6bis.png|6bis.png|link=http://curlybraces.be/wiki/Fichier:5bis.png|[[Image:http://curlybraces.be/wiki/images/9/9b/5bis.png|5bis.png|thumb|none]]] [http://curlybraces.be/wiki/Fichier:6bis.png]]


Récupérée de « http://curlybraces.be/wiki/index.php?title=ERG::physicalcomputing&oldid=2569 »
Récupérée de « http://curlybraces.be/wiki/index.php?title=ERG::physicalcomputing&oldid=3245 »

Dernière version du 13 mai 2019 à 02:11

Source (url) http://curlybraces.be/wiki/index.php/ERG::physicalcomputing
Site satellite Curlybraces
Date 2019-05-12 16:22:33

De {}

Aller à : navigation, rechercher

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.











CHANGEMENT DE PROJET :









Fichier:'"`UNIQ-NOPARSEHttp://curlybraces.be/wiki/images/4/4a/1.png 1.png ] none none [http://curlybraces.be/wiki/Fichier:4bis.png





PROBLÈME RÉSOLU :





Fichier:'"`UNIQ-NOPARSEHttp://curlybraces.be/wiki/images/9/9b/5bis.png 5bis.png ] [http://curlybraces.be/wiki/Fichier:6bis.png

Récupérée de « http://curlybraces.be/wiki/index.php?title=ERG::physicalcomputing&oldid=3245 »