<?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 getlinein() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=getlinein%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:58:46 +0000</pubDate>
         <description>Tagged with getlinein() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgetlinein%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to add a trigger to an oscilloscope program?</title>
      <link>https://forum.processing.org/two/discussion/28074/how-to-add-a-trigger-to-an-oscilloscope-program</link>
      <pubDate>Sat, 14 Jul 2018 06:52:29 +0000</pubDate>
      <dc:creator>8bit_coder</dc:creator>
      <guid isPermaLink="false">28074@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a very bare bones oscilloscope program using the minim library:</p>

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

Minim minim;
AudioInput in;
color white;

void setup()
{
  size(512, 100, P2D);
  white = color(255);
  colorMode(HSB,100);
  minim = new Minim(this);
  minim.debugOn();

  in = minim.getLineIn(Minim.STEREO, 512);
  background(0);
}

void draw()
{
  background(0);
  // draw the waveforms
  for(int i = 0; i &lt; in.bufferSize() - 1; i++)
  {
    stroke((1+in.left.get(i))*50,100,100);
    line(i, 50 + in.left.get(i)*50, i, 50 + in.left.get(i+1)*50);
  }
}


void stop()
{
  in.close();
  minim.stop();
  super.stop();
}
</code></pre>

<p>My question is, how do I make the waveform trigger/stabilize like an actual oscilloscope? I'm trying to figure that out so I can make the waveform stay at a certain spot so it doesn't jump around. Basically keep the waveform stable at all times.</p>

<p>Thanks for your help.</p>
]]></description>
   </item>
   <item>
      <title>Interactive video with sound input</title>
      <link>https://forum.processing.org/two/discussion/26401/interactive-video-with-sound-input</link>
      <pubDate>Sat, 17 Feb 2018 13:41:10 +0000</pubDate>
      <dc:creator>komats</dc:creator>
      <guid isPermaLink="false">26401@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I will soon have to make interactive video. As I know a little bit of Processing language, think I should use it for my project.</p>

<p>I have been searching for inspiration and found one of ideas (that might not be as complex for me as a beginer).</p>

<p>So the main question is this:</p>

<p>Is it possible in Processing to code smth like this:</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-sCaOy5VukCs"><span class="VideoPreview"><a href="http://youtube.com/watch?v=sCaOy5VukCs"><img src="http://img.youtube.com/vi/sCaOy5VukCs/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>The main idea is to make some black&amp;white background "come to life" with the sounds. The input sounds make random different blurry color splashes that stays for a while, but doesn't disappear very fast.</p>

<p>Would like to make it a bit complex by having those colorful flashes on top of some video.</p>

<p>Any tuts/videos on mind, where I could learn something similar?</p>
]]></description>
   </item>
   <item>
      <title>Minim sequencing play and record functions</title>
      <link>https://forum.processing.org/two/discussion/26337/minim-sequencing-play-and-record-functions</link>
      <pubDate>Tue, 13 Feb 2018 16:10:46 +0000</pubDate>
      <dc:creator>amycroft</dc:creator>
      <guid isPermaLink="false">26337@/two/discussions</guid>
      <description><![CDATA[<p>Hi Folks!</p>

<p>I've been working on a script where in very simple terms I would like a random beep to sound (Audioplayer beep - working!) and after that beep, a sequence of audio tracks to play (currently arranged in the array audio) and eventually audio recordings to be made (not set up yet).</p>

<p>My current issue is that</p>

<pre lang="javascript">audio[0].play(); </pre>

<p>is working perfectly but not then playing the second audio track. I've tried setting this up as a separate event (</p>

<pre lang="javascript">void playrecord()</pre>

<p>) and have found this thread very helpful to get the crux of the code from <a href="/two/profile/GoToLoop">@GoToLoop</a>: <a href="https://forum.processing.org/two/discussion/12966/how-to-play-an-audio-file-sequentially" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/12966/how-to-play-an-audio-file-sequentially</a>.</p>

<p>Ideally I would like to sequence it as audio 0 play, record audio input 0 through microphone, audio 1 play, record audio input 1 through microphone. All before the next "beep" sound is made.</p>

<p>Can anyone suggest what is going wrong?</p>

<hr />

<pre lang="javascript">
import ddf.minim.*;
import ddf.minim.AudioPlayer;
import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress otherSketch;

Minim minim;
AudioPlayer beep;

static final int AUDIO = 2;
final AudioPlayer[] audio = new AudioPlayer [AUDIO];
AudioInput daydream;
AudioRecorder[] recorder = new AudioRecorder [1];

PFont f;
int [] beeps = new int [5];
int ms;
int start = -millis();
int totalBeeps;
int beeptime;
boolean pressEnter;

int current=-1;
int count=0;
 
void setup() {
  size (512, 200, P3D);
  f= createFont ("Georgia", 16);
 
  boolean pressEnter = false;
  totalBeeps = 0;
 
  oscP5 = new OscP5(this,8001); /* start oscP5, listening for incoming messages at port 8001 */
  otherSketch = new NetAddress("xxxxxx",8000); /* Start listening at (IP Address, Port Number) */
  
 
  int fac=1000;
  beeps [0] = int(random(10, 60))*fac;//these numbers aren't right but give an earlier beep!
  beeps [1] = int(random(1260, 1739))*fac;
  beeps [2] = int(random(1860, 2339))*fac;
  beeps [3] = int(random(2460, 2939))*fac;
  beeps [4] = int(random(3060, 3539))*fac;
 
  printArray (beeps);
  
  minim = new Minim(this);
  audio [0] = minim.loadFile ("Audio_01.mp3");
  audio [1] = minim.loadFile ("Audio_02.mp3");
  
  minim = new Minim(this);
  daydream = minim.getLineIn();
 // recorder [0] = minim.createRecorder(daydream, "audio01.mp3");
  
  minim = new Minim(this);
  beep = minim.loadFile ("ping.mp3");
}
 
void keyPressed() { //boolean controlling the start screen.
  if (keyCode == ENTER) { 
    start = millis();
    pressEnter = true;
  }
}
 
void draw () {
 
  background (255);
  textFont (f, 16);
  fill (0);
 
  int ms = millis()-start;
 
  println(ms, start);
  
  startScreen();

  for (int i=0; i beeps[i] &amp;&amp; i&gt;current) {
      current=i;
      beeptime=millis();
      beep.rewind();
      beep.play();
      totalBeeps =totalBeeps+1;
      OscMessage myMessage = new OscMessage("time in milliseconds");
      myMessage.add(ms); 
      myMessage.add(millis()); 
      myMessage.add(beeptime); 
      myMessage.add(start); 
      oscP5.send(myMessage, otherSketch);       
playrecord();
    }
  } 
}

void startScreen(){
  
  if (pressEnter)//this boolean controls the start screen and initiates the timer -resetting millis to 0 when ENTER is pressed.
  {
    text("The experiment has begun and these are the random beep times:", 10, 40);
    text(beeps[0], 10, 70);
    text("milliseconds", 80, 70);
    text(beeps[1], 10, 90);
    text("milliseconds", 80, 90);
    text(beeps[2], 10, 110);
    text("milliseconds", 80, 110);
    text(beeps[3], 10, 130);
    text("milliseconds", 80, 130);
    text(beeps[4], 10, 150);
    text("milliseconds", 80, 150);
  } else {
    text("Press Enter to begin", 10, 100);
  }
 
  if (!pressEnter)
    return;
}

