<?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 arraycopy() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=arraycopy%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:50:07 +0000</pubDate>
         <description>Tagged with arraycopy() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedarraycopy%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How do I use arraycopy?</title>
      <link>https://forum.processing.org/two/discussion/27738/how-do-i-use-arraycopy</link>
      <pubDate>Wed, 11 Apr 2018 03:29:50 +0000</pubDate>
      <dc:creator>Grimtin10</dc:creator>
      <guid isPermaLink="false">27738@/two/discussions</guid>
      <description><![CDATA[<p>So, i'm trying to get the differences between two boolean arrays, (I have a setter, i'm trying to make a screen) but if I change one, it changes the other.</p>
]]></description>
   </item>
   <item>
      <title>How to stamp a Pgraphics canvas into a Pimage?</title>
      <link>https://forum.processing.org/two/discussion/26564/how-to-stamp-a-pgraphics-canvas-into-a-pimage</link>
      <pubDate>Tue, 27 Feb 2018 17:54:14 +0000</pubDate>
      <dc:creator>BGADII</dc:creator>
      <guid isPermaLink="false">26564@/two/discussions</guid>
      <description><![CDATA[<p>I know usually you draw in pimage and then save to pgraphics, but is it possible to go the other way around? for example you draw the canvas image(canvas,0,0) with some effects; and then -&gt; save that to a PImage to further effects. If that's not possible, how do you do it the other way around?</p>
]]></description>
   </item>
   <item>
      <title>kin</title>
      <link>https://forum.processing.org/two/discussion/26335/kin</link>
      <pubDate>Tue, 13 Feb 2018 11:51:36 +0000</pubDate>
      <dc:creator>meru_lp</dc:creator>
      <guid isPermaLink="false">26335@/two/discussions</guid>
      <description><![CDATA[<p>thanks for your response</p>
]]></description>
   </item>
   <item>
      <title>Problems with transpose a 2D array or matrix ...</title>
      <link>https://forum.processing.org/two/discussion/25921/problems-with-transpose-a-2d-array-or-matrix</link>
      <pubDate>Fri, 12 Jan 2018 09:39:11 +0000</pubDate>
      <dc:creator>nowtronix</dc:creator>
      <guid isPermaLink="false">25921@/two/discussions</guid>
      <description><![CDATA[<p>Hello !</p>

<p>I have a question about the transpose of a 2D Array or Matrix. 
I wrote a short programm to explain my problem:</p>

<pre><code>int [][] matrix = { {0, 0, 0}, 
                    {0, 1, 0}, 
                    {1, 1, 1} };

int [][] tmpMatrix = new int [3][3];
int [][] newMatrix = new int [3][3];

void setup() {
  size(800, 600);
  background(0);
  tmpMatrix = matrix;
}

void draw() {
  drawMatrix(newMatrix);
  for (int j = 0; j&lt;3; j++) {
    for (int i = 0; i&lt;3; i++) {

      **newMatrix[j][i]**=tmpMatrix[i][j];
    }

    print("\n");
  }
  drawMatrix(matrix);
  drawMatrix(tmpMatrix);
  drawMatrix(newMatrix);
  noLoop();
}

void drawMatrix(int [][] matrix) { 
  for (int j = 0; j&lt;3; j++) {
    print("\n");
    for (int i = 0; i&lt;3; i++) {
      print(matrix[j][i]);
    }
  }
  print("\n");
}
</code></pre>

<p>So this programm works fine and I get the transpose of the Matrix in "newMatrix".</p>

<p>But when I change the variable from "newMatrix" into "matrix" (I mean inside of the two for loops) the transposed matrix is wrong !</p>

<p>I don't understand what is the problem here.</p>

<p>Thank you a lot !</p>
]]></description>
   </item>
   <item>
      <title>Stitch together audio samples from microphone to get continuous signal?</title>
      <link>https://forum.processing.org/two/discussion/10900/stitch-together-audio-samples-from-microphone-to-get-continuous-signal</link>
      <pubDate>Tue, 19 May 2015 17:45:59 +0000</pubDate>
      <dc:creator>darwexter</dc:creator>
      <guid isPermaLink="false">10900@/two/discussions</guid>
      <description><![CDATA[<p>I want to capture real-time audio continuously without interruption, so I can take samples of arbitrary length from that capture, but without waiting for that capture-length of time. My goal is to be able to analyze the signal such that the higher frequency results appear immediately, while allowing some lag for the lower frequency components.  The code below shows my attempt to do this using an array to paste together the input samples as they appear, using arrayCopy() to move older samples to the right, eventually falling off.  I had expected that each new sample would start where the previous sample had ended, but this appears not to be the case.  The sketch shows this as a discontinuity in waveform at the junctions shown in the middle (most easily seen with a sine wave input, varying the frequency).  I've checked the timing various ways, and the problem is not with math or drawing speed.  An additional waveform discontinuity seen only in the most recent sample at about 10-20% from the left suggests that new samples actually do not start at the end of the old sample.<br />
As you can see I've tried using a "listener" and putting the capture and array processing in a separate thread from draw, as well as checking my assumptions about which end of the capture buffer is most recent. I'm sure there must be some solution to this. GetInputStream looks like a possibility, but I couldn't find any examples showing how to use it. Or am I better off going to Processing 3?
Many Thanks for suggestions!!!</p>

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

Minim       minim;
AudioInput in1;
ListenUp listenUp;

int bufSize = 1024, bufMult = 16;

float points[] = new float[bufSize];
float bigSrc[] = new float[bufMult*bufSize];
float bigDest[] = new float[bufMult*bufSize];

class ListenUp implements AudioListener
{
  private float[] left;
  private float[] right;

  ListenUp()
  {
    left = null; 
    right = null;
  }

  synchronized void samples(float[] samp)
  {
    left = samp;
  }

  synchronized void samples(float[] sampL, float[] sampR)
  {
    left = sampL;
    right = sampR;
  }  
}

void setup()
{
 // frameRate(30);
  size(bufSize/2, 400);
  minim = new Minim(this);
  listenUp = new ListenUp();

  in1 = minim.getLineIn(Minim.MONO, bufSize); 

  background(0);

  for (int i=0; i&lt;bufMult*bufSize; i++)
  {
     bigSrc[i]=0;
     bigDest[i]=0;
  }
  in1.addListener(listenUp);
}


void stuff()
{  
   if ( listenUp.left != null )
    {
      points = listenUp.left; //read "listened" input buffer front to back
    //  for(int i = 0; i&lt;bufSize; i++) {points[bufSize-1-i]=listenUp.left[i];} //read "listened input buffer back to front

//    arrayCopy(bigSrc, bufSize, bigDest, 0, (bufMult-1)*bufSize); //to put most recent input at back of array
//    arrayCopy(points, 0, bigDest, (bufMult-1)*bufSize, bufSize); // ''

    arrayCopy(bigSrc, 0, bigDest, bufSize, (bufMult-1)*bufSize);  //to put most recent input at front of array
    arrayCopy(points, 0, bigDest, 0, bufSize);                    //''

    arrayCopy(bigDest, bigSrc);
  }
}

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

  thread("stuff"); //to see if capturing input as separate thread helps - no difference

  for (int j=0; j&lt;bufMult/2; j++) //presenting result as adjacent buffers to show discontinuity in capture
  {
    for(int i = 0; i&lt;bufSize*2; i+=4) //take every 4th point - to fit on screen and to decrease draw time
    { 
      float dH = bigDest[i+j*bufSize]*100;
      line( i/4, height*(j+1)/10-dH, i/4+1, height*(j+1)/10 - dH );
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Draw lines on click</title>
      <link>https://forum.processing.org/two/discussion/23606/draw-lines-on-click</link>
      <pubDate>Fri, 28 Jul 2017 00:20:08 +0000</pubDate>
      <dc:creator>albobz</dc:creator>
      <guid isPermaLink="false">23606@/two/discussions</guid>
      <description><![CDATA[<p>I have this code I have written that is a simple drawing program using arrays to store points where the mouse was clicked, and functions that modify the array in different ways. Other than the keyPressed(), everything else is complete, but the program is not working properly and I'm not sure where I went wrong.</p>

<pre><code>final int START_POINTS = 5;

int[] x = new int[START_POINTS];
int[] y = new int[START_POINTS];
int pointCount = 0;
int red = int(random(255));
int green = int(random(255));
int blue = int(random(255));
color clr = color(red, green, blue);

void setup()
{
  size(500, 500);
}

void draw()
{
  background(0);
  stroke(255);
  drawLines(x, y, pointCount);
}

/********************
*  Adds the given x, y point to the corresponding array. curSize corresponds to the
*  existing data entries in the array and the fucntion returns the new number of points
*  in the array.
********************/
int addPoint(int x, int y, int[] pointsX, int[] pointsY, int curSize)
{
  for (int c = 0; c &lt; curSize; c++)
  {
    pointsX[c] = x;
    pointsY[c] = y;
  }
  return curSize++;
}

/********************
*  Draws lines between consecutive pairs of points in the arrays, forming a continuous
*  line.
********************/
void drawLines(int[] x, int[] y, int curSize)
{
  for (int p = 1; p &lt; curSize; p++)
  {
    line(x[p-1], y[p-1], x[p], y[p]);
  }
}

/********************
*  Add the value in delta to every value in the array.
********************/
void addToData(int[] data, int curSize, int delta)
{
  for (int d = 0; d &lt; curSize; d++)
  {
    data[d] = data[d] + delta;
  }
}

/********************
*  Multiplies the value in rate to every value in the array.
********************/
void multiplyData(int[] data, int curSize, float rate)
{
  for (int d = 0; d &lt; curSize; d++)
  {
    data[d] = int(data[d] * rate);
  }
}

/********************
*  Creates and returns a new array that is double the size of the old array, with all
*  data in oldArray copied into the new one. 
********************/
int[] doubleArray(int[] oldArray)
{
  int[] newArray = expand(oldArray);
  arrayCopy(oldArray,newArray);
  return newArray;
}

/********************
*  Removes half the data from a given array, and returns the new array size. Data from
*  the even numbered positions are kept, odd positons are thrown out
********************/
int shrinkData(int[] data, int curSize)
{
  for (int s = 0; s &lt; curSize; s++)
  {
    if (s % 2 == 0)
    {
      data[s] = data[s/2];
    }
  }
  int newSize = data.length/2;
  return newSize;
}

/********************
*  Averages all data in the array.
********************/
int averagePoints(int[] data, int curSize)
{
  int sum = 0;
  for (int s = 0; s &lt; curSize; s++)
  {
    sum += data[s];
  }
  int average = sum/curSize;
  return average;
}

/********************
*  Modifies all values in the array so they get closer to/further from the offset value
*  by a factor of scale.
********************/
void scaleAroundOffset(int[] data, int curSize, int offset, float scale)
{
  addToData(data, curSize, -offset);
  multiplyData(data, curSize, scale);
  addToData(data, curSize, offset);
}

/********************
*  Add current mouse location to the array using addPoint. If not enough space use
*  doubleArray to make the array larger.
********************/
void mousePressed()
{
  addPoint(mouseX, mouseY, x, y, pointCount);
  if (x.length &gt; START_POINTS)
  {
    doubleArray(x);
    doubleArray(y);
  }
}

/********************
*  Erase, shift, zoom, change colour or delete every second point depending which key
*  is pressed.
********************/
void keyPressed()
{
  if (keyPressed)
  {
    if (key == 'w')
    {
      scaleAroundOffset(y, pointCount, 5, 0.5);
    }
    if (key == 'a')
    {
      scaleAroundOffset(x, pointCount, 5, -0.5);
    }
    if (key == 's')
    {
      scaleAroundOffset(y, pointCount, 5, -0.5);
    }
    if (key == 'd')
    {
      scaleAroundOffset(x, pointCount, 5, 0.5);
    }
    if (key == 'q')
    {
      background(0);
    }
    if (key == '!')
    {
      red = int(random(255));
      green = int(random(255));
      blue = int(random(255));
    }
    if (key == 'c')
    {
      shrinkData(x, pointCount);
      shrinkData(y, pointCount);
    }
    if (key == '+')
    {
      multiplyData(x, averagePoints(x, pointCount), 1.5);
      multiplyData(y, averagePoints(y, pointCount), 1.5);
    }
    if (key == '-')
    {
      multiplyData(x, averagePoints(x, pointCount), -2.0);
      multiplyData(y, averagePoints(y, pointCount), -2.0);
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>NullPointer Exception Issue</title>
      <link>https://forum.processing.org/two/discussion/21566/nullpointer-exception-issue</link>
      <pubDate>Thu, 23 Mar 2017 23:09:27 +0000</pubDate>
      <dc:creator>AndresAlejandro</dc:creator>
      <guid isPermaLink="false">21566@/two/discussions</guid>
      <description><![CDATA[<p>I have a code that I need running for several hours. After several minutes it stops responding altogether (and I have to force quit the application) and gives me the error "NullPointer Exception" and highlights line 106. I have not been able to solve this, it may be because it runs out of pixels to grab? I am not sure. Another issue I am having is that it is using both my USB camera and my built-in mac camera. How do I get it to only use the USB camera? 
    final int kTotalGlitches=10;
    int currGlitch=0;
    PImage img;
    ArrayList glitches;</p>

<pre><code>final int kGlitchState=0;
final int kCamState=1;

int state=kCamState;


// ---------------------------------

final int kGlitchTimeLapse=7000;  // 2 secs
final int kCamTimeLapse=5000;    //8 secs
int triggerTime;

// ---------------------------------


import processing.video.*; 
Capture cam; 
Capture video;



void setup() { 
  size(1024, 768); 
  imageMode(CENTER);

  glitches = new ArrayList &lt;GlitchClass&gt;();
  for (int i=0; i&lt;kTotalGlitches; i++)
    glitches.add(new GlitchClass());

  cam = new Capture(this);
  cam.start();
  triggerTime=millis()+kCamTimeLapse;
  img = cam;
  video = new Capture(this, width, height);
  video.start();
} 

void draw() { 

  if (millis()&gt;=triggerTime) {

    if (state==kCamState) {
      state=kGlitchState;
      triggerTime+=kGlitchTimeLapse;
      currGlitch=int(random(kTotalGlitches));  //Select new glitch
    } else {
      state=kCamState;
      triggerTime+=kCamTimeLapse;
    }
  }

  if (state==kCamState)
    image(cam, width/2, height/2);
  else {
    background(0);
    glitches.get(currGlitch).display();
  }
} 


void captureEvent(Capture camera) {
  camera.read();

  img = createImage(width, height, RGB);
  video.loadPixels();
  arrayCopy(video.pixels, img.pixels);
}


//A glitch is just two ellipses overlapping on top of each other with different
//colors and one being rotated by 90 degrees.
class GlitchClass {

  void display() {

    loadPixels();

    int randPos = 0;
    if (frameCount  % 100 == 0)
      randPos = (int)random(0, video.height -4);

    int randPosY = 0;

    // if (frameCount  % 100 == 0)
    randPosY = (int)random(20, 50);

    // Begin a loop for displaying pixel rows of 4 pixels height
    for (int y = 0; y &lt; video.height -57; y++) {
      if (img != null) {
        img.loadPixels();

        // Put 4 rows of pixels on the screen
        if (frameCount % 50 == 0)
          randPosY = (int)random(20, 50);
        for (int x = 0; x &lt; video.width; x++) {
          if (frameCount % 100 == 0)
            randPosY = (int)random(20, 50);
          if (y &lt; video.height -4) {
            pixels[x + (y + 0 + randPosY)* width] = img.pixels[  (y + 0 )* video.width + randPos + x];
            pixels[x + (y + 1 + randPosY) * width] = img.pixels[ (y + 1) * video.width + randPos + 1 + x];
            pixels[x + (y + 2 + randPosY) * width] = img.pixels[ (y + 2) * video.width + randPos + 2 + x];
            pixels[x + (y + 3 + randPosY) * width] = img.pixels[ (y + 3) * video.width + randPos + 3 + x];

            pixels[x + (y + 4 + randPosY)* width] = img.pixels[  (y + 4 )* video.width + randPos + 4 + x];
            pixels[x + (y + 5 + randPosY) * width] = img.pixels[ (y + 5) * video.width + randPos + 5 + x];
            pixels[x + (y + 6 + randPosY) * width] = img.pixels[ (y + 6) * video.width + randPos + 6 + x];
            pixels[x + (y + 7 + randPosY) * width] = img.pixels[ (y + 7) * video.width + randPos + 7 + x];
          }
        }
      } else {
        break;
      }
    }

    updatePixels();
  }
}
</code></pre>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Copy PGraphics by value</title>
      <link>https://forum.processing.org/two/discussion/20716/copy-pgraphics-by-value</link>
      <pubDate>Wed, 08 Feb 2017 14:38:49 +0000</pubDate>
      <dc:creator>cameyo</dc:creator>
      <guid isPermaLink="false">20716@/two/discussions</guid>
      <description><![CDATA[<p>Which is the best(fast) way  to copy two PGraphics (P1 over P2) by value ?<br />
P2 = P1 seems to copy by reference :(<br />
Thanks.<br />
cameyo</p>
]]></description>
   </item>
   <item>
      <title>Simply reading/printing a matrix from a text file.</title>
      <link>https://forum.processing.org/two/discussion/20598/simply-reading-printing-a-matrix-from-a-text-file</link>
      <pubDate>Thu, 02 Feb 2017 05:29:34 +0000</pubDate>
      <dc:creator>Abotics99</dc:creator>
      <guid isPermaLink="false">20598@/two/discussions</guid>
      <description><![CDATA[<p>Hi All, I'm fairly new to using arrays and I'm not sure why this code isn't working. All I'm trying to do is read a text file, convert it to a 2D array, and then be able to read that matrix given whatever "coordinates" I put inside the square brackets.  In this code I'm trying to print the variable at (2,2).  The file I'm reading from is just an 8x8 matrix separated by commas.
My problem is everytime I try to run this, I get a NullPointerException on the println line. I apologize if i am saying matrix when i mean 2d array.</p>

<pre><code>int[][] data;

void setup() {
  size(200, 200);
  int[][] data = new int[7][7];
  // Load text file as a String
  String[] stuff = loadStrings("data.csv");
  // Convert string into an array of integers using ',' as a delimiter
  for(int a=0;a&lt;7;a++) {
    data[a] = int(split(stuff[a], ','));
  }
}

void draw() {
  println(data[2][2]);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Motion Detection</title>
      <link>https://forum.processing.org/two/discussion/16860/motion-detection</link>
      <pubDate>Sat, 28 May 2016 10:35:49 +0000</pubDate>
      <dc:creator>Luke12345</dc:creator>
      <guid isPermaLink="false">16860@/two/discussions</guid>
      <description><![CDATA[<p>What's wrong with my code. When I run the code, it pops out a grey windows nothing inside there. The camera should be activated and detect motion in the screen</p>

<pre><code>import processing.video.*; 
int numPixels;
int[] previousFrame;
Capture video;

void setup(){
  size (640, 480);
  video = new Capture (this, width, height);
  numPixels = video.width * video.height;
  previousFrame = new int[numPixels];
  video.start();

}

void draw() {
  if (video.available()){
    video.read();
    video.loadPixels();
    int movementSum=0;
    loadPixels();

    for (int i = 0; i &lt; numPixels; i++){
      color currColor = video.pixels[i];
      color prevColor = previousFrame[i];

      int currR = (currColor &gt;&gt; 16) &amp; 0xFF;
      int currG = (currColor &gt;&gt; 8) &amp; 0xFF;
      int currB = currColor &amp; 0xFF;

      int prevR = (currColor &gt;&gt; 16) &amp; 0xFF;
      int prevG = (currColor &gt;&gt; 8) &amp; 0xFF;
      int prevB = currColor &amp; 0xFF;

      int diffR = abs(currR - prevR);
      int diffG = abs(currG - prevG);
      int diffB = abs(currB - prevB);

      movementSum += diffR + diffG + diffB;
      pixels[i] = color(diffR,diffG,diffB);
      previousFrame[i] = currColor;
    }

   if (movementSum &gt; 0){
     updatePixels();
     println(movementSum);
   }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Zooming in and out using the direction keys? / Changing color of text</title>
      <link>https://forum.processing.org/two/discussion/19076/zooming-in-and-out-using-the-direction-keys-changing-color-of-text</link>
      <pubDate>Wed, 16 Nov 2016 19:23:20 +0000</pubDate>
      <dc:creator>drewk94</dc:creator>
      <guid isPermaLink="false">19076@/two/discussions</guid>
      <description><![CDATA[<p>Hello! Really new to processing.. new to programming in general so bear with me. All I want to do is:</p>

<p>1) Change the color of the text
<br />
2) Zoom in and out using the directional keys (Up, down, left, right)</p>

<p>I can't manage to figure it out.. some help would be great. 
Thank you.</p>

<pre><code>TextGraphics tg;
PVector root = new PVector(random(1234), random(1234), random(1234)), //noise root
nSpeed = new PVector(random(-.02, .02), random(-.02, .02), random(-.02, .02));//noise speed;
ArrayList&lt;Particle&gt; particles = new ArrayList&lt;Particle&gt;();
int nbParticle = 6000;
int[] pgpx;//PGraphics' pixels array
float zoom = 100;//noise zoom level
Boolean noiseOn = true, hitMode = true;
import peasy.*;
PeasyCam cam;


void setup()
{
  size(1300, 800, P3D);
  cam = new PeasyCam(this, 800);
  cam.setMinimumDistance(50);
  cam.setMaximumDistance(1300);
  tg = new TextGraphics();
  strokeWeight(10);
  smooth();

}

void draw()
{ 
  background(0);
  lights();
  box(0);
  pushMatrix();
  box(0);
  popMatrix();


  for (int i = 0; i &lt; nbParticle; i++)
  {
    Particle p = particles.get(i);
    p.update();
  }
  root.add(nSpeed);//update noise


}


void createParticles()
{
  particles = new ArrayList&lt;Particle&gt;();
  //random particle disposition 
  while (particles.size () &lt; nbParticle)
  {
    Particle p = new Particle(particles.size ());
    particles.add(p);
  }
}

void mousePressed()
{
  root = new PVector(random(1234), random(1234));//reset noise root
  nSpeed = new PVector(random(-.02, .02), random(-.02, .02));//reset noise speed
}

void keyPressed()

  {
    switch(key)
    {
    case 'n'://noise toggle
      noiseOn = !noiseOn;
      break;
    case 'h'://hit toggle
      hitMode = !hitMode;
      if (!hitMode)
        for (Particle p : particles)
        {
          p.speed.mult(-1);
        }
      break;
    case ' '://ignore SPACE
    case ESC://ignore ESCAPE
    case ENTER://ignore ENTER
    case BACKSPACE://ignore BACKSPACE
      break;
    default://char input
      //tg.process("" + key);//RUN IN JAVA

      break;
    }
  }


class Particle
{
  final float SPEED_MIN = .12, SPEED_MAX = .25, h = 40;
  PVector pos, origin, speed;
  int rank, col = color(random(128, 255), random(128, 205), 90, 120);
  float n, nz;//noise
  Boolean stuck = false;//against a wall

  Particle(int p_rank)
  {
    rank = p_rank;
    init();
  }

  void init()
  {
    stuck = false;
    float theta = random(TWO_PI);
    speed = new PVector(cos(theta), sin(theta), -cos(theta));
    speed.mult(random(SPEED_MIN, SPEED_MAX) * (random(1)&lt;0?1:-1));
    Boolean done = false;
    while (!done)
    {
      pos = new PVector(random(width), random(height));
      if (green(pgpx[(int)pos.y * width + (int)pos.x]) &gt; 100)
      {
        pos.z = random(-h/2, h/2);
        origin = pos.get();
        done = true;
      }
    }
  }

  void update()
  {
    if (noiseOn &amp;&amp; !stuck)
    {
      n = noise(root.x + pos.x/zoom, root.y + pos.y/zoom, root.z + pos.z/zoom)*2*TWO_PI;
      nz = noise(root.x/10 + pos.x/zoom, root.y + pos.y/zoom, root.z + pos.z/zoom)*2*TWO_PI;
      speed.set(cos(n), sin(n), -cos(nz));
      speed.mult(SPEED_MAX);
    }

    if (!(stuck &amp;&amp; hitMode))
      pos.add(speed);

    if (green(pgpx[(int)pos.y * width + (int)pos.x]) &lt; 80)//particle outside the letter
    {
      stuck = hitMode;
      pos.sub(speed);
      if (!hitMode)
      {
        if (noiseOn)
        { 
          pos = origin.get();
        } else
        {      
          speed.x *= -1;
          speed.y *= -1;
        }
      }
    }
    if (pos.z &gt; h/2 || pos.z &lt; -h/2)
    {
      stuck = hitMode;
      pos.z = constrain(pos.z, -h/2, h/2);
      if (!hitMode)
      {
        if (noiseOn)
        {
          pos = origin.get();
        } else
        {
          speed.z *= -1;
        }
      }
    }

    stroke(map(pos.z, -h/2, h/2, 128, 255), map(pos.z, -h/2, h/2, 128, 205), 90, 120);
    point(pos.x-width/2, pos.y-height/2, pos.z);
  }
}

class TextGraphics
{  
  PGraphics pg;//buffer PG used to write the input char

  TextGraphics()
  {
    pg = createGraphics(width, height, P2D);
    process(new String("Nothing is ever complete."));//"Ï�")//initialize with a String
  }

  void process(String c)
  {
    pg.beginDraw();
    pg.translate(-width/2, -height/1.7);
    pg.background(0);
    pg.textSize(70);//500
    pg.fill(color(255, 255, 255));
    pg.textAlign(CENTER, CENTER);
    pg.text(c, width, height);
    pg.translate(width/2, height/1.7);
    pg.endDraw();

    pgpx = new int[width * height];
    pg.loadPixels();
    arrayCopy(pg.pixels, pgpx);
    pg.updatePixels();

    createParticles();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Same Capture stream in two PApplet frames</title>
      <link>https://forum.processing.org/two/discussion/18993/same-capture-stream-in-two-papplet-frames</link>
      <pubDate>Fri, 11 Nov 2016 18:53:14 +0000</pubDate>
      <dc:creator>stmacarelli</dc:creator>
      <guid isPermaLink="false">18993@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'd like to ask for your help.</p>

<p>I'm working on a Processing sketch running two frames (via runSketch() ).
In the main PApplet I'm showing and filtering, with a GLSL shader, a Capture object.
I'd like to see the same Capture stream in the second PApplet, unfiltered, using it as a "system monitor", and launch PApplet 1 on projector and PApplet 2 on Macbook display.</p>

<p>As fai as I can go, I'm referencing the Capture obj from the main PApplet in the second. if I call image(Capture,0,0) I'm just able to see the first captured frame from the webcam. To actually see the frames updating, I gotta call image(Capture.copy(),0,0); but also if the PApplet framerate doesn't drop, I can see a frame drop in the two sketches.</p>

<p>This doesn't happen if I call two times image(Capture,0,0) in the main PApplet. Framerate of PApplet and Capture stays up.</p>

<p>Any hints?</p>

<p>Thank you.</p>
]]></description>
   </item>
   <item>
      <title>HELP!  How to store pictures in array ?</title>
      <link>https://forum.processing.org/two/discussion/18047/help-how-to-store-pictures-in-array</link>
      <pubDate>Fri, 02 Sep 2016 10:30:59 +0000</pubDate>
      <dc:creator>rao</dc:creator>
      <guid isPermaLink="false">18047@/two/discussions</guid>
      <description><![CDATA[<p>I am going to filter the kinect depth img with guidedfilter,  I want to put pictures（pixels） into the matrix,  then processing  it ...like in matlab. But in processing, I have some problems, and I don't know how to debug them... Here is my code...</p>

<pre><code>translationDepthImg.loadPixels();
resizeHDFillImg.loadPixels();

int  hei= translationDepthImg.height;
int  wid=translationDepthImg.width;
 float  []I=new  float[hei*wid];
 float  []p=new  float[hei*wid];
  float  []q=new  float[hei*wid];
 PApplet.arrayCopy(resizeHDFillImg.pixels,  I);/////???here have bug?
 PApplet.arrayCopy(translationDepthImg.pixels,  p);
q=guidedfilter(I,p, 5, 0.01);
float[] guidedfilter(float[]I,float[]p,int r,float eps)
{.....
}
</code></pre>

<p>please help me ....thanks</p>
]]></description>
   </item>
   <item>
      <title>reset position if inside shape</title>
      <link>https://forum.processing.org/two/discussion/17974/reset-position-if-inside-shape</link>
      <pubDate>Thu, 25 Aug 2016 20:55:17 +0000</pubDate>
      <dc:creator>phaidon</dc:creator>
      <guid isPermaLink="false">17974@/two/discussions</guid>
      <description><![CDATA[<p>hello,again,i have  made this code,with a 3d model,the model starts dismorph after 100 frames.I have a box shape that is moved with mouse,i want when ever the vertices be inside the box,to reset their position to the original position,and reconstruct the model,while the others dismorph. Always resetting the position when they are in the box,and move when they are not.Can anyone help me.Until now what it happens,is that when the vertices are inside the box they stop moving.</p>

<p>Thanks in Advance</p>

<pre><code>import peasy.*;
import saito.objloader.*;


OBJModel model ;
OBJModel tmpmodel ;

PeasyCam cam;

float easing = 0.005;
float r;
float k =0.00001;
int VertCount;
PVector[] Verts;
PVector Mouse;

void setup()
{
  size(800, 800, P3D);
  frameRate(30);
  noStroke();

  model = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  model.enableDebug();
  model.scale(100);
  model.translateToCenter();

  tmpmodel = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  tmpmodel.enableDebug();
  tmpmodel.scale(100);
  tmpmodel.translateToCenter();



  cam = new PeasyCam(this, width/2, height/2, 0, 994);
}



void draw()
{
  background(129);
  lights();

  int VertCount = model.getVertexCount ();
  PVector[] Verts = new PVector[VertCount];
  PVector[] locas = new PVector[VertCount];
  float r =80;
  PVector Mouse = new PVector(mouseX-width/2, mouseY-height/2, 0);


  cam.setMouseControlled(true);










  //println(frameCount);
  pushMatrix();
  translate(width/2, height/2, 0);



  for (int i = 0; i &lt; VertCount; i++) {
    //PVector orgv = model.getVertex(i);


    Verts[i]= model.getVertex(i);
    arrayCopy(Verts, locas);
    //PVector tmpv = new PVector();
    if (frameCount&gt; 100) {



      float randX = random(-5, 5);
      float randY = random(-5, 5);
      float randZ = random(-5, 5);

      PVector Ran = new PVector(randX, randY, randZ);

      //float norX = abs(cos(k)) * randX;
      //float norY = abs(cos(k)) * randY;
      //float norZ = abs(cos(k)) * randZ;









      if (Verts[i].x &gt; Mouse.x  - r/2 &amp;&amp; Verts[i].x &lt; Mouse.x  + r/2) {
        if (Verts[i].x &gt; Mouse.y  - r/2 &amp;&amp; Verts[i].x &lt; Mouse.y  + r/2) {
          if (Verts[i].x &gt; Mouse.z  - r/2 &amp;&amp; Verts[i].x &lt;  Mouse.z  + r/2) {


            arrayCopy(locas, Verts);
          }
        }
      } else {


        Verts[i].x+=Ran.x;
        Verts[i].y+=Ran.y;
        Verts[i].z+=Ran.z;

        if (Verts[i].x &gt; width/2 || Verts[i].x &lt; -width/2) {
          Verts[i].x+=-Ran.x;
        }
        if (Verts[i].y &gt; height/2 || Verts[i].y &lt; -height/2) {
          Verts[i].y+=-Ran.y;
        }
        if (Verts[i].z &lt; -800/2 || Verts[i].z &gt; 800/2) {  
          Verts[i].z+=-Ran.z;
        }
      }
      tmpmodel.setVertex(i, Verts[i].x, Verts[i].y, Verts[i].z);
    }
    k+=0.0001;
  }

  pushMatrix();
  translate(Mouse.x, Mouse.y, Mouse.z);
  noFill();
  stroke(255);
  box(r);
  popMatrix();


  noStroke();

  tmpmodel.draw();

  popMatrix();



  pushMatrix();
  translate(width/2, height/2, 0);
  noFill();
  stroke(255);
  box(width, height, 600);
  popMatrix();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Disposing of a previous call to beginRaw()</title>
      <link>https://forum.processing.org/two/discussion/17253/disposing-of-a-previous-call-to-beginraw</link>
      <pubDate>Tue, 21 Jun 2016 15:38:21 +0000</pubDate>
      <dc:creator>chrisb78</dc:creator>
      <guid isPermaLink="false">17253@/two/discussions</guid>
      <description><![CDATA[<p>I want to save the current frame as PDF, but only if a button has been pressed in that frame as well.
The examples (e.g. the "PDF Files from 3D Geometry (With Screen Display)" from <a href="https://processing.org/reference/libraries/pdf/" target="_blank" rel="nofollow">https://processing.org/reference/libraries/pdf/</a> appear to do something similar, but are essentially different: they use a variable to then save the NEXT frame.</p>

<p>I'd like to do something like the sample from <a href="https://processing.org/reference/beginRaw_.html" target="_blank" rel="nofollow">https://processing.org/reference/beginRaw_.html</a> (below) - to call beginRaw() every frame, and call endRaw() only if a key was pressed - but if no key was pressed at the end of draw(), i'd like to dispose of the recording of the current frame. 
Since there is not call to something like "disposeRaw()", beginRaw() creates a new PDF file each frame.</p>

<pre><code>import processing.pdf.*;

Boolean saveFrame = false;
void setup() {
  size(400, 400, P2D);
}

void draw() {
  beginRaw(PDF, "raw"+frameCount+".pdf");
  line(pmouseX, pmouseY, mouseX, mouseY);
  if (saveFrame == true) endRaw();
  else // disposeRaw();
}

void keyPressed() {
  if (key == ' ') {
    saveFrame = true;
  }
}
</code></pre>

<p>How would I dispose of PDF file creation for frames which already called beginRaw()?</p>
]]></description>
   </item>
   <item>
      <title>KinectPV2 library Color image to depth issue</title>
      <link>https://forum.processing.org/two/discussion/15974/kinectpv2-library-color-image-to-depth-issue</link>
      <pubDate>Tue, 12 Apr 2016 00:04:25 +0000</pubDate>
      <dc:creator>jackthegoodboy</dc:creator>
      <guid isPermaLink="false">15974@/two/discussions</guid>
      <description><![CDATA[<p>Hey!</p>

<p>I'm trying to map color pixels to the depth map using the KinectPV2 library, in order to do some checkerboard detection for calibration.</p>

<p>I've been using the function getMapDepthToColor() which gives you a mapping between the 2 spaces (or so I think).</p>

<p>The following is a modification of the MapDepthToColor example to suit my needs.</p>

<pre><code>import KinectPV2.*;

KinectPV2 kinect;

int [] depthZero;

//BUFFER ARRAY TO CLEAN DE PIXLES
PImage depthToColorImg;

void setup() {
  size(1024, 848, P3D);

  depthToColorImg = createImage(512, 424, PImage.RGB);
  depthZero    = new int[ KinectPV2.WIDTHDepth * KinectPV2.HEIGHTDepth];

  //SET THE ARRAY TO 0s
  for (int i = 0; i &lt; KinectPV2.WIDTHDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.HEIGHTDepth; j++) {
      depthZero[424*i + j] = 0;
    }
  }

  kinect = new KinectPV2(this);
  kinect.enableDepthImg(true);
  kinect.enableColorImg(true);
  kinect.enablePointCloud(true);

  kinect.init();
}

void draw() {
  background(0);

  float [] mapDCT = kinect.getMapDepthToColor();

  //get the raw data from depth and color
  int [] colorRaw = kinect.getRawColor();
  int [] depthRaw = kinect.getRawDepthData();

  //clean de pixels
  PApplet.arrayCopy(depthZero, depthToColorImg.pixels);

  int count = 0;
  depthToColorImg.loadPixels();
  count = 0;

  for (int i = 0; i &lt; KinectPV2.HEIGHTDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.WIDTHDepth; j++) {

      //incoming pixels 512 x 424 with position in 1920 x 1080
      int valX = (int)mapDCT[(count) * 2 + 0];
      int valY = (int)mapDCT[(count) * 2 + 1];

      if (valX &gt;= 0 &amp;&amp; valX &lt; 1920 &amp;&amp; valY &gt;= 0 &amp;&amp; valY &lt; 1080) {
        color colorPixel = colorRaw[valY * 1920 + valX];
        depthToColorImg.pixels[count] = colorPixel;
      }
      count++;
    }
  }

  depthToColorImg.updatePixels();

  image(depthToColorImg, 0, 424);
  image(kinect.getColorImage(), 0, 0, 512, 424);
  image(kinect.getDepthImage(), 512, 0);
}
</code></pre>

<p>Giving the output:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/160/HYPV7TUI2DSD.PNG" alt="Capture" title="Capture" /></p>

<p>Is there something I'm misunderstanding here? Any help would be much appreciated.</p>
]]></description>
   </item>
   <item>
      <title>Problem displaying video (using Atagen VideoSmear sketch)</title>
      <link>https://forum.processing.org/two/discussion/15895/problem-displaying-video-using-atagen-videosmear-sketch</link>
      <pubDate>Thu, 07 Apr 2016 09:14:08 +0000</pubDate>
      <dc:creator>leffy</dc:creator>
      <guid isPermaLink="false">15895@/two/discussions</guid>
      <description><![CDATA[<p>Hi, first post, very new to it all, but enjoying the learn.</p>

<p>Using this code (not mine, from Git Hub, user Atagen I think ( <a href="https://github.com/GlitchTools/Atagen" target="_blank" rel="nofollow">https://github.com/GlitchTools/Atagen</a> )</p>

<p>mp4 is in data file, when run, the canvas appears but remains gray, however the audio plays.</p>

<p>quicktime tells me that it's 29.97 fps, so i've put 30 in the code, and that it's H.264...</p>

<p>not sure if it's a code problem (i guess likely not) or something to do with the vid...any help really appreciated!</p>

<p>(I wasn't sure how to best paste the code, hope it all cool)</p>

<p>// video 'greater than' buffer/delay
// rob mac, 2015
import processing.video.*;</p>

<p>//options
String fileName = "filename.mp4";
int fps = 30; //set your video's fps here, and width/height below
int w = 320;
int h = 238;
float len = 0.5; //length of echo
int mode = 2; //set echo style, 0, 1, or 2</p>

<p>Movie frames;
boolean newFrame = false;
int cached = 0;
int count = int(fps*len)-1;
PImage[] cache = new PImage[count+1];
void setup() {
  size(w, h);
  frames = new Movie(this, fileName);
  frameRate(fps);
  //  noSmooth();
  //  strokeWeight(1.0/fps);
  frames.loop();
  loadPixels();
  cache[count] = createImage(w, h, RGB);
}</p>

<p>void draw() {
  if (newFrame) {</p>

<pre><code>if (cached &lt; count) { 
  cache[cached] = createImage(w, h, RGB);
  cache[cached].loadPixels();
  arrayCopy(frames.pixels, cache[cached].pixels);
  cached++;
} else {
  for (int i = 0; i &lt; count; i++) {
    arrayCopy(cache[i+1].pixels, cache[i].pixels);
  }
  arrayCopy(frames.pixels, cache[cached].pixels);
}

if (cached == count) {
  switch(mode) {
  case 1:
    for (int i = 0; i &lt; w*h; i++) {
      pixels[i%w+(i/w)*w] = color(0);
      for (int o = 0; o &lt; count; o++) {
        pixels[i%w+(i/w)*w] = (brightness(cache[o].pixels[i%w+(i/w)*w])*map(o, 0, count, 1.0, 0.0) &gt; brightness(pixels[i%w+(i/w)*w])) ? cache[o].pixels[i%w+(i/w)*w] : pixels[i%w+(i/w)*w];
        /*        stroke(cache[o].pixels[i%w+(i/w)*w]);
         point(i%w, i/w);*/
      }
    }
    break;

  case 2:
    for (int i = 0; i &lt; w*h; i++) {
      pixels[i%w+(i/w)*w] = color(0);
      for (int o = 0; o &lt; count; o++) {
        pixels[i%w+(i/w)*w] = (brightness(cache[o].pixels[i%w+(i/w)*w]) &gt; brightness(pixels[i%w+(i/w)*w])) ? cache[o].pixels[i%w+(i/w)*w] : pixels[i%w+(i/w)*w];
        /*        stroke(cache[o].pixels[i%w+(i/w)*w]);
         point(i%w, i/w);*/
      }
    }
    break;

  default:
    for (int i = 0; i &lt; w*h; i++) {
      color temp = pixels[i%w+(i/w)*w];
      pixels[i%w+(i/w)*w] = color(0);
      for (int o = 0; o &lt; count; o++) {
        temp = lerpColor(temp, cache[o].pixels[i%w+(i/w)*w], norm(o, count, 0));
      }
      pixels[i%w+(i/w)*w] = temp;
    }
    break;
  }//mode
}
updatePixels();
newFrame = false;
</code></pre>

<p>}
}</p>

<p>void movieEvent(Movie m) {
  m.read();
  newFrame = true;
  m.loadPixels();
}</p>

<p>void keyPressed() {
  switch(key) {
  case ' ':
    mode = (mode == 2) ? 0 : mode+1;
    println(mode);
    break;
  }
}<img src="" alt="" /></p>
]]></description>
   </item>
   <item>
      <title>Duplicate processed pixels</title>
      <link>https://forum.processing.org/two/discussion/15197/duplicate-processed-pixels</link>
      <pubDate>Mon, 29 Feb 2016 15:17:56 +0000</pubDate>
      <dc:creator>somu</dc:creator>
      <guid isPermaLink="false">15197@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, I'm still getting confidence with processing and I had some tryouts about pixel processing. I'm on this sketch, my camera is cameras[3], yours could be different:</p>

<pre><code>    import processing.video.*;
    int i=1;
    Capture cam;
    PImage img;
    int camX;
    int camY;


    void setup ()
    {
       size(800, 600, P3D);
       frameRate(25);

    img = createImage(width, height, RGB);
      String[] cameras = Capture.list();

      if (cameras.length == 0) {
        println("There are no cameras available for capture.");
        exit();
      } else {
        println("Available cameras:");
        for (int i = 0; i &lt; cameras.length; i++) {
          println(cameras[i]);
        }

        // The camera can be initialized directly using an 
        // element from the array returned by list():
        cam = new Capture(this, 640, 480,cameras[3]);
        cam.start(); 
      }
    }
    void draw()
    {
    background(0,10);

      if (cam.available() == true){   
        img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, cam.width, cam.height);
        img.updatePixels();
        cam.read();
      }

      loadPixels();
      cam.loadPixels();
      img.loadPixels();


       //pix process start  
     for (int index=0;index&lt;width*height; index++)
       {
         int myPixel = pixels[index];
         int r = myPixel &gt;&gt;24 &amp; 0xFF;
         int g = myPixel &gt;&gt;8 &amp; 0xFF;
         int b = myPixel &gt;&gt;4 &amp; 0xFF;
         int av = (r*2);
         if (av&gt;128){
           r=av&lt;&lt;16;
           g=av&lt;&lt;8;
           b=av;
          pixels[index]= r|g|b;
         }
       }
       for (int y = 0; y&lt;height; y+=1 ) {
        for (int x = 0; x&lt;width; x+=1) {
          int loc = x + y*img.width;
          float r = red (img.pixels[loc]);
          float g = green (img.pixels[loc]);
          float b = blue (img.pixels[loc]);
          float av = ((r+g)/2.0);

          pushMatrix();
        translate(x,y);

          if (b &gt;10 &amp;&amp; b &lt; 15) {
        stroke(0,g/random(.3),b/random(.6,.7),random(15,80));
      line(0,0, random(-100,100), 0, 0, random(-100,100));
          }   
          if (g &gt;80 &amp;&amp; g &lt; 90) {   
              stroke(r/random(.5,.6),g/random(.3),b/random(.6,.7),random(200,255));
      point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
          }   
          if (r &gt;80 &amp;&amp; r &lt; 85) {

            strokeWeight(random(.25,.95));

            stroke(r/random(-.5,.5),g*(random(1.9)),b/random(b, 0),random(200,250));
            point(random(width/2)*.25,random(height/2)*.25, random(-70,70));
            stroke(r/random(5),g,b/random(.6));
            noFill();
            point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
          }

        popMatrix(); 
        //filter(BLUR,1);


        }
       }}
</code></pre>

<p>which gives out this framing:
<img src="https://forum.processing.org/two/uploads/imageupload/267/01BUWNJUQLLK.jpg" alt="solo" title="solo" /></p>

<p>What I want to do is to have something like this (mock up), so duplicate and mirror on 4 corners the single framing 
<img src="https://forum.processing.org/two/uploads/imageupload/875/EG0SCZOOF26I.jpg" alt="multiple" title="multiple" /></p>

<p>I had different tryouts, I tried to work by objects and classes but it hasn't worked.</p>

<p>I tried to transform img.copy on line 38, but it can't mirror it.</p>

<pre><code>    import processing.video.*;
    int i=1;
    Capture cam;
    PImage img;
    int camX;
    int camY;


    void setup ()
    {
      frameRate(25);
       size(800, 600, P3D);

    img = createImage(width, height, RGB);
      String[] cameras = Capture.list();

      if (cameras.length == 0) {
        println("There are no cameras available for capture.");
        exit();
      } else {
        println("Available cameras:");
        for (int i = 0; i &lt; cameras.length; i++) {
          println(cameras[i]);
        }

        // The camera can be initialized directly using an 
        // element from the array returned by list():
        cam = new Capture(this, 352, 288, cameras[3]);
        cam.start(); 
      }
    }
    void draw()
    {
    background(2);

      if (cam.available() == true){   
        img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, 400, 300);
        img.copy(cam, 0, 0, cam.width, cam.height, 400, 0, 400, 300);
        img.copy(cam, 0, 0, cam.width, cam.height, 0, 300, 400, 300);
        img.copy(cam, 0, 0, cam.width, cam.height, 400, 300, 400, 300);
        img.updatePixels();
        cam.read();
      }

      loadPixels();
      cam.loadPixels();
      img.loadPixels();


       //inizio algoritmo  
       for (int index=0;index&lt;width*height; index++)
       {
         int myPixel = pixels[index];
         int r = myPixel &gt;&gt;24 &amp; 0xFF;
         int g = myPixel &gt;&gt;8 &amp; 0xFF;
         int b = myPixel &gt;&gt;4 &amp; 0xFF;
         int av = (r*2);
         if (av&gt;128){
           r=av&lt;&lt;16;
           g=av&lt;&lt;8;
           b=av;
          pixels[index]= r|g|b;
         }
       }
       for (int y = 0; y&lt;height; y+=1 ) {
        for (int x = 0; x&lt;width; x+=1) {
          int loc = x + y*img.width;
          float r = red (img.pixels[loc]);
          float g = green (img.pixels[loc]);
          float b = blue (img.pixels[loc]);
          float av = ((r+g)/2.0);

          pushMatrix();
        translate(x,y);

          if (b &gt;10 &amp;&amp; b &lt; 15) {
        stroke(0,g/random(.3),b/random(.6,.7),random(15,80));
      line(0,0, random(-100,100), 0, 0, random(-100,100));
          }   
          if (g &gt;80 &amp;&amp; g &lt; 90) {   
              stroke(r/random(.5,.6),g/random(.3),b/random(.6,.7),random(200,255));
      point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
          }   
          if (r &gt;80 &amp;&amp; r &lt; 85) {
            strokeWeight(random(.25,.95));
            stroke(r/random(-.5,.5),g*(random(1.9)),b/random(b, 0),random(200,250));
            point(random(width/2)*.25,random(height/2)*.25, random(-50,50)); 


            point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
            stroke(r/random(5),g,b/random(.6));
            noFill();
            point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
          }

        popMatrix(); 

        //filter(BLUR,1);


        }
       }}
</code></pre>

<p>I tried to quadruplicate and mirror the capture before process it, but it neither worked.</p>

<pre><code>import processing.video.*;

Capture cam;
PImage img;
void setup() {
  size(800, 600);
img = createImage(width, height, RGB);
  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i &lt; cameras.length; i++) {
      println(cameras[i]);
    }

    // The camera can be initialized directly using an 
    // element from the array returned by list():
    cam = new Capture(this, 640, 480,cameras[3]);
    cam.start();       

  }      
}

void draw() {
   if (!cam.available())  return;

  cam.read();

 image(cam, 0, 0, 320, 240);

 pushMatrix();
  scale(-1,1);
  image(cam, -640, 0, 320, 240);
 popMatrix();

  pushMatrix();
  scale(1,-1);
  image(cam, 0, -480, 320, 240);
 popMatrix();

 pushMatrix();
  scale(-1,-1);
  image(cam, -640, -480, 320, 240);
 popMatrix();
   img.updatePixels();
    cam.read();

  loadPixels();
  cam.loadPixels();
  img.loadPixels();


   //inizio algoritmo  
   for (int index=0;index&lt;width*height; index++)
   {
     int myPixel = pixels[index];
     int r = myPixel &gt;&gt;24 &amp; 0xFF;
     int g = myPixel &gt;&gt;8 &amp; 0xFF;
     int b = myPixel &gt;&gt;4 &amp; 0xFF;
     int av = (r*2);
     if (av&gt;128){
       r=av&lt;&lt;16;
       g=av&lt;&lt;8;
       b=av;
      pixels[index]= r|g|b;
     }
   }
   for (int y = 0; y&lt;height; y+=1 ) {
    for (int x = 0; x&lt;width; x+=1) {
      int loc = x + y*img.width;
      float r = red (img.pixels[loc]);
      float g = green (img.pixels[loc]);
      float b = blue (img.pixels[loc]);
      float av = ((r+g)/2.0);

      pushMatrix();
    translate(x,y);

      if (b &gt;10 &amp;&amp; b &lt; 15) {
    stroke(0,g/random(.3),b/random(.6,.7),random(15,80));
  line(0,0, random(-100,100), 0, 0, random(-100,100));
      }   
      if (g &gt;80 &amp;&amp; g &lt; 90) {   
          stroke(r/random(.5,.6),g/random(.3),b/random(.6,.7),random(200,255));
  point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
      }   
      if (r &gt;80 &amp;&amp; r &lt; 85) {
        strokeWeight(random(.25,.95));
        stroke(r/random(-.5,.5),g*(random(1.9)),b/random(b, 0),random(200,250));
        point(random(width/2)*.25,random(height/2)*.25, random(-50,50)); 


        point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
        stroke(r/random(5),g,b/random(.6));
        noFill();
        point(random(width/2)*.25,random(height/2)*.25, random(-10,10));
      }

    popMatrix(); 

    //filter(BLUR,1);


    }
   }
}
</code></pre>

<p>It should be projected on real time, so I suppose I can't save frames and then work on them.</p>

<p>is there any suggestion? whats wrong with codes (I suppose a lot of things, but what's basic to run it properly)?</p>

<p>Thank you very much, 
Andrea</p>
]]></description>
   </item>
   <item>
      <title>Can I store another images pixel into a different image's pixel buffer?</title>
      <link>https://forum.processing.org/two/discussion/15065/can-i-store-another-images-pixel-into-a-different-image-s-pixel-buffer</link>
      <pubDate>Mon, 22 Feb 2016 23:27:50 +0000</pubDate>
      <dc:creator>atran</dc:creator>
      <guid isPermaLink="false">15065@/two/discussions</guid>
      <description><![CDATA[<p>Say for example I did pic = loadImage("pic.jpg") and I did pic2 = createImage(width,height,RGB). Would I be able to store pixels of pic into pic2?
  <br />
If I found the right indices could I just do pic2.pixels[location] = color(r , g ,b ), where r g and b are found from the first image like: r = red(pic.pixels[location])?</p>

<p><br /></p>

<p>thank you</p>
]]></description>
   </item>
   <item>
      <title>How to change main sketch display?</title>
      <link>https://forum.processing.org/two/discussion/14835/how-to-change-main-sketch-display</link>
      <pubDate>Wed, 10 Feb 2016 04:26:24 +0000</pubDate>
      <dc:creator>rtavakko</dc:creator>
      <guid isPermaLink="false">14835@/two/discussions</guid>
      <description><![CDATA[<p>I'm using this modified main method to run my main sketch on a second display in 3.0a5. The sketch doesnt run because my sketch path is lost, I tried exporting the sketch and it didnt work. Any suggestions?</p>

<pre><code>static final void main(final String[] args) {
  final String sketch = Thread.currentThread().getStackTrace()[1].getClassName();
  final String[] monitor = { "--display=1", "--present" };
  final String[] params = concat(append(monitor, sketch), args);

  PApplet.main(params);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Problem with example in reference</title>
      <link>https://forum.processing.org/two/discussion/14635/problem-with-example-in-reference</link>
      <pubDate>Wed, 27 Jan 2016 14:59:59 +0000</pubDate>
      <dc:creator>discoman</dc:creator>
      <guid isPermaLink="false">14635@/two/discussions</guid>
      <description><![CDATA[<p>I am making examples for reference of p5.image to be put in inline documentation (thereby for online reference). I have placed a PR for 3 examples that I was able to make successfully but I am not able to make it work for loadPixel() method of p5Image class.
<a rel="nofollow" href="http://p5js.org/reference/#p5.Image/loadPixels">p5js.org/reference/#p5.Image/loadPixels</a></p>

<p>It is all about porting examples from processing. So I was porting from <a rel="nofollow" href="https://processing.org/reference/PImage_loadPixels_.html">https://processing.org/reference/PImage_loadPixels_.html</a></p>

<p>So my code</p>

<pre><code>            var myImage;
            var halfImage;

            function preload(){
              myImage = loadImage("assets/rockies.jpg");
            }

            function setup(){
              myImage.loadPixels();
              halfImage = width*height/2;
              for(var i=0; i&lt;halfImage; i++){
                myImage.pixels[i+halfImage] = myImage.pixels[i];
              }
              myImage.updatePixels();
            }

            function draw(){
              image(myImage, 0, 0);
            }
</code></pre>

<p>Is not producing expected result.
Then I looked at the loadPixel() of p5 class.<a rel="nofollow" href="http://p5js.org/reference/#p5/loadPixels">p5js.org/reference/#p5/loadPixels</a>.
I guess this too is not producing desired result.
Need someones guidance here. About what is the error in my code for loadPixels() for p5.image above.</p>

<p>PS - To run the code quickly -
1. Open <a href="http://p5js.org/reference/#/p5.Image/set" target="_blank" rel="nofollow">http://p5js.org/reference/#/p5.Image/set</a>
2. Click "edit" in example, delete existing code and paste this.
3. rockies.jpg is present in the assets of p5js-website and is accessible here.</p>

<p>Sorry for big question I tried putting everything I have done for clarity.</p>
]]></description>
   </item>
   <item>
      <title>code giving a voice alert only and only when motion is detected in front of laptop camera</title>
      <link>https://forum.processing.org/two/discussion/14515/code-giving-a-voice-alert-only-and-only-when-motion-is-detected-in-front-of-laptop-camera</link>
      <pubDate>Mon, 18 Jan 2016 10:18:58 +0000</pubDate>
      <dc:creator>Abhi_1122</dc:creator>
      <guid isPermaLink="false">14515@/two/discussions</guid>
      <description><![CDATA[<p>I am a beginner, so I want to know the code by which the laptop's camera detects motion and speaks something like "Alert we have an intruder"
this is the code which I found out in examples....</p>

<p>Code for Background subtraction...</p>

<p>/**
 * Background Subtraction 
 * by Golan Levin. 
 *
 * GSVideo version by Andres Colubri. 
 * 
 * Detect the presence of people and objects in the frame using a simple
 * background-subtraction technique. To initialize the background, press a key.
 */</p>

<p>import codeanticode.gsvideo.*;</p>

<p>int numPixels;
int[] backgroundPixels;
GSCapture video;</p>

<p>void setup() {
  // Change size to 320 x 240 if too slow at 640 x 480
  size(640, 480);</p>

<p>video = new GSCapture(this, width, height);
  video.start();<br />
  numPixels = video.width * video.height;
  // Create array to store the background image
  backgroundPixels = new int[numPixels];
  // Make the pixels[] array available for direct manipulation
  loadPixels();
}</p>

<p>void draw() {
  if (video.available()) {
    video.read(); // Read a new video frame
    video.loadPixels(); // Make the pixels of video available
    // Difference between the current frame and the stored background
    int presenceSum = 0;
    for (int i = 0; i &lt; numPixels; i++) { // For each pixel in the video frame...
      // Fetch the current color in that location, and also the color
      // of the background in that spot
      color currColor = video.pixels[i];
      color bkgdColor = backgroundPixels[i];
      // Extract the red, green, and blue components of the current pixel�s color
      int currR = (currColor &gt;&gt; 16) &amp; 0xFF;
      int currG = (currColor &gt;&gt; 8) &amp; 0xFF;
      int currB = currColor &amp; 0xFF;
      // Extract the red, green, and blue components of the background pixel�s color
      int bkgdR = (bkgdColor &gt;&gt; 16) &amp; 0xFF;
      int bkgdG = (bkgdColor &gt;&gt; 8) &amp; 0xFF;
      int bkgdB = bkgdColor &amp; 0xFF;
      // Compute the difference of the red, green, and blue values
      int diffR = abs(currR - bkgdR);
      int diffG = abs(currG - bkgdG);
      int diffB = abs(currB - bkgdB);
      // Add these differences to the running tally
      presenceSum += diffR + diffG + diffB;
      // Render the difference image to the screen
      pixels[i] = color(diffR, diffG, diffB);
      // The following line does the same thing much faster, but is more technical
      //pixels[i] = 0xFF000000 | (diffR &lt;&lt; 16) | (diffG &lt;&lt; 8) | diffB;
    }
    updatePixels(); // Notify that the pixels[] array has changed
    println(presenceSum); // Print out the total amount of movement
  }
}</p>

<p>// When a key is pressed, capture the background image into the backgroundPixels
// buffer, by copying each of the current frame�s pixels into it.
void keyPressed() {
  video.loadPixels();
  arraycopy(video.pixels, backgroundPixels);
}</p>

<p>Code for frame differencing.....</p>

<p>/**
 * Frame Differencing 
 * by Golan Levin. 
 *
 * GSVideo version by Andres Colubri.<br />
 * 
 * Quantify the amount of movement in the video frame using frame-differencing.
 */</p>

<p>import codeanticode.gsvideo.*;</p>

<p>int numPixels;
int[] previousFrame;
GSCapture video;</p>

<p>void setup() {
  size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
  // Uses the default video input, see the reference if this causes an error
  video = new GSCapture(this, width, height);
  video.start();<br />
  numPixels = video.width * video.height;
  // Create an array to store the previously captured frame
  previousFrame = new int[numPixels];
  loadPixels();
}</p>

<p>void draw() {
  if (video.available()) {
    // When using video to manipulate the screen, use video.available() and
    // video.read() inside the draw() method so that it's safe to draw to the screen
    video.read(); // Read the new frame from the camera
    video.loadPixels(); // Make its pixels[] array available</p>

<pre><code>int movementSum = 0; // Amount of movement in the frame
for (int i = 0; i &lt; numPixels; i++) { // For each pixel in the video frame...
  color currColor = video.pixels[i];
  color prevColor = previousFrame[i];
  // Extract the red, green, and blue components from current pixel
  int currR = (currColor &gt;&gt; 16) &amp; 0xFF; // Like red(), but faster
  int currG = (currColor &gt;&gt; 8) &amp; 0xFF;
  int currB = currColor &amp; 0xFF;
  // Extract red, green, and blue components from previous pixel
  int prevR = (prevColor &gt;&gt; 16) &amp; 0xFF;
  int prevG = (prevColor &gt;&gt; 8) &amp; 0xFF;
  int prevB = prevColor &amp; 0xFF;
  // Compute the difference of the red, green, and blue values
  int diffR = abs(currR - prevR);
  int diffG = abs(currG - prevG);
  int diffB = abs(currB - prevB);
  // Add these differences to the running tally
  movementSum += diffR + diffG + diffB;
  // Render the difference image to the screen
  pixels[i] = color(diffR, diffG, diffB);
  // The following line is much faster, but more confusing to read
  //pixels[i] = 0xff000000 | (diffR &lt;&lt; 16) | (diffG &lt;&lt; 8) | diffB;
  // Save the current color into the 'previous' buffer
  previousFrame[i] = currColor;
}
// To prevent flicker from frames that are all black (no movement),
// only update the screen if the image has changed.
if (movementSum &gt; 0) {
  updatePixels();
  println(movementSum); // Print the total amount of movement to the console
}
</code></pre>

<p>}
}</p>
]]></description>
   </item>
   <item>
      <title>Moving pixels a row at a time from multiple images to a single new image</title>
      <link>https://forum.processing.org/two/discussion/14450/moving-pixels-a-row-at-a-time-from-multiple-images-to-a-single-new-image</link>
      <pubDate>Thu, 14 Jan 2016 03:57:53 +0000</pubDate>
      <dc:creator>JeffG</dc:creator>
      <guid isPermaLink="false">14450@/two/discussions</guid>
      <description><![CDATA[<p>Not sure if the title describes this properly. I want to take say 100 images and extract a single row of pixels from each image and then reconstitute the images.</p>

<p>load initialPix1-100</p>

<p>get row 1 from each image and make finalpix_one from these rows</p>

<p>get row 2 from each image and make finalpix_two from these rows</p>

<p>get row 3 from each image and make finalpix_three from these rows</p>

<p><code>##########</code></p>

<p><code>void setup(){</code></p>

<p><code> size(400,400);
  img_one = loadImage("initial_one.jpg");
  img_two = loadImage("initial_two.jpg");
  img_three = loadImage("initial_three.jpg");</code></p>

<p><code>finalpix_one.set(0,0, initial_one.get(0,1,initial_one.width,1) );
   finalpix_one.set(0,1, initial_two.get(0,1,initial_two.width,1) );
   finalpix_one.set(0,2, initial_three.get(0,1,initial_three.width,1) );</code></p>

<p><code>finalpix_two.set(0,0, initial_one.get(0,2,initial_one.width,1) );
   finalpix_two.set(0,1, initial_two.get(0,2,initial_two.width,1) );
   finalpix_two.set(0,2, initial_three.get(0,2,initial_three.width,1) );</code></p>

<p><code>finalpix_three.set(0,0, initial_one.get(0,3,initial_one.width,1) );
   finalpix_three.set(0,1, initial_two.get(0,3,initial_two.width,1) );
   finalpix_three.set(0,2, initial_three.get(0,3,initial_three.width,1) );</code></p>

<p>My question is -- does this make sense or would it be easier to do this with pixels[] can anyone see an easy way to pick if this works with taking 2 rows at a time rather than a single row? If I keep spitting out to the final pix will it overwrite it or append like I want-- there has to be a way to do this that I am not seeing.</p>
]]></description>
   </item>
   <item>
      <title>Copy Matrix without linking them forever</title>
      <link>https://forum.processing.org/two/discussion/13541/copy-matrix-without-linking-them-forever</link>
      <pubDate>Tue, 17 Nov 2015 02:51:18 +0000</pubDate>
      <dc:creator>mraeclo</dc:creator>
      <guid isPermaLink="false">13541@/two/discussions</guid>
      <description><![CDATA[<p>Hey, how is it going?</p>

<p>Im doing an android app for making pixelArt. Im using 2 16x16 matrixes of a Pixel object. Basicaly, inside the object there is:
int x, y, tam;
color cor;
boolean pixel = false;</p>

<p>x and y are normal position values,
tam is the size of the square,
cor is the color of that pixel,
the boolan is because when its true it draws using a universal brush color, when false it draws using a universal background color.</p>

<p>So, what Im trying to implement is a button to copy matrix 1 to matrix 2 (remembering there are two 16x16 matrixes of this object). It only shows 1 matrix at a time, and the idea is to make 2 frames animations, so I need this feature so the user does not have to make the same draw two times just to change one small detail wich is gonna be animated.</p>

<p>I have tried some different ways and whats happening is that it does copy, but after copying they stay linked, and what ever change I draw in one is made instantly in the other. Here`s what Ive tried:</p>

<p>Matrix2 = Matrix1;</p>

<p>or</p>

<p>for (int i = 0; i &lt; 16; i++){
    for (int j = 0; j &lt; 16; j++){
  matrix2[i][j].pixel = matrix1[i][j].pixel;
  matrix2[i][j].cor = matrix1[i][j].cor;
}</p>

<p>or</p>

<p>arrayCopy(Matrix1, Matrix2);</p>

<p>all of them give the same result, instantly copies the matrix to the other, but when I change something and go back to the other, it has also changed the other, even without pressing to copy again.</p>

<p>I didnt paste the code because its too big, its already working for android and only this feature missing, posting the code would maybe distract from the problem (too many variables and other stuff unrelated to this problem) but if necessary Ill post. We can face this as a simple problem, when you use this comands above seems like it does not only copy the values between the matrixes but it link them and future changes affect one another.</p>
]]></description>
   </item>
   <item>
      <title>Another newb question on arrays flexibility?</title>
      <link>https://forum.processing.org/two/discussion/12723/another-newb-question-on-arrays-flexibility</link>
      <pubDate>Tue, 29 Sep 2015 08:52:26 +0000</pubDate>
      <dc:creator>PlzHelp</dc:creator>
      <guid isPermaLink="false">12723@/two/discussions</guid>
      <description><![CDATA[<p>this example is from the the orig processing book it uses custom function to transfer array data
I seem not to understand the application of this one: Page 311 Data 4: Arrays</p>

<pre lang="processing">
float[] data = { 19.0, 40.0, 75.0, 76.0, 90.0 };
float[] halfData;
void setup() {
halfData = halve(data); // Run the halve() function
println(data[0] + ", " + halfData[0]); // Prints "19.0, 9.5"
println(data[1] + ", " + halfData[1]); // Prints "40.0, 20.0"
println(data[2] + ", " + halfData[2]); // Prints "75.0, 37.5"
println(data[3] + ", " + halfData[3]); // Prints "76.0, 38.0"
println(data[4] + ", " + halfData[4]); // Prints "90.0, 45.0"
}

float[] halve(float[] d) {
float[] numbers = new float[d.length]; // Create a new array
arraycopy(d, numbers);
for (int i = 0; i &lt; numbers.length; i++) { // For each element,
numbers[i] = numbers[i] / 2; // divide the value by 2
}
return numbers; // Return the new array
} 
</pre>

<p>lame shortcut</p>

<pre><code>                float[] data = { 19.0, 40.0, 75.0, 76.0, 90.0 };
                void setup(){
                  for(int i = 0 ; i &lt;data.length ; i++){
                  float  x  = data[i] ;
                  float y  = data[i]/2 ; 
                   println(x,y);
                  }
                }
</code></pre>

<p>both gives same result ?
 what is the disadvantage of the shorter code ( lame "shortcut" ) would the orig code be flexible in any application ?</p>

<p>is array the most important aspect in creating good visual designs?
should i really be mastering it if I want to focus on making crazy designs (automated boom boom style?)</p>
]]></description>
   </item>
   <item>
      <title>Random videos displaying in different masks</title>
      <link>https://forum.processing.org/two/discussion/12609/random-videos-displaying-in-different-masks</link>
      <pubDate>Sun, 20 Sep 2015 23:22:03 +0000</pubDate>
      <dc:creator>aighis_</dc:creator>
      <guid isPermaLink="false">12609@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys! I'm just beginning with Processing, so this is probably something just easy that I still don't understand. Okay now the project: I am trying to make this player that randomize some videos to display them in three different mask (together they form a entire screen) with three different keyboard keys... The masks and, theoretically the random aspect are done, but I really can't figure out how to activate the masks with the keys without using the same array output (without using the same random picked video in all three masks)...And it really sounds complicated, but if someone could help me I would be eternally grateful.
(Windows 7/ Processing 2.2.1)</p>

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

    //Audio
    AudioPlayer player;
    Minim minim;//audio context

    //
    PImage mask1;
    PImage mask2;
    PImage mask3;

    //Array-random
    int maxMovies= 4;
    int rand = int(random(maxMovies)); 

    Movie[] myMovies=new Movie[maxMovies];
    ArrayList&lt;Movie&gt; moviesPlaying = new ArrayList&lt;Movie&gt;();


    void setup() {
      size (640, 480, P3D);
      frameRate(30);

      //sound
      minim = new Minim(this);
      player = minim.loadFile("cocoon.mp3", 2048);
      player.play();

      //masks
      mask1 = loadImage("center.jpg");
      mask2 = loadImage("left.jpg");
      mask3 = loadImage("right.jpg");

      for (int i = 0; i &lt; myMovies.length; i ++ ) {
        myMovies[i] = new Movie(this, i+".mov");
      }
    }

    void keyPressed() {

      if (key=='a') {
        rand = int(random(maxMovies));

        moviesPlaying.add(myMovies[rand]);
        moviesPlaying.get(moviesPlaying.size()-1).loop();
      }
    }

    void draw() {
      background(0);

      for (int i = 0; i&lt; moviesPlaying.size (); i++ ) {    
        Movie m = moviesPlaying.get(i);

        if (m.available())
          m.read();
        m.mask(mask1);
        image(m, 0, 0);
      }
    }

    void stop()
    {
      player.close();
      minim.stop();
      super.stop();
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>minim: moving up or down a selected part of the soundspectrum</title>
      <link>https://forum.processing.org/two/discussion/12123/minim-moving-up-or-down-a-selected-part-of-the-soundspectrum</link>
      <pubDate>Mon, 17 Aug 2015 11:48:52 +0000</pubDate>
      <dc:creator>bartlitz</dc:creator>
      <guid isPermaLink="false">12123@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>The last days I spent a lot of time trying to move down a selected part of the soundspectrum from the Line In of my soundcard. So that when there is a signal at 5 khz at the souncards input I wanna hear the same signal at a frequency of only 1 kHz at the output. The only idea I had  was to modifying the samples in an AudioSignal class. The result is that the frequency of the incoming signal is divided by 2, but there seem to be scheduling asynchronies or any other problem because the outgoing signal isn't clean. I would be grateful if anybody could help me to find any mistakes in my code or showing me another way to get a better result. So here is my code:</p>

<p><a rel="nofollow" href="http://www.bilder-upload.eu/show.php?file=2a522f-1439812069.jpg">bilder-upload.eu/show.php?file=2a522f-1439812069.jpg</a></p>
]]></description>
   </item>
   <item>
      <title>How do i copy out one row of a 2d array into a 1d array?</title>
      <link>https://forum.processing.org/two/discussion/12044/how-do-i-copy-out-one-row-of-a-2d-array-into-a-1d-array</link>
      <pubDate>Wed, 12 Aug 2015 14:26:32 +0000</pubDate>
      <dc:creator>rickhatfield</dc:creator>
      <guid isPermaLink="false">12044@/two/discussions</guid>
      <description><![CDATA[<p>what is the proper syntax for copying one row of a 2d array of integers into an existing 1d array? like if i have:</p>

<pre><code> int[][] stuff = {{1,2,3},{4,5,6},{7,8,9}};  
</code></pre>

<p>and i also have:</p>

<pre><code> int[] usethis = {0,0,0};  
</code></pre>

<p>and i want to copy one row of 'stuff' into 'usethis'.</p>

<p>logically it should be possible to do something like:</p>

<pre><code> usethis = new int[] {4,5,6};  
</code></pre>

<p>only copying it out of 'stuff', e.g.</p>

<pre><code> usethis = new int[] stuff[2];  
</code></pre>

<p>only that doesn't seem to work.</p>

<p>and i do NOT want to have to loop thru it element by element.  that would be entirely too stupid. is there a way?</p>
]]></description>
   </item>
   <item>
      <title>moving some particular frequency bands with minim's fft library</title>
      <link>https://forum.processing.org/two/discussion/12032/moving-some-particular-frequency-bands-with-minim-s-fft-library</link>
      <pubDate>Tue, 11 Aug 2015 04:44:34 +0000</pubDate>
      <dc:creator>bartlitz</dc:creator>
      <guid isPermaLink="false">12032@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I hope anybody here can help me. I am trying to write an application for decoding AM-Signals and SSB-Signals on shortwave delivered by an Direct Conversion Receiver. The library which I use for analyse the soundcards frequency spectrum is minim's fft-library. I now how to get the amplitude of  any frequency band an I know how to set the amplitude of any frequency band. I also know who to get the middle frequency of any frequency band, but I' am not able to move down some particular frequency bands in the sound spectrum.</p>

<p>This is what I tried, but it doesn't sound really good.</p>

<p>class InputOutputBind implements AudioSignal, AudioListener{
  private float[] leftChannel ;
  private float[] rightChannel;
 InputOutputBind(int sample){
    leftChannel = new float[sample];
    rightChannel= new float[sample];
  }
  // This part is implementing AudioSignal interface, see Minim reference
  void generate(float[] samp){
    arraycopy(leftChannel,samp);
  }
  void generate(float[] left, float[] right){
     arraycopy(leftChannel,left);
     arraycopy(rightChannel,right);
  }
 // This part is implementing AudioListener interface, see Minim reference
  synchronized void samples(float[] samp){<br />
     int index_band = 0;
     fft.forward(samp);
     for(int i = 0; i &lt; 1024; i++){
        if ((i &gt;= index_lsb) &amp;&amp; (i &lt; index_usb)){float bandanteil = fft.getBand(i); fft1.setBand(index_band, bandanteil * 10.0); index_band += 1;}
        else if (i &gt; index_usb){fft1.setBand(index_band, 0.0); index_band += 1;}
     }
     fft.inverse(samp);
     arraycopy(samp,leftChannel);
  }
  synchronized void samples(float[] sampL, float[] sampR){
    arraycopy(sampL,leftChannel);
    arraycopy(sampR,rightChannel);
  }<br />
}</p>
]]></description>
   </item>
   <item>
      <title>Kinect pixel array is flipped when copied to PGraphics?</title>
      <link>https://forum.processing.org/two/discussion/11370/kinect-pixel-array-is-flipped-when-copied-to-pgraphics</link>
      <pubDate>Fri, 19 Jun 2015 00:46:42 +0000</pubDate>
      <dc:creator>msp</dc:creator>
      <guid isPermaLink="false">11370@/two/discussions</guid>
      <description><![CDATA[<p>Hi all</p>

<p>Can someone please tell what I'm doing wrong here?</p>

<p>I'm <a rel="nofollow" href="https://github.com/msp/MspSyphonSceneImageBasic/blob/master/MspSyphonSceneImageBasic.pde#L82">copying the implicit canvas</a> (this.g) to my VDMXCanvas (PGraphics) and something is causing the pixels to be flipped 180 degrees - check the screenshot!</p>

<p>I've overlaid the VDMXCanvas at the bottom half of the screen so I can see the two together. Here's the patch:</p>

<p><a href="https://github.com/msp/MspSyphonSceneImageBasic/blob/master/MspSyphonSceneImageBasic.pde" target="_blank" rel="nofollow">https://github.com/msp/MspSyphonSceneImageBasic/blob/master/MspSyphonSceneImageBasic.pde</a></p>

<p>Any thoughts welcome!</p>

<p>Cheers</p>

<p>Matt</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/961/DTXEEOU6UGIW.jpg" alt="kinect-reverse" title="kinect-reverse" /></p>
]]></description>
   </item>
   </channel>
</rss>