<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with buffersize() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=buffersize%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:53:20 +0000</pubDate>
         <description>Tagged with buffersize() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedbuffersize%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Get Audio Input with minim?</title>
      <link>https://forum.processing.org/two/discussion/25450/get-audio-input-with-minim</link>
      <pubDate>Fri, 08 Dec 2017 05:47:27 +0000</pubDate>
      <dc:creator>jeremy_wilde</dc:creator>
      <guid isPermaLink="false">25450@/two/discussions</guid>
      <description><![CDATA[<p>Hi This is code that I got from the internet and I modified it a bit.</p>

<p>The original code was using mp3 files to draw.<br />
However I want to get the sound and fft from Audio Input.</p>

<p>I'm trying to get the sound from audio but I think the original code using minim library so I can't get the sound right.</p>

<p>How can I get the sound from mic like I get the sound from mp3?</p>

<pre><code>import ddf.minim.*;
import ddf.minim.analysis.*;
import processing.sound.*;

FFT fft;
AudioIn song;

// Variables that define the "zones" of the spectrum
// For example, for bass, we take only the first 4% of the total spectrum
float specLow = 0.03; // 3%
float specMid = 0.125;  // 12.5%
float specHi = 0.20;   // 20%

// This leaves 64% of the possible spectrum that will not be used.
// These values are usually too high for the human ear anyway.

// Scoring values for each zone
float scoreLow = 0;
float scoreMid = 0;
float scoreHi = 0;

// Previous value, to soften the reduction
float oldScoreLow = scoreLow;
float oldScoreMid = scoreMid;
float oldScoreHi = scoreHi;

// Softening value
float scoreDecreaseRate = 25;

// Cubes appearing in space
int nbCubes;
Cube[] cubes;

//Lines that appear on the sides
int nbWalls = 500;
Wall[] murs;

void setup()
{
  //Display in 3D on the entire screen
  fullScreen(P3D);

  //Create the FFT object to analyze the song
  //fft = new FFT(song.bufferSize(), song.sampleRate());
  fft = new FFT(this, song.sampleRate());


  //Get Audio In
  song = new AudioIn(this, 0);
  song.start();
  fft.input(song);

  //One cube per frequency bandOne cube per frequency band
  nbCubes = (int)(fft.specSize()*specHi);
  cubes = new Cube[nbCubes];

  //As many walls as we want
  walls = new Wall[nbWalls];

  //Create all objects
  //Create cubic objects
  for (int i = 0; i &lt; nbCubes; i++) {
   cubes[i] = new Cube(); 
  }

  //Create wall objects
  //walls LEFT
  for (int i = 0; i &lt; nbWalls; i+=4) {
   walls[i] = new Wall(0, height/2, 10, height); 
  }

  //walls RIGHT
  for (int i = 1; i &lt; nbWalls; i+=4) {
   walls[i] = new Wall(width, height/2, 10, height); 
  }

  //walls DOWN
  for (int i = 2; i &lt; nbWalls; i+=4) {
   walls[i] = new Wall(width/2, height, width, 10); 
  }

  //walls UP
  for (int i = 3; i &lt; nbWalls; i+=4) {
   walls[i] = new Wall(width/2, 0, width, 10); 
  }

  //Black background
  background(0);

  //Start the song
  song.play(0);
}



void draw()
{  
  //Forward the song. One draw () for each "frame" of the song ...
  fft.forward(song.mix);

  //Calculation of "scores" (power) for three categories of sound
  //First, save old values
  oldScoreLow = scoreLow;
  oldScoreMid = scoreMid;
  oldScoreHi = scoreHi;

  //Reset values
  scoreLow = 0;
  scoreMid = 0;
  scoreHi = 0;

  //Calculate the new "scores"
  for(int i = 0; i &lt; fft.specSize()*specLow; i++)
  {
    scoreLow += fft.getBand(i);
  }

  for(int i = (int)(fft.specSize()*specLow); i &lt; fft.specSize()*specMid; i++)
  {
    scoreMid += fft.getBand(i);
  }

  for(int i = (int)(fft.specSize()*specMid); i &lt; fft.specSize()*specHi; i++)
  {
    scoreHi += fft.getBand(i);
  }

  //To slow down the descent.
  if (oldScoreLow &gt; scoreLow) {
    scoreLow = oldScoreLow - scoreDecreaseRate;
  }

  if (oldScoreMid &gt; scoreMid) {
    scoreMid = oldScoreMid - scoreDecreaseRate;
  }

  if (oldScoreHi &gt; scoreHi) {
    scoreHi = oldScoreHi - scoreDecreaseRate;
  }

  //Volume for all frequencies at this time, with the highest sounds higher.
  //This allows the animation to go faster for the higher pitched sounds, which is more noticeable
  float scoreGlobal = 0.66*scoreLow + 0.8*scoreMid + 1*scoreHi;

  //Subtle color of background
  background(scoreLow/100, scoreMid/100, scoreHi/100);

  //Cube for each frequency band
  for(int i = 0; i &lt; nbCubes; i++)
  {
    //Value of the frequency band
    float bandValue = fft.getBand(i);

    //The color is represented as: red for bass, green for medium sounds and blue for high.
    //The opacity is determined by the volume of the tape and the overall volume.
    cubes[i].display(scoreLow, scoreMid, scoreHi, bandValue, scoreGlobal);
  }

  //Walls lines, here we must keep the value of the previous tape and the next to connect them together
  float previousBandValue = fft.getBand(0);

  //Distance between each line point, negative because on the z dimension
  float dist = -25;

  //Multiply the height by this constant
  float heightMult = 2;

  //For each band
  for(int i = 1; i &lt; fft.specSize(); i++)
  {
    //Value of the frequency band, we multiply the bands farther to make them more visible.
    float bandValue = fft.getBand(i)*(1 + (i/50));

    //Selection of the color according to the forces of the different types of sounds
    stroke(100+scoreLow, 100+scoreMid, 100+scoreHi, 255-i);
    strokeWeight(1 + (scoreGlobal/100));

    //lower left line
    line(0, height-(previousBandValue*heightMult), dist*(i-1), 0, height-(bandValue*heightMult), dist*i);
    line((previousBandValue*heightMult), height, dist*(i-1), (bandValue*heightMult), height, dist*i);
    line(0, height-(previousBandValue*heightMult), dist*(i-1), (bandValue*heightMult), height, dist*i);

    //upper left line
    line(0, (previousBandValue*heightMult), dist*(i-1), 0, (bandValue*heightMult), dist*i);
    line((previousBandValue*heightMult), 0, dist*(i-1), (bandValue*heightMult), 0, dist*i);
    line(0, (previousBandValue*heightMult), dist*(i-1), (bandValue*heightMult), 0, dist*i);

    //ligne inferieure droite
    line(width, height-(previousBandValue*heightMult), dist*(i-1), width, height-(bandValue*heightMult), dist*i);
    line(width-(previousBandValue*heightMult), height, dist*(i-1), width-(bandValue*heightMult), height, dist*i);
    line(width, height-(previousBandValue*heightMult), dist*(i-1), width-(bandValue*heightMult), height, dist*i);

    //lower right line
    line(width, (previousBandValue*heightMult), dist*(i-1), width, (bandValue*heightMult), dist*i);
    line(width-(previousBandValue*heightMult), 0, dist*(i-1), width-(bandValue*heightMult), 0, dist*i);
    line(width, (previousBandValue*heightMult), dist*(i-1), width-(bandValue*heightMult), 0, dist*i);

    //Save the value for the next loop round
    previousBandValue = bandValue;
  }

  //Rectangular walls
  for(int i = 0; i &lt; nbWalls; i++)
  {
    //Each wall is assigned a band, and its strength is sent to it.
    float intensity = fft.getBand(i%((int)(fft.specSize()*specHi)));
    walls[i].display(scoreLow, scoreMid, scoreHi, intensity, scoreGlobal);
  }
}

//Class for cubes floating in space
class Cube {
  //Z position of spawn and maximum Z position
  float startingZ = -10000;
  float maxZ = 1000;

  //Position values
  float x, y, z;
  float rotX, rotY, rotZ;
  float sumRotX, sumRotY, sumRotZ;

  //--------------------------builder--------------------------
  //--------------------------builder--------------------------
  //--------------------------builder--------------------------

  Cube() {
    //Make the cube appear in a random place
    x = random(0, width);
    y = random(0, height);
    z = random(startingZ, maxZ);

    //Give the cube a random rotation
    rotX = random(0, 1);
    rotY = random(0, 1);
    rotZ = random(0, 1);
  }

  void display(float scoreLow, float scoreMid, float scoreHi, float intensity, float scoreGlobal) {
    //Selection of the color, opacity determined by the intensity (volume of the band)
    color displayColor = color(scoreLow*0.67, scoreMid*0.67, scoreHi*0.67, intensity*5);
    fill(displayColor, 255);

    //Color lines, they disappear with the individual intensity of the cube
    color strokeColor = color(255, 150-(20*intensity));
    stroke(strokeColor);
    strokeWeight(1 + (scoreGlobal/300));

    //Creating a transformation matrix to perform rotations, enlargements
    pushMatrix();

    //Shifting
    translate(x, y, z);

    //Calculation of the rotation according to the intensity for the cube
    sumRotX += intensity*(rotX/1000);
    sumRotY += intensity*(rotY/1000);
    sumRotZ += intensity*(rotZ/1000);

    //Application of the rotation
    rotateX(sumRotX);
    rotateY(sumRotY);
    rotateZ(sumRotZ);

    //Creation of the box, variable size according to the intensity for the cube
    box(100+(intensity/2));

    //Application of the matrix
    popMatrix();

    //Z displacement
    z+= (1+(intensity/5)+(pow((scoreGlobal/150), 2)));

    //Replace the box at the back when it is no longer visible
    if (z &gt;= maxZ) {
      x = random(0, width);
      y = random(0, height);
      z = startingZ;
    }
  }
}

//Class to display the lines on the sides
class Wall {
  //Minimum and maximum position Z
  float startingZ = -10000;
  float maxZ = 50;

  //Position values
  float x, y, z;
  float sizeX, sizeY;

  //--------------------------builder--------------------------
  //--------------------------builder--------------------------
  //--------------------------builder--------------------------

  Wall(float x, float y, float sizeX, float sizeY) {
    //Make the line appear at the specified place
    this.x = x;
    this.y = y;
    //Random depth
    this.z = random(startingZ, maxZ);  

    //We determine the size because the walls on the floors have a different size than those on the sides
    this.sizeX = sizeX;
    this.sizeY = sizeY;
  }

  //Display function
  void display(float scoreLow, float scoreMid, float scoreHi, float intensity, float scoreGlobal) {
    //Color determined by low, medium and high sounds
    //Opacity determined by the overall volume
    color displayColor = color(scoreLow*0.67, scoreMid*0.67, scoreHi*0.67, scoreGlobal);

    //Make lines disappear in the distance to give an illusion of fog
    fill(displayColor, ((scoreGlobal-5)/1000)*(255+(z/25)));
    noStroke();

    //First band, the one that moves according to the force
    //Transformation Matrix
    pushMatrix();

    //Shifting
    translate(x, y, z);

    //extension
    if (intensity &gt; 100) intensity = 100;
    scale(sizeX*(intensity/100), sizeY*(intensity/100), 20);

    //Creation of the "box"
    box(1);
    popMatrix();

    //Second band, the one that is still the same size
    displayColor = color(scoreLow*0.5, scoreMid*0.5, scoreHi*0.5, scoreGlobal);
    fill(displayColor, (scoreGlobal/5000)*(255+(z/25)));
    //Transformation Matrix
    pushMatrix();

    //Shifting
    translate(x, y, z);

    //extension
    scale(sizeX, sizeY, 10);

    //Creation of the "box"
    box(1);
    popMatrix();

    //Z displacement
    z+= (pow((scoreGlobal/150), 2));
    if (z &gt;= maxZ) {
      z = startingZ;  
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to change the stroke of my triangles with serial port data?</title>
      <link>https://forum.processing.org/two/discussion/23218/how-to-change-the-stroke-of-my-triangles-with-serial-port-data</link>
      <pubDate>Mon, 26 Jun 2017 19:02:26 +0000</pubDate>
      <dc:creator>realdapsis</dc:creator>
      <guid isPermaLink="false">23218@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm new to processing and I'm working with this code.. while I accomplished to fade the background I wonder how to change the stroke weight with the same data the background changes. Thanks in advance. This is my code:</p>

<pre><code>import processing.serial.*;
import ddf.minim.*;
import ddf.minim.signals.*;

Minim minim;
AudioPlayer mySound;

Serial port;
float brightness;



void setup() {
size(1000, 500,P3D);


String portName = Serial.list()[2];
port = new Serial(this, "/dev/cu.usbmodem1421", 9600);
port.bufferUntil('\n');
noFill();
strokeWeight(1);

minim = new Minim(this);
mySound = minim.loadFile("bb.mp3");
mySound.play();
mySound.loop();  
}
int n=0;

void draw ()
{
background (brightness, 0, 25);


translate(width/2,height/2);
for(int i = 0; i &lt; mySound.bufferSize() - 1; i++)  {

stroke(random(250),random(250),random(250));

rotateX(n*-PI/6*0.05);
rotateY(n*-PI/6*0.05);
rotateZ(n*-PI/6*0.05);


triangle (i,i,mySound.left.get(i)*50,mySound.left.get(i)*50,i,i);
}
n++;

}

void serialEvent (Serial port)
{
brightness = float (port.readStringUntil ('\n'));



}
</code></pre>
]]></description>
   </item>
   <item>
      <title>2d stereo oscilloscope</title>
      <link>https://forum.processing.org/two/discussion/20863/2d-stereo-oscilloscope</link>
      <pubDate>Sat, 18 Feb 2017 13:52:34 +0000</pubDate>
      <dc:creator>chanof</dc:creator>
      <guid isPermaLink="false">20863@/two/discussions</guid>
      <description><![CDATA[<p>Hi there, I created this simple oscilloscope with point, and i try without result to use line to merge points, i understand i have to store the x,y points of the two stereo channels into an array but i don't understand how, could some one help me about?</p>

<p>Thanks a lot!
Gianmaria</p>
]]></description>
   </item>
   <item>
      <title>Using a sound input to affect text.</title>
      <link>https://forum.processing.org/two/discussion/2513/using-a-sound-input-to-affect-text</link>
      <pubDate>Sun, 19 Jan 2014 15:09:48 +0000</pubDate>
      <dc:creator>sam_strudwick</dc:creator>
      <guid isPermaLink="false">2513@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to self teach the Processing language, and struggling with something I'm trying to do for university.</p>

<p>This is probably quite simple for someone who knows what they're doing... I'm trying to use sound input to change the opacity of text. The louder the sound, the greater the opacity. Could someone help with the coding?</p>

<p>Many thanks hope someone can help!</p>
]]></description>
   </item>
   <item>
      <title>What port name do I use?</title>
      <link>https://forum.processing.org/two/discussion/18803/what-port-name-do-i-use</link>
      <pubDate>Mon, 31 Oct 2016 05:13:31 +0000</pubDate>
      <dc:creator>Sean02</dc:creator>
      <guid isPermaLink="false">18803@/two/discussions</guid>
      <description><![CDATA[<p>I have got his code of someone else as i am a beginner. I am using a windows computer. I not sure what the port name is.
This is the line of my code that isn't working.  **  arduino = new Arduino(this, "/dev/com5", 57600.  Line 34 is the one i need help with.</p>

<pre><code>import cc.arduino.*;
import org.firmata.*;

import ddf.minim.*;  
import ddf.minim.analysis.*;
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

Minim minim;  
AudioPlayer song;
FFT fft;

int redPin1 = 12;
int greenPin1 = 11;
int bluePin1 = 10;

int redPin2 = 9;
int greenPin2 = 7;
int bluePin2 = 8;

int redPin3 = 6;
int greenPin3 = 4;
int bluePin3 = 5;

int color_id = 0;

int common_cathode = 0;

void setup() {
    size(800, 600);

    arduino = new Arduino(this, "/dev/com5", 57600);
    for (int i = 0; i &lt;= 13; i++) arduino.pinMode(i, Arduino.OUTPUT);
    for (int i = 0; i &lt;= 13; i++) arduino.digitalWrite(i,arduino.HIGH);

    minim = new Minim(this);  
    song = minim.loadFile("fugly.mp3");
    song.play();
    fft = new FFT(song.bufferSize(), song.sampleRate());    
}

void draw() {    
    background(#151515);

    fft.forward(song.mix);

    strokeWeight(1.3);
    stroke(#FFF700);

    // frequency
    pushMatrix();
      translate(250, 0);   
      for(int i = 0; i &lt; 0+fft.specSize(); i++) {
        line(i, height*4/5, i, height*4/5 - fft.getBand(i)*4); 
        if(i%100==0) text(fft.getBand(i), i, height*4/5+20);
        if(i==200) {
          if(fft.getBand(i)&gt;2) {
            setColor1(255,255,0);
            setColor3(255,255,0);
          }
          else if(fft.getBand(i)&gt;1) {
            setColor1(255,0,255);
            setColor3(255,0,255);
          } else {
            setColor1(255,255,255);
            setColor3(255,255,255);
          }
        }
        if(i==50) {
          if(fft.getBand(i)&gt;5) {
            color_id = (color_id+1)%4;
          } else if(fft.getBand(i)&gt;3) {
            if(color_id==0) setColor2(0,255,0);
            else if(color_id==1) setColor2(0,255,255);
            else if(color_id==2) setColor2(0,0,255);
            else setColor2(255,0,0);
          } 
          else {
            setColor2(255,255,255);
          }
        } 
      }  
    popMatrix();

    stroke(#FF0000);

    //waveform
    for(int i = 250; i &lt; song.left.size() - 1; i++) {
      line(i, 50 + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
      line(i, 150 + song.right.get(i)*50, i+1, 150 + song.right.get(i+1)*50);
      line(i, 250 + song.mix.get(i)*50, i+1, 250 + song.mix.get(i+1)*50);
    }

    noStroke();
    fill(#111111);
    rect(0, 0, 250, height);

    textSize(24);
    fill(#046700);
    text("left amplitude", 10, 50); 
    text("right amplitude", 10, 150); 
    text("mixed amplitude", 10, 250); 
    text("frequency", 10, height*4/5); 
}

void stop()
{
    for (int i = 0; i &lt;= 13; i++) arduino.digitalWrite(i,arduino.HIGH);
    song.close();  
    minim.stop();
    super.stop();
}
void setColor1(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin1, red);
  arduino.digitalWrite(greenPin1, green);
  arduino.digitalWrite(bluePin1, blue);  
}
void setColor2(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin2, red);
  arduino.digitalWrite(greenPin2, green);
  arduino.digitalWrite(bluePin2, blue);  
}
void setColor3(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin3, red);
  arduino.digitalWrite(greenPin3, green);
  arduino.digitalWrite(bluePin3, blue);  
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sound Amplitude coding</title>
      <link>https://forum.processing.org/two/discussion/16985/sound-amplitude-coding</link>
      <pubDate>Sat, 04 Jun 2016 10:44:16 +0000</pubDate>
      <dc:creator>oc9316</dc:creator>
      <guid isPermaLink="false">16985@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,
I want to try and modify an existing code (which tracks in real time the amplitude of surrounding noises and visualises them via a waveform on the screen), so that when a certain sound reaches a certain amplitude a desired sound (such as the recorded sound of rain) starts to automatically play to negate this noise, and stops after the noise it is trying to negate has not gone above that same high amplitude for 10 seconds. How would I go about modifying this existing code to do this?</p>

<p>Any kind of feedback would be appreciated!</p>

<p>Here is the existing code I have-</p>

<p>`
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.*;</p>

<p>Minim minim;<br />
FFT fft;</p>

<p>AudioInput in;</p>

<p>void setup()
{
  size(1000, 300, P3D);</p>

<p>minim = new Minim(this);</p>

<p>in = minim.getLineIn();</p>

<p>fft = new FFT(in.bufferSize(), in.sampleRate());</p>

<p>}</p>

<p>void draw()
{
  background(0);</p>

<p>stroke( 255 );</p>

<p>for(int i = 0; i &lt; in.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, in.bufferSize(), 0, width );
    float x2 = map( i+1, 0, in.bufferSize(), 0, width );
    line( x1, 50 + in.mix.get(i)<em>50, x2, 50 + in.mix.get(i+1)</em>50 );
  }</p>

<p>noStroke();
  fill( 255, 128 );</p>

<p>rect( 0, 0, in.mix.level()*width, 100 );</p>

<p>}`</p>
]]></description>
   </item>
   <item>
      <title>Landscape generator with the help of sound</title>
      <link>https://forum.processing.org/two/discussion/16018/landscape-generator-with-the-help-of-sound</link>
      <pubDate>Thu, 14 Apr 2016 13:46:06 +0000</pubDate>
      <dc:creator>Raffish</dc:creator>
      <guid isPermaLink="false">16018@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am working on a landscape generator. i had the idea of a Perlin Noise surface wich interacts with sound.
I wonder how i can feed it with even more parameters to get it more visible that the sound has an influence on the surface?
has anybody an idea or even a similar example i can look on?</p>

<p>This is my code:</p>

<pre><code>import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;

FFT fftLin;
FFT fftLog;



boolean record;                                                


int datascale = 250;
int dsh = datascale / 2;
float[][] data = new float [datascale][datascale];
float incrementation = 0.01;
int dataheight = 190;
int g;
int p;
float fram;
float z = 0.9;
float zoff = 3;
boolean stop;
boolean lnon;
float framspeed = 0.01;
boolean mouseleftpressed;


import peasy.*;
PeasyCam cam;

void setup() {
  background(0);
  stroke(255);
  strokeWeight(1);
  size(1920, 1080,P3D);
    minim = new Minim(this);
  player = minim.loadFile("groove.mp3");
  meta = player.getMetaData();
  beat = new BeatDetect();
  player.loop();
//  player.play();



}
void draw() {


   beat.detect(player.mix);


    lights();
     if(stop==false) {
    fram += framspeed;
  }

 translate(width/2, height/2);
  rotateY(map(mouseX,0,width*0.1,-PI/2,PI/2));           
  rotateX(map(mouseY,0,height*0.1,-PI/2,PI/2));              


int bsize = player.bufferSize();

  for(int i = 0; i &lt; datascale; i++) {                                                                                                     //funktion  incrementation
      for(int j = 0; j &lt; datascale; j++) {
       data[i][j] = 2 * noise((i+bsize)*incrementation/4+52, (j+p)*incrementation/4+35, fram/4) + (noise((i+g)*incrementation,
        (j+p)*bsize + pow(noise((i+bsize)*incrementation, (j+p)*incrementation, fram)*2, 2), fram+zoff)) * dataheight;
     }
   }                                                                                                                                           //funktion

  background(0);        //hier wird geupdated


  scale(2);

  for(int i = 1; i &lt; datascale-1; i++) {                                                                                             //konstruktion
    for(int j = 1; j &lt; datascale-1; j++) {


      if(lnon == true) {
        line((i-dsh)*2, (j-dsh)*2, data[i][j], (i-1-dsh)*2, (j-1-dsh)*2, data[i-1][j-1]);
        line((i-dsh)*2, (j-dsh)*2, data[i][j], (i-1-dsh)*2, (j+1-dsh)*2, data[i-1][j+1]);
      }else{
        noStroke();
        beginShape(TRIANGLE_STRIP);
          vertex((i-dsh)*2, (j-dsh)*2, data[i][j]);
          vertex((i-dsh)*2, (j+1-dsh)*2, data[i][j+1]);
          vertex((i+1-dsh)*2, (j-dsh)*2, data[i+1][j]);
          vertex((i+1-dsh)*2, (j+1-dsh)*2, data[i+1][j+1]);
        endShape(CLOSE);
      }
    }
  }        


 }                                                                                                                                  //konstruktion 
</code></pre>
]]></description>
   </item>
   <item>
      <title>beat.isOnset but for kick,snare,hat etc.</title>
      <link>https://forum.processing.org/two/discussion/13309/beat-isonset-but-for-kick-snare-hat-etc</link>
      <pubDate>Thu, 29 Oct 2015 09:35:11 +0000</pubDate>
      <dc:creator>honzojd</dc:creator>
      <guid isPermaLink="false">13309@/two/discussions</guid>
      <description><![CDATA[<p>Hello would you help me, please? I would like to have this ellipse to move by beat, but also but other other sounds like snare, kick or hat for example. Is there some way to do it easy? I tried something like beat.isKick instead of beat.isOnset but it didn't work. Thanks for all tips guys!!</p>

<pre><code>import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;

int  r = 200;
float rad = 70;

void setup()
{
  fullScreen();
  minim = new Minim(this);
  player = minim.loadFile("lilB.mp3");
  meta = player.getMetaData();
  beat = new BeatDetect();
  player.loop();
  //player.play();
  background(0);
}


void draw()
{ 
  beat.detect(player.mix);
  fill(0, 20);
  noStroke();
  rect(0, 0, width, height);
  noFill();
  if (beat.isOnset()) rad = rad*0.9;
  else rad = 70;
  int bsize = player.bufferSize();  
  if (beat.isOnset()) rad = rad+5;
  else rad = 1;
  for (int i = 0; i &lt; bsize; i+=200)
  {  
  fill(255);
  ellipse(200+rad,200,20,20);


}}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Comparing ints and checking value every 5 second.</title>
      <link>https://forum.processing.org/two/discussion/13208/comparing-ints-and-checking-value-every-5-second</link>
      <pubDate>Fri, 23 Oct 2015 15:14:49 +0000</pubDate>
      <dc:creator>stoffer4600</dc:creator>
      <guid isPermaLink="false">13208@/two/discussions</guid>
      <description><![CDATA[<p>Hi.</p>

<p>I'm working on this project, where I have to import the numbers from an excel sheet, and checking which team has the highest score.</p>

<p>I've managed to import numbers from excel sheet and add them together.
I am now in doubt about how to make sure that the check excel sheet every five seconds, and how to compare the different scores for the teams.</p>

<p>The goal is, that every team has different song, and the team with the highest score got to play their song.</p>

<pre><code>import ddf.minim.*;
import de.bezier.data.*;

private int lastMillis = 0;

Minim minim;

AudioPlayer player1;
AudioPlayer player2;
AudioPlayer player3;
AudioPlayer player4;
AudioPlayer player5;

XlsReader reader;

int current_cell;

int team = 5;
int poster = 20;

int team1 = 0;
int team2 = 0;
int team3 = 0;
int team4 = 0;
int team5 = 0;

void setup ()
{
  size(512, 200, P3D);

  // we pass this to Minim so that it can load files from the data directory
  minim = new Minim(this);

  // loadFile will look in all the same places as loadImage does.
  // this means you can find files that are in the data folder and the 
  // sketch folder. you can also pass an absolute path, or a URL.
  player1 = minim.loadFile("marcus_kellis_theme.mp3");
  player2 = minim.loadFile("Fatbros.mp3");
  player3 = minim.loadFile("I_don't_mind.mp3");
  player4 = minim.loadFile("Unison.mp3");
  player5 = minim.loadFile("Wonder.mp3");

  reader = new XlsReader( this, "workbook.xls" );    // assumes file to be in the data folder
  for (int i = 0; i &lt; team; i = i+1) {
    for (int j = 0; j &lt; poster; j = j+1) {
      current_cell = (reader.getInt( j+1, i+1 ) );
      if (i == 0) {
          team1 = team1 + current_cell;
      }
      if (i == 1) {
          team2 = team2 + current_cell;
      }
      if (i == 2) {
          team3 = team3 + current_cell;
      }
      if (i == 3) {
          team4 = team4 + current_cell;
      }
      if (i == 4) {
          team5 = team5 + current_cell;
      }
    }
  }
  println(team1);
  println(team2);
  println(team3);
  println(team4);
  println(team5);
}

void draw()
{
  background(0);
  stroke(255);


  // draw the waveforms
  // the values returned by left.get() and right.get() will be between -1 and 1,
  // so we need to scale them up to see the waveform
  // note that if the file is MONO, left.get() and right.get() will return the same value
  for(int i = 0; i &lt; player1.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player1.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player1.bufferSize(), 0, width );
    line( x1, 50 + player1.left.get(i)*50, x2, 50 + player1.left.get(i+1)*50 );
    line( x1, 150 + player1.right.get(i)*50, x2, 150 + player1.right.get(i+1)*50 );
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sound minim</title>
      <link>https://forum.processing.org/two/discussion/12137/sound-minim</link>
      <pubDate>Tue, 18 Aug 2015 14:06:13 +0000</pubDate>
      <dc:creator>lviensen</dc:creator>
      <guid isPermaLink="false">12137@/two/discussions</guid>
      <description><![CDATA[<p>Como posso usar o aúdio e o "desenho de frequência" fora do draw() ?</p>

<pre><code>import ddf.minim.*;

Minim minim;
AudioPlayer groove;

void setup()
{
  size(512, 200, P3D);
  minim = new Minim(this);
  groove = minim.loadFile("groove.mp3", 2048);
  groove.loop();
}

void draw()
{
  background(0);
  stroke(255);
  for(int i = 0; i &lt; groove.bufferSize() - 1; i++)
  {
    line(i, 50  + groove.left.get(i)*50,  i+1, 50  + groove.left.get(i+1)*50);
    line(i, 150 + groove.right.get(i)*50, i+1, 150 + groove.right.get(i+1)*50);
  }
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>