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
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 10:48:22
|Updated=2018-10-15 08:06:02
|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é : Modifications réalisées sur le code : -FFT à partir d'un enregistrement micro input -Retour Micro
//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;
== ATTENTION UTILISER CASQUE AUDIO SINON LARSEN ==


void setup() {
<pre class="de1">/**
 
* This sketch shows how to use the FFT class to analyze a stream
<pre> size (200, 200);
  * of sound. Change the number of bands to get more spectral bands
  //je crée mon objet son
  * (at the expense of more coarse-grained time resolution of the spectrum).
  monObjetSon = new Minim(this);
  */
  // je précise les caractéristiques de mon objet entreeSon : stereo, avec une memoire tampon (buffer) de 512 ko
 
entreeSon = monObjetSon.getLineIn(Minim.STEREO, 512);</pre>
import processing.sound.*;
}
 
 
// Declare the sound source and FFT analyzer variables
void draw() {
FFT fft;
 
AudioIn in;
<pre> background(255);
 
// Nous avons besopin d'une iteration pour récpérer tous les échantillons sonores présents dans la mémoire tampon
// Define how many FFT bands to use (this needs to be a power of two)
for (int i = 0; i &lt; entreeSon.bufferSize() - 1; i++)
int bands = 128;
{
 
  // 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
// Define a smoothing factor which determines how much the spectrums of consecutive
  monVolumeSon =   (entreeSon.left.get(i)+entreeSon.right.get(i)/2)*50;
// 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
// 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
// is rendered), decrease the factor down towards 0.0 to have the visualisation update
strokeWeight(abs(monVolumeSon));
// more slowly, which is easier on the eye.
// je donne à ma ligne la couleur rouge
float smoothingFactor = 0.2;
stroke(255, 0, 0);
 
// je dessine ma ligne
// Create a vector to store the smoothed spectrum data in
line(width/4, height/2, width*3/4, height/2);
float[] sum = new float[bands];
// maintenant, quand je fais du bruit l'épaisseur de ma ligne rouge varie en fonction du volume ambiant</pre>
 
}
// Variables for drawing the spectrum:
 
// Declare a scaling factor for adjusting the height of the rectangles
void stop() {
int scale = 5;
 
// Declare a drawing variable for calculating the width of the
<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
float barWidth;
entreeSon.close();
 
monObjetSon.stop();</pre>
public void setup() {
<pre> super.stop();</pre>
  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();
}
}
 
 
Récupérée de « http://curlybraces.be/wiki/index.php?title=ERG::physicalcomputing&oldid=2569 »
public void draw() {
  // Set background color, noStroke and fill color
  background(125, 255, 125);
  fill(255, 0, 150);
  noStroke();
 
  // Perform the analysis
  fft.analyze();
 
  for (int i = 0; i &lt; bands; i++) {
    // Smooth the FFT spectrum data by smoothing factor
    sum[i] += (fft.spectrum[i] - sum[i]) * smoothingFactor;
 
    // Draw the rectangles, adjust their height using the scale factor
    rect(i*barWidth, height, barWidth, -sum[i]*height*scale);
  }
}</pre>
Récupérée de « http://curlybraces.be/wiki/index.php?title=ERG::physicalcomputing&oldid=2597 »

Version du 16 octobre 2018 à 02:10

Source (url) http://curlybraces.be/wiki/index.php/ERG::physicalcomputing
Site satellite Curlybraces
Date 2018-10-15 08:06:02

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é : Modifications réalisées sur le code : -FFT à partir d'un enregistrement micro input -Retour Micro

ATTENTION UTILISER CASQUE AUDIO SINON LARSEN

/**
 * 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;
 
// 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() {
  // Set background color, noStroke and fill color
  background(125, 255, 125);
  fill(255, 0, 150);
  noStroke();
 
  // Perform the analysis
  fft.analyze();
 
  for (int i = 0; i < bands; i++) {
    // Smooth the FFT spectrum data by smoothing factor
    sum[i] += (fft.spectrum[i] - sum[i]) * smoothingFactor;
 
    // Draw the rectangles, adjust their height using the scale factor
    rect(i*barWidth, height, barWidth, -sum[i]*height*scale);
  }
}

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