» codelab : http://codelab.fr/accueil » Forum : Processing : http://codelab.fr/processing » Problème de codage - visualisation sonore Minim : http://codelab.fr/4660 Ceci est la version imprimable d'un sujet du forum, pour retourner à la version complète : Problème de codage - visualisation sonore Minim |
Marg — 2013-12-12 14:47:15 |
Bonjour, |
fabrice54 — 2013-12-17 03:17:13 |
bonjour import ddf.minim.*; float x; float y; Minim minim; AudioInput input; void setup () { // Sketch einstellen size (1000, 450); smooth(); stroke (255, 25); noFill (); // Startposition festlegen x = 150; y = 150; // Audiotoolkit anlegen minim = new Minim (this); input = minim.getLineIn (Minim.STEREO, 512); background (0); } void draw () { // Kreisgröße Abhängig von Lautstärke float dim = input.mix.level () * width; // Kreis x-Position verschieben y+= input.mix.level () * 20; // Kreis zeichnen ellipse (x, y, dim, dim); if (x > width) { x = 50; y += 150; } } |
Marg — 2013-12-17 09:58:46 |
Bonjour, |
fabrice54 — 2013-12-17 10:25:42 |
bonjour |
fabrice54 — 2013-12-17 11:30:07 |
un exemple pour la frequence Code (P5) :/* frequencyModulation <p> A simple example for doing FM (frequency modulation) using two Oscils. Use the mouse to control the speed and range of the frequency modulation. <p> Author: Damien Di Fede */ // import everything necessary to make sound. import ddf.minim.*; import ddf.minim.ugens.*; // create all of the variables that will need to be accessed in // more than one methods (setup(), draw(), stop()). Minim minim; AudioOutput out; // the Oscil we use for modulating frequency. Oscil fm; // setup is run once at the beginning void setup() { // initialize the drawing window size( 512, 200, P3D ); // initialize the minim and out objects minim = new Minim( this ); out = minim.getLineOut(); // make the Oscil we will hear. // arguments are frequency, amplitude, and waveform Oscil wave = new Oscil( 200, 0.8, Waves.TRIANGLE ); // make the Oscil we will use to modulate the frequency of wave. // the frequency of this Oscil will determine how quickly the // frequency of wave changes and the amplitude determines how much. // since we are using the output of fm directly to set the frequency // of wave, you can think of the amplitude as being expressed in Hz. fm = new Oscil( 10, 2, Waves.SINE ); // set the offset of fm so that it generates values centered around 200 Hz fm.offset.setLastValue( 200 ); // patch it to the frequency of wave so it controls it fm.patch( wave.frequency ); // and patch wave to the output wave.patch( out ); } // draw is run many times void draw() { // erase the window to black background( 0 ); // draw using a white stroke stroke( 255 ); // draw the waveforms for( int i = 0; i < out.bufferSize() - 1; i++ ) { // find the x position of each buffer value float x1 = map( i, 0, out.bufferSize(), 0, width ); float x2 = map( i+1, 0, out.bufferSize(), 0, width ); // draw a line from one buffer position to the next for both channels line( x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50); } } // we can change the parameters of the frequency modulation Oscil // in real-time using the mouse. void mouseMoved() { float modulateAmount = map( mouseY, 0, height, 220, 1 ); float modulateFrequency = map( mouseX, 0, width, 0.1, 100 ); fm.frequency.setLastValue( modulateFrequency ); fm.amplitude.setLastValue( modulateAmount ); } |