void playrecord(){
     audio[0].play();
     if (!audio[count].isPlaying()) audio[count=(count+1)% AUDIO].play(); 
}
</pre>
]]></description>
   </item>
   <item>
      <title>Simple Oscilloscope</title>
      <link>https://forum.processing.org/two/discussion/1129/simple-oscilloscope</link>
      <pubDate>Sun, 10 Nov 2013 10:33:40 +0000</pubDate>
      <dc:creator>Oolong</dc:creator>
      <guid isPermaLink="false">1129@/two/discussions</guid>
      <description><![CDATA[<p>The example code for Minim includes a program that displays the incoming waves, but it doesn't include a Trigger to stabilise the wave form. I needed something that worked a little bit more like an oscilloscope, so I made it start every displayed wave at a positive-slope zero-crossing, and while I was at it I changed the display to be a bit more like an oscilloscope. I hope this is useful for someone else too...</p>

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

Minim minim;
AudioInput in;

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

  minim = new Minim(this);

  // use the getLineIn method of the Minim object to get an AudioInput
  in = minim.getLineIn();
  println (in.bufferSize());
  // uncomment this line to *hear* what is being monitored, in addition to seeing it
  //in.enableMonitoring();
  background(0);
}

void draw()
{
  //background(0);
  fill (0, 32, 0, 32);
  rect (0, 0, width, height);
  stroke (32);
  for (int i = 0; i &lt; 11 ; i++){
    line (0, i*75, width, i*75);
    line (i*75+25, 0, i*75+25, height);
  }
  stroke (0);
  line (width/2, 0, width/2, height);
  line (0, height/2, width, height/2);
  stroke (128,255,128);
  int crossing=0;
  // draw the waveforms so we can see what we are monitoring
  for(int i = 0; i &lt; in.bufferSize() - 1 &amp;&amp; i&lt;width+crossing; i++)
  {
    if (crossing==0&amp;&amp;in.left.get(i)&lt;0&amp;&amp;in.left.get(i+1)&gt;0) crossing=i;
    if (crossing!=0){
      line( i-crossing, height/2 + in.left.get(i)*300, i+1-crossing, height/2 + in.left.get(i+1)*300 );
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to use system audio as an AudioInput for Minim</title>
      <link>https://forum.processing.org/two/discussion/25815/how-to-use-system-audio-as-an-audioinput-for-minim</link>
      <pubDate>Thu, 04 Jan 2018 15:10:45 +0000</pubDate>
      <dc:creator>SirHoneyBadger</dc:creator>
      <guid isPermaLink="false">25815@/two/discussions</guid>
      <description><![CDATA[<p>I'm making a audio visualizer which works really well except i have a huge issue with the audio input side. I can use <code>AudioInput in;</code>  along with <code>in = minim.getLineIn(Minim.STEREO)</code> which works but i have to make the stereo mix in the control panel to the default device, meaning i can't use my microphone anywhere else (like steam for instance - doesn't pick up the microphone).</p>

<p>Is there a way to get the audio input from the stereo mix without making it the default device?</p>
]]></description>
   </item>
   <item>
      <title>How to avoid my processing become really slow after one images array???</title>
      <link>https://forum.processing.org/two/discussion/25809/how-to-avoid-my-processing-become-really-slow-after-one-images-array</link>
      <pubDate>Thu, 04 Jan 2018 02:52:24 +0000</pubDate>
      <dc:creator>TricyQ</dc:creator>
      <guid isPermaLink="false">25809@/two/discussions</guid>
      <description><![CDATA[<p>import ddf.minim.*;</p>

<p>Minim minim;</p>

<p>AudioInput in;</p>

<p>PImage[] img = new PImage[4];</p>

<p>PImage[] blue = new PImage[31];</p>

<p>PVector player;</p>

<p>PVector velocity;</p>

<p>PVector leftHand;</p>

<p>float gravity = 0.1;</p>

<p>float r=100;</p>

<p>float force;</p>

<p>PImage body;</p>

<p>PImage zuo;</p>

<p>PImage zuoshou;</p>

<p>PImage you;</p>

<p>PImage youshou;</p>

<p>int n = 15;</p>

<p>PVector enemy[] = new PVector[n];</p>

<p>boolean show[] = new boolean[n];</p>

<p>boolean blink[] = new boolean[n];</p>

<p>int times[] = new int[n];</p>

<p>int count[] = new int[n];</p>

<p>boolean start = false;</p>

<p>boolean change = true;</p>

<p>boolean judge(int k) {</p>

<p>//int i=0;</p>

<p>for (int i=0; i&lt;k; i++) {</p>

<p>if (dist(enemy[k].x, enemy[k].y, enemy[i].x, enemy[i].y) &lt; 100) {</p>

<pre><code>  return true;
}
</code></pre>

<p>}
  return false;
}</p>

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

<p>size(1000, 1000);</p>

<p>frameRate(24);</p>

<p>velocity = new PVector(0, 0);</p>

<p>player = new PVector(width/2, height/2);</p>

<p>for (int i = 0; i &lt; n; i ++) {</p>

<pre><code>enemy[i] = new PVector(random(0, width), random(200, height/2));

while ((dist(width/2, height/2, enemy[i].x, enemy[i].y) &lt; 300)||judge(i)) {

  enemy[i] = new PVector(random(0, width), random(200, height/2));

}

show[i] = true;

blink[i] = false;

times[i] = 0;

count[i] = 0;
</code></pre>

<p>}</p>

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

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

<p>imageMode(CENTER);</p>

<p>body=loadImage("main.png");</p>

<p>//left arm</p>

<p>zuo=loadImage("zuo.png");</p>

<p>zuoshou=loadImage("zuoshou.png");</p>

<p>//right arm</p>

<p>you=loadImage("you.png");</p>

<p>youshou=loadImage("youshou.png");</p>

<p>//MY IMAGE ARRAY</p>

<p>for(int i=0;i&lt;blue.length;i++){</p>

<pre><code>String imageName = nf(i,3)+".png";

blue[i] = loadImage(imageName);
</code></pre>

<p>}</p>

<p>for (int i=0; i&lt;4; i++) {</p>

<pre><code>img[i] = loadImage(i%4+".png");
</code></pre>

<p>}</p>

<p>}</p>

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

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

<p>if (getLevel() &gt; 0.01) {</p>

<pre><code>start = true;
</code></pre>

<p>}</p>

<p>force = map(getLevel(), 0, 0.1, 0, 0.2);</p>

<p>force = constrain(force, 0, 0.2);</p>

<p>println(force, player.x, player.y, velocity.x, velocity.y);</p>

<p>r = map(getLevel(), 0, 0.1, 0.3, 0.5);</p>

<p>r = constrain(r, 0.3, 0.5);</p>

<p>for (int i = 0; i &lt; n; i ++) {</p>

<pre><code>if (blink[i]) {

  if (frameCount % 30 &lt; 15)

    fill(255, 209, 238);

  else fill(255);

  if (frameCount%30 == 29) {

    times[i] ++;

  }

  if (times[i]&gt;20) {

    blink[i] = false;

    times[i]=0;

  }

} else {

  fill(255, 209, 238);

}

if (show[i]) {

  image(img[i%4], enemy[i].x, enemy[i].y, height/20, height/20);

  println(i%4+".png"+i);

}else{

  pushMatrix();

  fill(0);

  //MY IMAGE ARRAY HERE&gt; 

  count[i]++;

  if(count[i] &gt;= blue.length)

    count[i]--;

  image(blue[count[i]],enemy[i].x, enemy[i].y,100,150);

  popMatrix();

}
</code></pre>

<p>}</p>

<p>drawPlayer();</p>

<p>}</p>

<p>void drawPlayer() {</p>

<p>if (abs(gravity)&lt;0.0005) {</p>

<pre><code>velocity.y = 0;
</code></pre>

<p>}
  //wald check edges</p>

<p>if (player.y &lt;= r*body.height/2) {</p>

<pre><code>velocity.y *= -1;
</code></pre>

<p>}</p>

<p>if (player.y&gt;=height-body.height*r) {</p>

<pre><code>if (force &lt; 0.01) {

  velocity.y *=-1;

}

if (change) {

  velocity.x = random(-8, 8);

  change = false;

}
</code></pre>

<p>}</p>

<p>if (player.x &gt;= width-r<em>body.width/2 || player.x &lt;= r</em>body.width/2) {</p>

<pre><code>velocity.x *= -1;
</code></pre>

<p>}</p>

<p>player.add(velocity);</p>

<p>if (start) {</p>

<pre><code>velocity.y += (gravity-force);

velocity.y -= 0.03*velocity.y/abs(velocity.y);
</code></pre>

<p>}</p>

<p>player.y = constrain(player.y, r<em>body.height/2, height-body.height</em>r);</p>

<p>player.x = constrain(player.x, r<em>body.width/2, width-r</em>body.width/2);</p>

<p>//pictures
  image(body, player.x, player.y, 369<em>r, 721</em>r);</p>

<p>float angle0 = atan2(mouseY-player.x, mouseX-player.y);</p>

<p>float leftHandx=0;</p>

<p>float leftHandy=90;</p>

<p>pushMatrix();</p>

<p>translate(player.x-40, player.y-50);</p>

<p>rotate(angle0);</p>

<p>image(zuo, 0, 50, 85<em>r, 306</em>r);</p>

<p>image(zuoshou, 0, 90, 180<em>r, 180</em>r);</p>

<p>leftHand = new PVector (leftHandx, leftHandy);</p>

<p>leftHand.x=leftHandx;</p>

<p>leftHand.y=leftHandy;</p>

<p>for (int i = 0; i &lt; n; i ++) {</p>

<pre><code>if ((dist(player.x, player.y-50, enemy[i].x, enemy[i].y) &lt; r*body.width/2) &amp;&amp; show[i]) {

  velocity.x *= -1;

  velocity.y *= -1;

  blink[i] = true;

  times[i] = 0;

  println(i);

}
</code></pre>

<p>}</p>

<p>for (int i = 0; i &lt; n; i ++) {</p>

<pre><code>if ((dist(player.x-40+90*sin(-angle0), player.y+40+90*cos(-angle0), enemy[i].x, enemy[i].y) &lt; 100) &amp;&amp; show[i]) {

  velocity.x *= -1;

  velocity.y *= -1;

  show[i] = false;  

  println("get"+i);

}
</code></pre>

<p>}</p>

<p>ellipse(leftHand.x, leftHand.y, 180<em>r, 180</em>r);</p>

<p>popMatrix();</p>

<p>float angle1 = atan2(mouseY-player.x, mouseY-player.y);</p>

<p>pushMatrix();</p>

<p>translate(player.x+40, player.y-50);</p>

<p>rotate(angle1);</p>

<p>image(you, 0, 50, 85<em>r, 306</em>r);</p>

<p>image(youshou, 0, 90, 180<em>r, 180</em>r);</p>

<p>popMatrix();
 }</p>

<p>float getLevel() {</p>

<p>float t = 0;</p>

<p>for (int i = 0; i &lt; in.bufferSize() - 1; i++) {</p>

<pre><code>t += abs(in.mix.get(i));
</code></pre>

<p>}</p>

<p>t /= in.bufferSize();</p>

<p>return t;</p>

<p>}</p>

<p>Hi,everyone,above are my coding part.Im kinda new with processing.I suppose it is because I loaded images in draw(),so it would load an image 60 times every second.But i don't know how to tackle that .
I would be really appreciate it if any of you guys help me out of it.Thanks!;)</p>
]]></description>
   </item>
   <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>(SOLVED)(Minim/Beads/Sound) How can I play back the LineIn signal (LineIn to LineOut)</title>
      <link>https://forum.processing.org/two/discussion/25399/solved-minim-beads-sound-how-can-i-play-back-the-linein-signal-linein-to-lineout</link>
      <pubDate>Tue, 05 Dec 2017 18:37:16 +0000</pubDate>
      <dc:creator>adriaano</dc:creator>
      <guid isPermaLink="false">25399@/two/discussions</guid>
      <description><![CDATA[<p>I wrote a music visualization which so far worked using the Minim library playing back mp3 files. Now I tried modifying it so that it would visualize an audio signal in real time. That way, I ran into a latency problem - the visuals are slightly out of sync with the sound (the problem gets less pronounced with buffer sizes as small as 128bits, however still very noticeable.)</p>

<p>Can I use an audio source other than my PC, connect it via LineIn to the processing sketch and play it back from there, so that the visualization and the playback have the same delay?</p>

<p>I tried achieving this using Beads, <a rel="nofollow" href="https://forum.processing.org/one/topic/minim-how-to-output-the-input-play-back-the-line-in-through-output.html">this</a> solution using Minim as well as its LiveInput class, but had issues with very glitchy audio playback in all cases.</p>

<p>The processing.sound library seems to handle that better, this bit of code seems to do exactly what I want:</p>

<blockquote class="Quote">
  <p>import processing.sound.*;</p>
  
  <p>AudioIn input;</p>
  
  <p>void setup() {
  <br />
      input = new AudioIn(this, 0);
      input.play();
  }</p>
  
  <p>void draw() {
      background(0);
  }</p>
</blockquote>

<p>However, I have experienced it to be very prone to crashing on Windows as soon as the code becomes slightly more complex than that (Target VM fails to initialize, reproducable with some of the included examples, the one most closely related to what I am trying to achieve would be FFTSpectrum), and it does not seem to be in active development anymore.</p>

<p>Is there any way to accomplish this only using Minim or is there a way to combine both libraries - using minim for the analysis and processing.sound for the playback?</p>
]]></description>
   </item>
   <item>
      <title>How can I put microphone value into an array and also filter microphone value</title>
      <link>https://forum.processing.org/two/discussion/25222/how-can-i-put-microphone-value-into-an-array-and-also-filter-microphone-value</link>
      <pubDate>Mon, 27 Nov 2017 04:51:08 +0000</pubDate>
      <dc:creator>nancyjou</dc:creator>
      <guid isPermaLink="false">25222@/two/discussions</guid>
      <description><![CDATA[<p>I want to do a project which is about  when saying something through microphone, and then can draw something (on Processing).</p>

<p>l watch Daniel Shiffman's video "17.9: Sound Visualization: Graphing Amplitude - p5.js",
<a rel="nofollow" href="https://www.youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s">https://youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s</a>,
but what I use is processing and pure data,
I have a question about  how to put those microphone value into an array in Processing, like the tutorial  in the video,
(the way of receive sound from microphone I use is Pure data, and I'm successfully connect pd and Processing), 
but I just don't know how to put those value into an array in processing,
and I guess the value also need to greater than a certain value 
because microphone will also receive value when is not saying.Thank you for your help!﻿</p>

<p>My Pure data and Processing sketch is here
<a rel="nofollow" href="https://github.com/nancyjou/Sound-Visualization">https://github.com/nancyjou/Sound-Visualization</a></p>

<p>and here is only my Processing sketch.</p>

<pre><code>float global1;
float global2;
float adc;
float fiddle;
float colorY;
float alphaX;

import netP5.*;
import oscP5.*;


OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
  size(800, 800);
  background(255);
  frameRate(25);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this, 12001);

  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}

void draw() {

  fiddle = global2;
  colorY= map(global2, 25, 150, 0, 360);
  alphaX= map(global1, 40, 250, 20, 255);
  fill(colorY, 100, 100);
  fill(colorY, 100, fiddle+50, alphaX);
  for (int y=200; y&lt;(height/4)+1; y+=10) {
    ellipse(width/2, random(0, 400), global1, global1);
    println(y);
  }
  adc = global1 + 10;
}


void mousePressed() {
  OscMessage myMessage = new OscMessage("/first");


  myMessage.add(123);
  myMessage.add(12.34);
  myMessage.add("some text");

  oscP5.send(myMessage, myRemoteLocation);
}  

void oscEvent(OscMessage theOscMessage) {

  if (theOscMessage.checkAddrPattern("/first")==true) {



    float firstValue = theOscMessage.get(0).floatValue();
    global1 = firstValue;
  }

  if (theOscMessage.checkAddrPattern("/second")==true) {



    float secondValue = theOscMessage.get(0).floatValue();
    global2 = secondValue;
  }
  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Changing colour of shapes over time</title>
      <link>https://forum.processing.org/two/discussion/25166/changing-colour-of-shapes-over-time</link>
      <pubDate>Thu, 23 Nov 2017 12:54:53 +0000</pubDate>
      <dc:creator>maltwhisker</dc:creator>
      <guid isPermaLink="false">25166@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>Now I'm very rusty with processing so I'm 100% sure I'm making some dumb mistakes here.</p>

<p>I'm trying to make the ellipses in this sketch change colour as they become older but I can't figure it out for the life of me!</p>

<p>Thanks in advance for any help/suggestions :)</p>

<p>See code here:</p>

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

Minim minim;
AudioInput in;
 float volume = 0;
float volumeF = 0;

   int maxParticles=1000; // max number of particles. real particles count depends on ppf and its lifetime
int addPPF=2;         // number of particles per frame added
ArrayList particles;

void setup(){
  size(900,900, P3D);
  frameRate(30);
  smooth();
  background(0);
  noStroke();
     minim = new Minim(this);
  minim.debugOn();

  // get a line in from Minim, default bit depth is 16
  in = minim.getLineIn(Minim.MONO, 512);


  particles = new ArrayList();
}

void draw(){
  background(0); // overpaint circles the frame before
  //  for(int i = 0; i &lt; 1; i++)
  //{
     volumeF = in.right.level()*1000;
  volume = 0.8*volume + 0.2*volumeF;
  if(particles.size()&lt;maxParticles){
    // add particle(s)
    for(int k=1; k&lt;= volume; k++){
      particles.add(new Particles());
    }
  }
  //}

  // run trought all Balls and make some action
  for(int j=0; j&lt;particles.size(); j++){
    Particles particle = (Particles)particles.get(j);
    // if particle still alive
    if( particle.alive() ){
      // update x/y positions
      particle.position();
      // now draw as cirle
      if( particle.lt &lt; 200 ) fill(20, 20, 20, particle.lt);
      else if(particle.lt &gt;= 200) fill(50, 50, 50, particle.lt);
      else if(particle.lt &gt;= 300) fill(100, 100, 100, particle.lt);
      else if(particle.lt &gt;= 400) fill(150, 150, 150, particle.lt);
      else if(particle.lt &gt;= 500) fill(200, 200, 200, particle.lt);
      else if(particle.lt &gt;= 600) fill(250, 250, 250, particle.lt);
      //stroke(random(100));
      ellipse(particle.x, particle.y, particle.r, particle.r);

  }else{
      // if lifetime is running out, delete
      particles.remove(j);
    }
  }
}


  void stop()
{
  // always close Minim audio classes when you are done with them
  in.close();
  minim.stop();

  super.stop();
}

public class Particles {
  float r, x, y, _x, _y, dx=0, dy=0, lt;

  // init start-values
  public Particles() {
    // start position center
    x=width/2;
    y=height/2;
    // now random values to make it non-linear
    lt=random(5,2000);       // lifetime in frames
    r=random(1, 4);        // circle Radius
    _x=random(-0.001, 0.001);    // stepwidth in x-pos (left, right)
    _y=random(-0.001, 0.001);    // stepwidth in y-pos (up, down)
  }

  public void position() {
    // stepwidth increases, circlespeed is exponential
    dx+=_x;
    dy+=_y;
    x+=dx;
    y+=dy;
  }

  public boolean alive(){
     if(lt&lt;=0){ return false; }else{ lt--; return true; }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Recognize a snare drum sound ?</title>
      <link>https://forum.processing.org/two/discussion/23155/recognize-a-snare-drum-sound</link>
      <pubDate>Wed, 21 Jun 2017 10:38:48 +0000</pubDate>
      <dc:creator>glhd2</dc:creator>
      <guid isPermaLink="false">23155@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>I am doing an project where I am displaying information on a snare drum only (not a all drum kit!). My goal is to give simple feedbacks to the user using a microphone as detection tool. My projection look like a clock and when the main hand reach a point, the player should hit the drum. I would like to detect if he hits the drum on time or not and if he hits the drum or not. 
My projection is in yellow on a black background, it will highlight in blue if he didn't hit on time and in red if he didn't hit the drum (or if he hits anything which is not the drum).</p>

<p>I tried with minim and beatdetect but unfortunatelly the "isSnare" doesn't work as it should be ... It returns true even if I am whistling or hitting my desk...</p>

<p>Should I go in an FFT analysis ? I am up for any advices .. I don't really know where to start.. Should I record the drum sound and then test in real-time if the hit is equal to the recorded sound?</p>

<p>Here is my code for now:</p>

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

Minim minim;
BeatDetect beat;
AudioInput in;


float eRadius;

void setup()
{
  size(200, 200, P3D);
  minim = new Minim(this);

  in = minim.getLineIn(Minim.STEREO, 512);
  // a beat detection object SOUND_FREQUENCY based on my mic
  beat = new BeatDetect(in.bufferSize(), in.sampleRate());

}

void draw()
{
  background(0);
  beat.detect(in.mix);

  println("isSnare: "+ beat.isSnare());
  //println("isHat: "+ beat.isHat());
  //println("isKick: " + beat.isKick());
  //println("isOnset: "+ beat.isOnset());

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make a word change to a different word every 10 seconds?</title>
      <link>https://forum.processing.org/two/discussion/22918/how-to-make-a-word-change-to-a-different-word-every-10-seconds</link>
      <pubDate>Sun, 04 Jun 2017 13:56:00 +0000</pubDate>
      <dc:creator>TypeCoding</dc:creator>
      <guid isPermaLink="false">22918@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>At the moment I have a word that reacts to sound input from an external mic. The title really explains what I'm looking to do. I've been looking at 'delay()' as a a possible way to change the word every 10 seconds, but I honestly don't know where to start. I've looked at tutorials and other threads to no avail.</p>

<p>I'm thinking I create a string of words I want the sketch to cycle through, but as to how I link that to time I don't know. Or is it a case of creating separate classes?</p>

<p>Thanks for any help or pointers to tutorials that could help me!</p>

<p>Here's what I've done so far:</p>

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

Minim minim; 
BeatDetect beat;
AudioInput in;
FFT fft;

float angle = 0;

PFont font1;
PFont font2;
PFont font3;


void setup()
{


  noCursor();
  fullScreen();
  smooth();
  minim = new Minim(this);
  in = minim.getLineIn();
  fft = new FFT(in.bufferSize(), in.sampleRate());

  frameRate(60);

  beat = new BeatDetect();
   beat.setSensitivity(100);


  font1=loadFont("Simplon.vlw");
  font2=loadFont("Simplon 50.vlw");
  font3=loadFont("Simplon 80.vlw");


}

void draw()
{
  noFill();
  background(255);
  fft.forward(in.mix);
  for (int i = 0; i &lt; in.mix.size() - 1; i++) {
    angle = radians(i);
     textFont(font3);
    textSize(80);
    textAlign(CENTER, CENTER);
    fill(0);
    text("John", 
    width/2 +1000 *cos(angle)*(10*in.mix.get(i)), 
    height/2 -1000 *sin(angle)*(10*in.mix.get(i)));
  }


}

void keyPressed() {

  if (key == 's') {
    saveFrame("wallpapers/wallpaper-####.tif");
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>I want the sound representing points to be vertical (See description)</title>
      <link>https://forum.processing.org/two/discussion/22608/i-want-the-sound-representing-points-to-be-vertical-see-description</link>
      <pubDate>Tue, 16 May 2017 06:22:20 +0000</pubDate>
      <dc:creator>mezbah</dc:creator>
      <guid isPermaLink="false">22608@/two/discussions</guid>
      <description><![CDATA[<p>I have modified a lot of code, added them up and came up with this..Here the sound representing points are presented in horizontal ..I want these points to be put vertical..But with this code I cant get my logic right..Any help?TIA..</p>

<pre><code>import ddf.minim.analysis.*;
import ddf.minim.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;


Minim minim;
AudioInput in;
FFT fft;
AudioPlayer song;
String str="X coordinate= || Y cordinate=";
ArrayList&lt;String&gt; times = new ArrayList();



// Configuration: spectrogram size (pixels)
int colmax = 500;
int rowmax = 250;
// Sample rate
float sampleRate = 22050;
// buffer size (= FFT size, must be power of 2)
int bufferSize = 1024;

// Variables
int[][] sgram = new int[rowmax][colmax];
int col;
int row;
int leftedge;
int topedge;
int window_len = bufferSize;
String timeHoover="";

PFont mono;


void setup()
{
  size(580, 250, P3D);
  textMode(SCREEN);
  textFont(createFont("SanSerif", 12));

  minim = new Minim(this);
  song = minim.loadFile("theMez.mp3", bufferSize);
  song.loop();
  // setup audio input
  //in = minim.getLineIn(Minim.MONO, bufferSize, sampleRate);

  fft = new FFT(song.bufferSize(), song.sampleRate());

  // suppress windowing inside FFT - we'll do it ourselves
  fft.window(FFT.NONE);
  times.add("");
}

void draw()
{
  background(0);
  stroke(255);
  strokeWeight(3);
  line(70, 0, 70, height);

  //song.play();
  // grab the input samples
  float[] samples = song.mix.toArray();
  // apply windowing
  for (int i = 0; i &lt; samples.length/2; ++i) {
    // Calculate &amp; apply window symmetrically around center point
    // Hanning (raised cosine) window
    float winval = (float)(0.5+0.5*Math.cos(Math.PI*(float)i/(float)(window_len/2)));
    if (i &gt; window_len/2)  winval = 0;
    samples[samples.length/2 - i] *= winval;
    samples[samples.length/2 + i] *= winval;
  }
  // zero out first point (not touched by odd-length window)
  samples[0] = 0; 

  // perform a forward FFT on the samples in the input buffer
  fft.forward(samples);

  // fill in the new column of spectral values
  for (int i = 0; i &lt; colmax /* fft.specSize() */; i++) {
    sgram[row][i] = (int)Math.round(Math.max(0, 2*20*Math.log10(1000*fft.getBand(i))));

  }

  // next time will be the next column
  row = row+1;
  // wrap back to the first column when we get to the end
  if (row == rowmax) { 
    row = 0;
  }

  // Draw points.
  // leftedge is the column in the ring-filled array that is drawn at the extreme left
  // start from there, and draw to the end of the array


  for (int i= 0; i&lt;colmax; i++)
  {
    for (int j=0; j&lt;row; j++)
    {
      stroke(sgram[j][i]);
      point(100+i,j);
     // l.add(sdf.format(cal.getTime()));

    }
  }



  //==============timePrinting
  mono = createFont("Verdana", 12);
  textFont(mono);
   if ( !times.get(0).equals("" + hour() + ":" + minute() + ":" + second())) {
    times.add(0, "" + hour() + ":" + minute() + ":" + second());
  }
 // println(times.size());
  while (times.size() &gt; 15) { 
    times.remove(15);
  }
  for ( int i = 0; i &lt; times.size(); i++) {
    text(times.get(i), 5,  20* i);

    if (times.get(i).length()&gt;0)
    {
      //timeHoover= times.get(i);
    stroke(255);
    strokeWeight(2);
    line(5,20*i+5,35,20*i+5);
    }

  }


  text(timeHoover,480,40);
  // Report window size
  //text(str, 8, 10);
}


void mousePressed()
{
  str="X cordinate = ";
  str += String.valueOf(mouseX);
  str+=" || Y cordinate = ";
  str+=String.valueOf(mouseY);
}

void mouseDragged() {
  // map mouse position within window to -1..1
  float proportion = map(mouseX, 0, colmax, -1, 0);
  // convert to window length, log scale, 2^8 range
  window_len = (int)Math.round(Math.pow(2.0, 4.0*proportion)*(float)bufferSize);
  text("asdffs",50,50);
}

void mouseMoved()
{

  int y = mouseY;
  int pos= mouseY/20;
  if (pos&lt;times.size())
  {
    timeHoover = times.get(pos);
    text(timeHoover,480,40);
  }
}


void stop()
{
  // always close Minim audio classes when you finish with them
  in.close();
  minim.stop();
  super.stop();
}
</code></pre>

<p>And this is the representation:
<img src="https://forum.processing.org/two/uploads/imageupload/168/RBRFBNYEXAWZ.PNG" alt="help" title="help" /></p>
]]></description>
   </item>
   <item>
      <title>Play an audioBuffer with Minim</title>
      <link>https://forum.processing.org/two/discussion/21874/play-an-audiobuffer-with-minim</link>
      <pubDate>Fri, 07 Apr 2017 09:17:45 +0000</pubDate>
      <dc:creator>JDev</dc:creator>
      <guid isPermaLink="false">21874@/two/discussions</guid>
      <description><![CDATA[<p>Im reading the microphone line in and storing the audiobuffer, is there a way to use AudioOutput to play what im recording without having to save it on the filesystem?</p>

<pre><code>    AudioInput in=minim.getLineIn();
    soundIn.add(in.mix);

    AudioOutput out=minim.getLineOut();
            //something like out.mix=soundIn.get(i);
</code></pre>
]]></description>
   </item>
   <item>
      <title>Minim getGain() only returns value -64</title>
      <link>https://forum.processing.org/two/discussion/21797/minim-getgain-only-returns-value-64</link>
      <pubDate>Tue, 04 Apr 2017 13:09:17 +0000</pubDate>
      <dc:creator>fagerli</dc:creator>
      <guid isPermaLink="false">21797@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to get the decibel level from the microphone on my laptop. I'm using Minim but if there's another simpler way please let me know.</p>

<p>This code only returns the value -64. What am i doing wrong?</p>

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

Minim minim;
AudioInput in;

void setup()
{
  minim = new Minim(this);
  minim.debugOn();


  in = minim.getLineIn(Minim.STEREO, 512);
}

void draw()
{
 println(in.getGain());  
}

void stop()
{

  in.close();
  minim.stop();

  super.stop();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Having trouble overlaying text on top of interactive background</title>
      <link>https://forum.processing.org/two/discussion/21477/having-trouble-overlaying-text-on-top-of-interactive-background</link>
      <pubDate>Sun, 19 Mar 2017 15:01:30 +0000</pubDate>
      <dc:creator>oddberg</dc:creator>
      <guid isPermaLink="false">21477@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
I am having trouble combining two codes I have.
The first one I want to have as a background while the second one (the text) should be on top of it.</p>

<p>I have tried combining them but of course it's not easy at it seem for a beginner like me, they either won't work at all or they don't work like the should.</p>

<p>This is not the only code that I am having trouble doing this with so I feel like I might be missing something.
Any help with the code or just pointing me to the right direction would be greatly appreciated!</p>

<p>Code I want to stay in the back but still be interactive:</p>

<pre><code>PShader sh;
String uid;

void setup() {
  PImage img = loadImage("test.jpg");

  size(img.width,img.height,P2D);
  background(0);

  // load and compile shader
  sh = loadShader("lens.glsl");
  // upload texture to graphics card
  sh.set("texture",img);
}

void draw() {
  // normalize mouse position
  float inpx = mouseX/(float)width;
  float inpy = mouseY/(float)height;

  // set shader variable
  sh.set("inp",inpx,inpy);

  // run shader
  shader(sh);

  // fill whole window
  rect(0,0,width,height);
}
</code></pre>

<p>And the text code:</p>

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

Minim mySound; //CREATE A NEW SOUND OBJECT
AudioInput in;

RFont font;
String myText = "TEST";

void setup() {
  size(1500, 400);
  background(255);
  smooth();
  RG.init(this); 
  font = new RFont("FreeSans.ttf", 100, CENTER);

  mySound = new Minim(this);
  in = mySound.getLineIn(Minim.STEREO,512);
}

void draw() {
  background(255);
  strokeWeight(2);
  stroke(255, 0, 0);
  noFill();
  translate(width/2, height/1.5);

  float soundLevel = in.mix.level(); //GET OUR AUDIO IN LEVEL

  RCommand.setSegmentLength(soundLevel*9000);
  RCommand.setSegmentator(RCommand.UNIFORMLENGTH);

  RGroup myGoup = font.toGroup(myText); 
  RPoint[] myPoints = myGoup.getPoints();

  beginShape(QUAD_STRIP);
  for (int i=0; i&lt;myPoints.length; i++) {

    vertex(myPoints[i].x, myPoints[i].y);
  }
  endShape();
}
</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>Why doesn't work MUTE with boolean in my code?</title>
      <link>https://forum.processing.org/two/discussion/20467/why-doesn-t-work-mute-with-boolean-in-my-code</link>
      <pubDate>Wed, 25 Jan 2017 17:00:09 +0000</pubDate>
      <dc:creator>Sly97</dc:creator>
      <guid isPermaLink="false">20467@/two/discussions</guid>
      <description><![CDATA[<p>Hey!
I'm having trouble to using .mute(); with boolean. As you can see in the code, I want to make processing to mute all my sounds when i hit 'k', and unmute them when I hit 'k' again. It's very important for me to make this program. When i do it with .pause() and .play(), it works, but it's not good for me, because i want to run these sounds in loop. I hope that u guys can help me. Here's my code: (on the start of the draw, wehere my problem is)   (Btw.: sorry for my bad english)
Thx</p>

<pre><code>import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;

Minim m;
AudioInput in;
AudioPlayer hera;
AudioPlayer time;
AudioPlayer hotlinebling;
AudioPlayer kemosabe;


boolean onOff = false;
boolean pOn = false;

void setup() {
  size(640, 360);
  background(255);

  m = new Minim(this);
  hera = m.loadFile("1.mp3");
  hera.loop();

  time = m.loadFile("2.mp3");
  time.loop();

  hotlinebling = m.loadFile("hbt.mp3");
  hotlinebling.loop();


  kemosabe = m.loadFile("4.mp3");
  kemosabe.loop();

  in = m.getLineIn(Minim.MONO, 2048);
}      

void draw() {

  if (onOff == false) {
    kemosabe.mute();
    time.mute();
    hera.nmute();
    hotlinebling.mute();

    //Mikrofon 
    if (keyPressed) {
      if (key == 'p' &amp;&amp; !pOn) {
        if (random(0, 6) &lt; 3) {
          in.enableMonitoring();
        } else {
          in.disableMonitoring();
        }
        println(in.isMonitoring());
        pOn = true;
      }
    } else {
      pOn = false;
      in.disableMonitoring();
    }
  } else {
    kemosabe.unmute();
    hera.unmute();
    hotlinebling.unmute();
    time.unmute();
  }

  //Hera koka hallatszik 
  if (keyPressed ) {
    if (key=='0') 
      time.mute();
  } else {
    time.unmute();
  }

  if (keyPressed ) {
    if (key=='0') 
      kemosabe.mute();
  } else {
    kemosabe.unmute();
  }

  if (keyPressed ) {
    if (key=='0') 
      hotlinebling.mute();
  } else {
    hotlinebling.unmute();
  }

  //I've had hallatszik 
  if (keyPressed ) {
    if (key=='2') 
      hera.mute();
  } else {
    hera.unmute();
  }

  if (keyPressed ) {
    if (key=='2') 
      kemosabe.mute();
  } else {
    kemosabe.unmute();
  }

  if (keyPressed ) {
    if (key=='2') 
      hotlinebling.mute();
  } else {
    hotlinebling.unmute();
  }

  //Hotline bling
  if (keyPressed ) {
    if (key=='5') 
      hera.mute();
  } else {
    hera.unmute();
  }

  if (keyPressed ) {
    if (key=='5') 
      kemosabe.mute();
  } else {
    kemosabe.unmute();
  }

  if (keyPressed ) {
    if (key=='5') 
      time.mute();
  } else {
    time.unmute();
  }

  //Kemosabe hallatszik 
  if (keyPressed ) {
    if (key=='8') 
      hera.mute();
  } else {
    hera.unmute();
  }

  if (keyPressed ) {
    if (key=='8') 
      time.mute();
  } else {
    time.unmute();
  }

  if (keyPressed ) {
    if (key=='8') 
      hotlinebling.mute();
  } else {
    hotlinebling.unmute();
  }
}

void keyPressed() {
  if (key == 'm') {
   onOff = !onOff;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Record audio from Arduino with Minim.</title>
      <link>https://forum.processing.org/two/discussion/19963/record-audio-from-arduino-with-minim</link>
      <pubDate>Wed, 28 Dec 2016 14:09:39 +0000</pubDate>
      <dc:creator>danxerik</dc:creator>
      <guid isPermaLink="false">19963@/two/discussions</guid>
      <description><![CDATA[<p>Hello.
I am new to Processing and somewhat new to programming.</p>

<p>I want to use Processing to record sound from and Arduino with an Adafruit Electret Microphone Amplifier and have problem with the code. I haven't been able to find any tutorial so I looked in to the example <em>Serial &gt; Simple read</em> and <em>Minim &gt; Basic &gt; RecordAudioInput</em> and tried to put them together.</p>

<p>What I am trying to do is to read the value from the serial and use it as the value for sound (was that clear?). Here is the code</p>

<p>I am using Processing 3.2.3 and latest Minim lib.</p>

<p>Am I on the right track? Thanks in advance. 
Daniel</p>

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

Serial myPort;  // Create object from Serial class
int val;      // Data received from the serial port

Minim minim;
AudioInput in;  // &lt;---------This is the current input from the computer I need it from Serial (probably 'val')
AudioRecorder recorder;

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

  String portName = Serial.list()[1];
  myPort = new Serial(this, portName, 9600);

  minim = new Minim(this);

  in = minim.getLineIn();
  // create a recorder that will record from the input to the filename specified
  // the file will be located in the sketch's root folder.
  recorder = minim.createRecorder(in, "myrecording.wav");

  textFont(createFont("Arial", 12));
}

void draw()
{
  background(0); 
  stroke(255);
    if ( myPort.available() &gt; 0) {  // If data is available,
    val = myPort.read();         // read it and store it in val
  }
  // 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
  for(int i = 0; i &lt; in.bufferSize() - 1; i++)
  {
    line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
    line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
  }

  if ( recorder.isRecording() )
  {
    text("Currently recording...", 5, 15);
  }
  else
  {
    text("Not recording.", 5, 15);
  }
}

void keyReleased()
{
  if ( key == 'r' ) 
  {
    // to indicate that you want to start or stop capturing audio data, you must call
    // beginRecord() and endRecord() on the AudioRecorder object. You can start and stop
    // as many times as you like, the audio data will be appended to the end of the buffer 
    // (in the case of buffered recording) or to the end of the file (in the case of streamed recording). 
    if ( recorder.isRecording() ) 
    {
      recorder.endRecord();
    }
    else 
    {
      recorder.beginRecord();
    }
  }
  if ( key == 's' )
  {
    // we've filled the file out buffer, 
    // now write it to the file we specified in createRecorder
    // in the case of buffered recording, if the buffer is large, 
    // this will appear to freeze the sketch for sometime
    // in the case of streamed recording, 
    // it will not freeze as the data is already in the file and all that is being done
    // is closing the file.
    // the method returns the recorded audio as an AudioRecording, 
    // see the example  AudioRecorder &gt;&gt; RecordAndPlayback for more about that
    recorder.save();
    println("Done saving.");
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Live Audio Translating Into Hue Change</title>
      <link>https://forum.processing.org/two/discussion/18837/live-audio-translating-into-hue-change</link>
      <pubDate>Wed, 02 Nov 2016 02:10:52 +0000</pubDate>
      <dc:creator>lbrez16</dc:creator>
      <guid isPermaLink="false">18837@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone!</p>

<p>So for this assignment I have to take either an audio file or live audio input and have it translate to a hue change on a photo! Overall it seems pretty simple but I'm stuck on how to put the information in to change the hue. I've inserted what I have so far below.</p>

<pre><code>    import ddf.minim.*;
    import ddf.minim.signals.*;
    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    PImage img;

    Minim minim;
    AudioInput in;

    void setup()
    {
        img = loadImage("Ash.jpg");
        size( 540, 687 );
        smooth();

        minim = new Minim( this );

        in = minim.getLineIn( Minim.STEREO, 512 );

        background(img);
    }

    void draw()
    {
    }
    void stop()
    {
        in.close();
        minim.stop();
        super.stop();
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>create a line using an audio sample</title>
      <link>https://forum.processing.org/two/discussion/17385/create-a-line-using-an-audio-sample</link>
      <pubDate>Sat, 02 Jul 2016 03:40:23 +0000</pubDate>
      <dc:creator>alanmartinsegal</dc:creator>
      <guid isPermaLink="false">17385@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to create a lineal drawing using the sound information from an audio sample or the computer internal mic.
I did this script but I'm just getting a straight line. Any ideas?</p>

<p>thanks!</p>

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

Minim minim;
AudioInput in;

float x;
float y;
float px;
float py;
float vel; 
float dir; 

void setup(){
  size(400,400);
  stroke(0);
  background(255);
  smooth();
  frameRate(30);

  x=y=px=py=200;


  vel = random(5);  
  dir = random(360);  

  minim = new Minim(this);

  in = minim.getLineIn();
}

void draw(){
  px = x;
  py = y;

  x += cos(radians(dir)) * vel;
  y += sin(radians(dir)) * vel;

  stroke(0);
  line(px,py,x,y);

  float value = 0;

  for(int i = 0; i &lt; in.bufferSize() - 1; i++) {
      value += in.mix.get(i);      
  }
  value /= in.bufferSize();
  dir += random(-30, 30) * value ;
}

void stop() {
  minim.stop();
  super.stop();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to process more than one audio inputs?</title>
      <link>https://forum.processing.org/two/discussion/16800/how-to-process-more-than-one-audio-inputs</link>
      <pubDate>Tue, 24 May 2016 12:47:13 +0000</pubDate>
      <dc:creator>ShyshyDai</dc:creator>
      <guid isPermaLink="false">16800@/two/discussions</guid>
      <description><![CDATA[<p>Hi all. First time here send message :)
I'm very interested in《Messa di voce》( <span class="VideoWrap"><span class="Video YouTube" id="youtube-STRMcmj-gHc"><span class="VideoPreview"><a href="http://youtube.com/watch?v=STRMcmj-gHc"><img src="http://img.youtube.com/vi/STRMcmj-gHc/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span> ),but I don't know how to      process more than one audio inputs with Minim just like what the video shows(two kinds of sound inputs control the motion trail in different places separately).
The programming below is from the example of Minim. How to change it so I can create two kinds of inputs? Or there are maybe some other ways?
////////////////////////////////////////////////////////////////////////
import ddf.minim.*;</p>

<p>Minim minim;
AudioInput in;</p>

<p>void setup()
{
  size(512, 200, P3D);</p>

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

<p>// use the getLineIn method of the Minim object to get an AudioInput
  in = minim.getLineIn();
}
&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;&#92;\
Poor expression maybe. Thank you ：)</p>
]]></description>
   </item>
   <item>
      <title>Conversly play input from mic</title>
      <link>https://forum.processing.org/two/discussion/15407/conversly-play-input-from-mic</link>
      <pubDate>Thu, 10 Mar 2016 15:24:33 +0000</pubDate>
      <dc:creator>digitalsmoke</dc:creator>
      <guid isPermaLink="false">15407@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>Is it possible, with the help of processing, to take INPUT from the microphone and play the data conversly in realtime.</p>
]]></description>
   </item>
   <item>
      <title>FFT code for audio spectrum analyzer</title>
      <link>https://forum.processing.org/two/discussion/13785/fft-code-for-audio-spectrum-analyzer</link>
      <pubDate>Sat, 05 Dec 2015 06:58:47 +0000</pubDate>
      <dc:creator>Glassjaw0</dc:creator>
      <guid isPermaLink="false">13785@/two/discussions</guid>
      <description><![CDATA[<p>Hey, 
I'm currently making the spectrum analyzer off this website.
<a href="http://www.instructables.com/id/Arduino-Processing-Audio-Spectrum-Analyzer/" target="_blank" rel="nofollow">http://www.instructables.com/id/Arduino-Processing-Audio-Spectrum-Analyzer/</a>
I'm using a different LED screen, Mine is a 16x32 from adafruit. 
I've changed and got my arduino portion of the code to work but
I'm getting an error that I'm unfamiliar with from processing. 
I read some people had issues with this project trying to upload the code to processing
3 because originally it was programmed on processing 1. Im running 1.5.1.</p>

<p>Any help is much appreciated!</p>

<p>The line of code causing the problem is:</p>

<p><code>port = new Serial(this, Serial.list()[1],9600); //set baud rate</code></p>

<p>This is the error I'm receiving:</p>

<blockquote class="Quote">
  <p>WARNING:  RXTX Version mismatch
    Jar version = RXTX-2.2pre1
    native lib Version = RXTX-2.2pre2
  Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 1
    at Audio_Spectrum_to_Arduino3216_doublebar_pde.setup(Audio_Spectrum_to_Arduino3216_doublebar_pde.java:68)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)</p>
</blockquote>

<p>Here is the entire code:</p>

<pre><code>                            import ddf.minim.analysis.*;
                            import ddf.minim.*;
                            import processing.serial.*; //library for serial communication

                            Serial port; //creates object "port" of serial class

                            Minim minim;
                            AudioInput in;
                            FFT fft;
                            float[] peaks;

                            int peak_hold_time = 1;  // how long before peak decays
                            int[] peak_age;  // tracks how long peak has been stable, before decaying

                            // how wide each 'peak' band is, in fft bins
                            int binsperband = 5;
                            int peaksize; // how many individual peak bands we have (dep. binsperband)
                            float gain = 40; // in dB
                            float dB_scale = 2.0;  // pixels per dB

                            int buffer_size = 1024;  // also sets FFT size (frequency resolution)
                            float sample_rate = 44100;

                            int spectrum_height = 176; // determines range of dB shown

                            int[] freq_array = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
                            int i,g;
                            float f;


                            float[] freq_height = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};  //avg amplitude of each freq band

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

                              minim = new Minim(this);
                              port = new Serial(this, Serial.list()[1],9600); //set baud rate

                              in = minim.getLineIn(Minim.MONO,buffer_size,sample_rate);

                              // create an FFT object that has a time-domain buffer 
                              // the same size as line-in's sample buffer
                              fft = new FFT(in.bufferSize(), in.sampleRate());
                              // Tapered window important for log-domain display
                              fft.window(FFT.HAMMING);

                              // initialize peak-hold structures
                              peaksize = 1+Math.round(fft.specSize()/binsperband);
                              peaks = new float[peaksize];
                              peak_age = new int[peaksize];
                            }


                            void draw()
                            {
                            for(int k=0; k&lt;16; k++){
                            freq_array[k] = 0;
                            }

                              // perform a forward FFT on the samples in input buffer
                              fft.forward(in.mix);

                            // Frequency Band Ranges      
                              freq_height[0] = fft.calcAvg((float) 0, (float) 50);
                              freq_height[1] = fft.calcAvg((float) 51, (float) 69);
                              freq_height[2] = fft.calcAvg((float) 70, (float) 94);
                              freq_height[3] = fft.calcAvg((float) 95, (float) 129);
                              freq_height[4] = fft.calcAvg((float) 130, (float) 176);
                              freq_height[5] = fft.calcAvg((float) 177, (float) 241);
                              freq_height[6] = fft.calcAvg((float) 242, (float) 331);
                              freq_height[7] = fft.calcAvg((float) 332, (float) 453);
                              freq_height[8] = fft.calcAvg((float) 454, (float) 620);
                              freq_height[9] = fft.calcAvg((float) 621, (float) 850);
                              freq_height[10] = fft.calcAvg((float) 851, (float) 1241);
                              freq_height[11] = fft.calcAvg((float) 1242, (float) 1600);
                              freq_height[12] = fft.calcAvg((float) 1601, (float) 2200);
                              freq_height[13] = fft.calcAvg((float) 2201, (float) 3000);
                              freq_height[14] = fft.calcAvg((float) 3001, (float) 4100);
                              freq_height[15] = fft.calcAvg((float) 4101, (float) 5600);


                            // Amplitude Ranges  if else tree
                              for(int j=0; j&lt;16; j++){    
                                if (freq_height[j] &lt; 200000 &amp;&amp; freq_height[j] &gt; 200){freq_array[j] = 16;}
                                else{ if (freq_height[j] &lt;= 300 &amp;&amp; freq_height[j] &gt; 150){freq_array[j] = 15;}
                                else{ if (freq_height[j] &lt;= 250 &amp;&amp; freq_height[j] &gt; 125){freq_array[j] = 14;}
                                else{ if (freq_height[j] &lt;= 200 &amp;&amp; freq_height[j] &gt; 100){freq_array[j] = 13;}
                                else{ if (freq_height[j] &lt;= 160 &amp;&amp; freq_height[j] &gt; 90){freq_array[j] = 12;}
                                else{ if (freq_height[j] &lt;= 150 &amp;&amp; freq_height[j] &gt; 75){freq_array[j] = 11;}
                                else{ if (freq_height[j] &lt;= 140 &amp;&amp; freq_height[j] &gt; 65){freq_array[j] = 10;}
                                else{ if (freq_height[j] &lt;= 120 &amp;&amp; freq_height[j] &gt; 50){freq_array[j] = 9;}
                                else{ if (freq_height[j] &lt;= 50 &amp;&amp; freq_height[j] &gt; 45){freq_array[j] = 8;}
                                else{ if (freq_height[j] &lt;= 45 &amp;&amp; freq_height[j] &gt; 40){freq_array[j] = 7;}
                                else{ if (freq_height[j] &lt;= 40 &amp;&amp; freq_height[j] &gt; 35){freq_array[j] = 6;}
                                else{ if (freq_height[j] &lt;= 35 &amp;&amp; freq_height[j] &gt; 30){freq_array[j] = 5;}
                                else{ if (freq_height[j] &lt;= 30 &amp;&amp; freq_height[j] &gt; 15){freq_array[j] = 4;}
                                else{ if (freq_height[j] &lt;= 15 &amp;&amp; freq_height[j] &gt; 10){freq_array[j] = 3;}
                                else{ if (freq_height[j] &lt;= 10 &amp;&amp; freq_height[j] &gt; 5){freq_array[j] = 2;}
                                else{ if (freq_height[j] &lt;= 5 &amp;&amp; freq_height[j] &gt;= 1 ){freq_array[j] = 1;}
                                else{ if (freq_height[j] &lt; 1 ){freq_array[j] = 0;}
                              }}}}}}}}}}}}}}}}}

                              //send to serial
                              port.write(0xff); //write marker (0xff) for synchronization

                              for(i=0; i&lt;16; i++){
                                port.write((byte)(freq_array[i]));
                              }
                              //delay(2); //delay for safety
                            }


                            void stop()
                            {
                              // always close Minim audio classes when you finish with them
                              in.close();
                              minim.stop();

                              super.stop();
                            }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Dots to move back when they reach bottom of the screen</title>
      <link>https://forum.processing.org/two/discussion/13081/dots-to-move-back-when-they-reach-bottom-of-the-screen</link>
      <pubDate>Sun, 18 Oct 2015 02:07:33 +0000</pubDate>
      <dc:creator>honzojd</dc:creator>
      <guid isPermaLink="false">13081@/two/discussions</guid>
      <description><![CDATA[<p>Hello, wouldn't someone of you know how to make those lines return back when they reach bottom? and then go again down? please</p>

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

Minim minim;
AudioPlayer track;
AudioInput in;


float bpm = 80;
float mspb = 54000/bpm;
float x = 0;
float y = 0;
float x1 =0;
float x2 =0;
float y2 =0;
float y1 =0;
float R_x =0;
float R_y =0;

float line_height = 1;
int time = 0;

void setup()
{
  fullScreen(P2D);
  background(255);
  strokeWeight(0);
  frameRate(20);
  smooth();
  minim = new Minim(this);
  track = minim.loadFile("alno.mp3", 2048);
  in = minim.getLineIn(Minim.STEREO, 1024);
  track.loop();

}


void draw() {
  int lapse = millis();
  for (int i = 0; i &lt; track.left.size()-1; i++) {
    x1 = x;
    x2 = x;
    y1 = track.left.get(i);
    y2 = track.left.get(i+1);
    fill(0,abs(track.left.get(i))*255);
    noStroke();
    ellipse(x, y,lapse % abs(track.left.get(i))*10,lapse % abs(track.left.get(i))*10);
    x+=abs(track.left.get(i)+7);
  }



if (lapse &gt; mspb || x &gt; width ) {
    time = millis();
    y += 6;
    x = 0;
    if (y &gt; height){
    y = 0;
  }  
  }

}

void stop(){

  track.close();
  minim.stop();
  super.stop();

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Code modification for Audio Input - Please help ASAP</title>
      <link>https://forum.processing.org/two/discussion/12983/code-modification-for-audio-input-please-help-asap</link>
      <pubDate>Tue, 13 Oct 2015 14:45:19 +0000</pubDate>
      <dc:creator>CVaughan</dc:creator>
      <guid isPermaLink="false">12983@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
So I'm modifying some code created by this guy here - <a href="http://www.controllerism.com/controllerism-how-to-interactive-visuals-with-processing" target="_blank" rel="nofollow">http://www.controllerism.com/controllerism-how-to-interactive-visuals-with-processing</a> 
It's some cool coding that allows visuals to react to a combo of MIDI controller inputs and audio input. No I'm trying to take the visualizer element and allow it to just react to Audio Input but can't get the code to produce the visualizer! Looking to fix this v.quickly as there is a live event where I'd like to demonstrate it!</p>

<p>My modified code is this (I am aware I haven't created an option for switching scenes yet):</p>

<pre><code>// Tomash Ghz - tomashg.com
// Ableton synced visuals in Processing Tutorial

import ddf.minim.*; // Iport the Minim Library for sound input

Minim minim; // Create instances of Minim
AudioInput in;


int scene=1; // Keep track of the current scene
int shape=1; // and shape

color backgroundCol=0; // Store the background color
color strokeCol=255; // Store the shape outile color

float soundWeight; // Store the sound volume weight

void setup() { // Setup function runs only once when the sketch starts. Initialize everything here
  size(1280, 768); // Set the window size

  noFill(); // Will draw only outline of shapes
  rectMode(CENTER); // Set the rectangle origin to its center
  colorMode(HSB, 360, 100, 100); // Set the color values to Hue Saturation Brightness instead of Red Green Blue
  smooth(8); // Draw smooth shapes

  minim = new Minim(this); // Create a new Minim class for sound input
  in = minim.getLineIn(Minim.STEREO, 2048, 192000.0);  // Enable 
}

void draw() { // Draw function runs every frame. Update everything and draw on the screen
  soundWeight=in.mix.level()*20; // Read the audio input and scale the value
  drawScene(); // Draw the visuals
}


void drawScene(){ // A function we use to draw different things according to the current scene
  switch(scene){ // We only have 4 scenes here
    case 0:
      background(0); // set the background black
      break;
    case 1:
      background(backgroundCol); // just draw the background with its color
      break;
    case 2:
      drawShapes(0); //draw static shapes over the background
      break;
    case 3:
      drawShapes(soundWeight); //draw shapes that scale to the incoming volume levels. We pass the sound weight as the size value
      break;
  }
}

void randomColors(){ // A function we use to change randomly the colors
    backgroundCol=color(random(127,255),50,50); // Set a random color for the background with a hue from 127 to 255
    strokeCol=color(random(0,126),100,100);; // Set a random color for the outlines with a hue from 0 to 126
}

void drawShapes(float size){ // A function we use to draw a shape according to the current shape
  background(backgroundCol); // First draw the background
  stroke(strokeCol); // Set the outline color
  pushMatrix();
  translate(width/2,height/2); // Start drawing from the center of the screen

  switch(shape%3){ // We only have 3 shapes so lets sycle through them. We add the size value
    case 0: 
      rect(0,0,width/4+size*width/8,width/4+size*width/8); // Draw a square
      break;
    case 1:
      ellipse(0,0,width/4+size*width/8,width/4+size*width/8); // Draw a circle
      break;
    case 2:
      triangle(-width/8-size*width/16,width/8+size*width/16,0,-width/8-size*width/16,width/8+size*width/16,width/8+size*width/16); // Draw a triangle
      break;
  }
  popMatrix();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Error while using Minim in Processing 2.2.1</title>
      <link>https://forum.processing.org/two/discussion/11948/error-while-using-minim-in-processing-2-2-1</link>
      <pubDate>Mon, 03 Aug 2015 12:26:54 +0000</pubDate>
      <dc:creator>elunicotomas</dc:creator>
      <guid isPermaLink="false">11948@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>I've just downloaded Processing 2.2.1 and I'm trying to get the Minim library to work but with no success.</p>

<p>Even with this simple/ example code I get an error.</p>

<p>Code:</p>

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

Minim minim;
AudioPlayer player;
AudioInput input;

void setup()
{
  size(100, 100);

  minim = new Minim(this);
  player = minim.loadFile("protection.mp3");
  input = minim.getLineIn();
}

void draw()
{
  // do what you do
}
</code></pre>

<p>Error:</p>

<p><img src="http://i.imgur.com/vmFXTDe.png" alt="" /></p>

<p>==== JavaSound Minim Error ====
==== Unable to return a TargetDataLine: unsupported format - PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian</p>

<p>=== Minim Error ===
=== Minim.getLineIn: attempt failed, could not secure an AudioInput.</p>

<p>Any ideas?????</p>

<p>Thanks!</p>

<p>I'm on Windows 7 64bits and just updated to Java Version 8 Update 51.
The file <em>protection.mp3</em> is in a folder named <em>data</em> in the sketch folder.</p>
]]></description>
   </item>
   <item>
      <title>Minim not working on P2D</title>
      <link>https://forum.processing.org/two/discussion/10932/minim-not-working-on-p2d</link>
      <pubDate>Thu, 21 May 2015 11:39:48 +0000</pubDate>
      <dc:creator>animatek</dc:creator>
      <guid isPermaLink="false">10932@/two/discussions</guid>
      <description><![CDATA[<p>Hello all!</p>

<p>here my first question in the forum, i´m trying to draw a audio reactive lines on screen using the minim library, and all works fine, but when i use the P2D or P3D in the size function that stop working.</p>

<p>using the 2.2.1 version of processing not work.
using the 1.5.1 version of processing it works.</p>

<p>what can i do?</p>

<p>thnxs in advance, sorry for the bad english..</p>

<p>here´s the code:</p>

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

//Reactivo
Minim minim;
AudioInput in;
float eyey = 300;

void setup() {
  size (500, 500,P2D);// it does not work
  // size (500, 500,P2D);// is working

  //Minim entrada de audio
  minim = new Minim(this);
  in = minim.getLineIn();
  background(0);
}

void draw() {
  difumina(0, 10);

  llora(100);
  llora(200);
  llora(300);
}

void mousePressed() {
  background(0);
}

void llora( float _y){


 for (int i = 0; i &lt; in.bufferSize () - 1; i++)
  {
    //Variables waveform
    float x1 = map(i, 0, in.bufferSize(), 0, width);

    stroke(255, 255);
    line(x1, _y+ in.right.get(i)*500, x1, _y+ in.right.get(i)*500);
  }



}

//Función fondo pantalla
void difumina(color c, float al) {

  fill(c, al);

  rect (-2, -2, width +10, height +10);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Fade effect</title>
      <link>https://forum.processing.org/two/discussion/10917/fade-effect</link>
      <pubDate>Wed, 20 May 2015 20:24:54 +0000</pubDate>
      <dc:creator>SimplyEnvision</dc:creator>
      <guid isPermaLink="false">10917@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
I'm trying to get my animation to appear smoother, so I thought I'd take the previous frame and paint it with some transparency onto the current frame. I have done this in another animation, and I pretty much copied it onto this one, so I'm doing something wrong and I can't see it. Also, for some reason translate(width/2, height/2); won't work if written in setup(), which I thought was a bit strange. It would make sense to be able to do the translation only once at the beginning, right?</p>

<p>Here's my code so far:</p>

<pre><code>PImage fade;

void setup(){

  size(1280, 720, P3D);
  smooth();


  fade = get(0, 0, width, height);


}

void draw(){  

  background(0);
  tint( 255, 255, 255, 254);
  translate(width/2, height/2);

  image(fade, -width/2, -height/2);
  noTint();


  colorMode(HSB, 100);


  filter.paintCircle(bassDominantFreq, 1);
  filter.paintCircle(midsDominantFreq, 2);
  filter.paintCircle(trebleDominantFreq, 3);

  fade = get(-width/2, -height/2, width/2, height/2);


}
</code></pre>

<p>Now, as far as I understand, the coordinates should be correct: top left corner would be -width/2, -height/2, and lower right corner would be width/2, height/2.</p>

<p>Any ideas?</p>
]]></description>
   </item>
   <item>
      <title>Constant Volume/Spectrum Range with Minim</title>
      <link>https://forum.processing.org/two/discussion/10885/constant-volume-spectrum-range-with-minim</link>
      <pubDate>Tue, 19 May 2015 02:27:11 +0000</pubDate>
      <dc:creator>KyleMac</dc:creator>
      <guid isPermaLink="false">10885@/two/discussions</guid>
      <description><![CDATA[<p>Hey,
As I said in my previous post, I am making a spectrum analyzer. One thing that is bothering me is that the height/sensitivity of the spectrum analyzer is directly related to the volume of my computer. If I turn the volume up, the spectrum analyzers minimum height increases. Same if I mute my computer, nothing will show on the spectrum analyzer. Is there a way to create a range within the analyzer where the audio input will be mapped between a min and max value so that it wont matter if my computer is muted or on maximum? I'm using minim.getLineIn to get my audio source . 
Thanks</p>
]]></description>
   </item>
   </channel>
</rss>