<?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 isplaying() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=isplaying%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:56:58 +0000</pubDate>
         <description>Tagged with isplaying() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedisplaying%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Exported Application Troubles</title>
      <link>https://forum.processing.org/two/discussion/27831/exported-application-troubles</link>
      <pubDate>Mon, 23 Apr 2018 20:27:53 +0000</pubDate>
      <dc:creator>mlehman6</dc:creator>
      <guid isPermaLink="false">27831@/two/discussions</guid>
      <description><![CDATA[<p>I have my code working well enough, but not I'm having troubles... implementing it. I can manually start my .exe by double-clicking it, but I can't open it through the command prompt or Windows Task Scheduler. Other applications (Notepad, Word, Processing) open through these channels, just not my Processing code exported as an executable file. Any idea if this problem stems from my code or anything Processing related? Here's the code if it helps:</p>

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

Minim minim;
AudioPlayer stand;
AudioPlayer sit;
AudioPlayer move;

int lf = 10; 
String myString = null;
Serial myPort;   
int sensorValue = 0;

void setup() {

  printArray(Serial.list());

  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();

  myString = myPort.readStringUntil(lf);
  myString = null;

  minim = new Minim(this);

  stand = minim.loadFile("stand.mp3"); 
  sit = minim.loadFile("sit.mp3");
  move = minim.loadFile("move.mp3");
}

void draw() {

  while (myPort.available() &gt; 0) {

    myString = myPort.readStringUntil(lf);

    if (myString != null) {
      myString = myString.trim();   

      if(myString.length() &gt; 0) {
        println(myString);              
        }

      if(myString.equals("sit")){
            move.pause();
            stand.pause();
            sit.rewind();
            sit.play();

            if(sit.isPlaying() == true)  {
              println("Sound");
            }

        }        
      if(myString.equals("stand")){
            sit.pause();
            move.pause();
            stand.rewind();
            stand.play();

            if(stand.isPlaying() == true)  {
              println("Sound");
            }

        }        
      if(myString.equals("move")){
            stand.pause();
            sit.pause();
            move.rewind();
            move.play();

            if(move.isPlaying() == true)  {
              println("Sound");
            }

        }
      }
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to play random sound file when clicking an item within a scrollable list (controlP5 library)?</title>
      <link>https://forum.processing.org/two/discussion/27834/how-to-play-random-sound-file-when-clicking-an-item-within-a-scrollable-list-controlp5-library</link>
      <pubDate>Mon, 23 Apr 2018 23:28:42 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27834@/two/discussions</guid>
      <description><![CDATA[<p>I'm using the 'scrollableList' from the controlP5 library. I wish to simply play a random sound file each time I click an element on the scrollable list, without pausing.</p>

<p>I have tried a few things. I am having limited success with some code from <a href="/two/profile/akenaton">@akenaton</a> that I found in this thread:
<a rel="nofollow" href="https://forum.processing.org/two/discussion/8949/how-do-i-play-a-random-audio-sample">https://forum.processing.org/two/discussion/8949/how-do-i-play-a-random-audio-sample</a></p>

<p>I merged that code with the scrollable list. So far, I'm only managing to pause the audio on clicking the menu. I am probably missing something obvious.</p>

<p>As ever, any tips much appreciated :)</p>

<pre><code>import ddf.minim.*;
import controlP5.*;
import java.util.*;
AudioPlayer player;
Minim minim;
ControlP5 cp5;

boolean playeurInit = false;// que leplayer n'est pas lancé
boolean stop = true;

String[] table = {"train1.wav", "train2.wav"};

int randomWav; 
String wav; 

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

  minim = new Minim(this);
  int randomWav = int(random(table.length));
  String son = table[randomWav];
  //println(son);
  player = minim.loadFile(son);
  player.pause();   

  cp5 = new ControlP5(this);
  List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
  cp5.addScrollableList("dropdown").setPosition(10, 10).setSize(200, 100).setBarHeight(20).setItemHeight(20).addItems(l);   
}


void draw() {
  background(240);
  if (!stop) {
    if (player.isPlaying() == false) {
          randomWav = int(random(table.length));
          println(randomWav);
          wav = table[randomWav];
          player = minim.loadFile(wav);
          player.play();
          player.loop();//you can change that!
          playeurInit = true;
     }
  }
}


void dropdown(int n) {
  if(stop == true)
  {
    stop = false;
  }else{
    stop = true;
    player.play();
    if (player.isPlaying() == true ) 
    {
      player.pause();
      //player.play();
    }
  }

  CColor c = new CColor();
  c.setBackground(color(255,0,0));
  cp5.get(ScrollableList.class, "dropdown").getItem(n).put("color", c);
}


void stop(){
  player.close();
  minim.stop();
  super.stop();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I get sound to fade in and out depending on your location?</title>
      <link>https://forum.processing.org/two/discussion/27718/how-can-i-get-sound-to-fade-in-and-out-depending-on-your-location</link>
      <pubDate>Sat, 07 Apr 2018 19:15:18 +0000</pubDate>
      <dc:creator>karinalopez87</dc:creator>
      <guid isPermaLink="false">27718@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I was able to make my sound play and stop with Kinect but it doesn't loop or fade out. I want my sound to continue playing with the video and just fade in if the interaction is activated and fade out when the interaction is no longer happening. Also, I want my sound to loop.</p>

<pre><code>     import processing.sound.*;
     import org.openkinect.processing.*;
     import processing.video.*;


    Movie vid;
    Movie vid1;
    SoundFile sound1;
    SoundFile sound2;
    Kinect2 kinect2;

    //PImage depthImg;
    //PImage img1;

    //pixel
    int minDepth=0;
    int maxDepth=4500; //4.5m

    boolean off = false;

    void setup() {
      size(1920,1080);
      //fullScreen();
      vid = new Movie(this, "test_1.1.mp4");
      vid1 = new Movie(this, "test_1.1.mp4");
      sound1 = new SoundFile(this, "cosmos.mp3");
      sound2 = new SoundFile(this, "NosajThing_Distance.mp3");

      //MOVIE FILES
          //01.MOV
          //03.MOV
          //02.mov (File's too big)
          //Urban Streams.mp4
          //HiddenNumbers_KarinaLopez.mov
          //test_w-sound.mp4
          //test_1.1.mp4
          //test005.mov
      //SOUND FILES      
          //cosmos.mp3
          //NosajThing_Distance.mp3

      vid.loop();
      vid1.loop();
      kinect2 = new Kinect2(this);
      kinect2.initDepth();
      kinect2.initDevice();
    //depthImg = new PImage(kinect2.depthWidth, kinect2.depthHeight);
    //img1 = createImage(kinect2.depthWidth, kinect2.depthHeight, RGB);
    }

    void movieEvent(Movie vid){
      vid.read();
      vid1.read();
    }


    void draw() { 
      vid.loadPixels();
      vid1.loadPixels();

      //image(kinect2.getDepthImage(), 0, 0);

        int[] depth = kinect2.getRawDepth();

      float sumX=0;
      float sumY=0;
      float totalPixels=0;

        for (int x = 0; x &lt; kinect2.depthWidth; x++){
          for (int y = 0; y &lt; kinect2.depthHeight; y++){
            int offset = x + y * kinect2.depthWidth;
            int d = depth[offset];

            if ( d &gt; 0 &amp;&amp; d &lt; 1000){
          //    //video.pixels[offset] = color(255, 100, 15);
          sumX +=x;
          sumY+=y;
          totalPixels++;
             brightness(0);
            } else {
          //    //video.pixels[offset] = color(150, 250, 180);
              brightness(255);
            }      }
        }
    vid.updatePixels();
    vid1.updatePixels();

    float avgX = sumX/totalPixels;
    float avgY=sumY/totalPixels;


    //VID 01 - Screen 01
    if (avgX&gt;300 &amp;&amp; avgX&lt;500){
    tint(255, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==0){
    sound2.play(0.5);
    sound2.amp(0.5);
    }
    }else{
    tint(0, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==1){
     delay(1);
    //IT DIMS THE VOLUME TO 0 BUT IT DOESN'T GO BACK TO VOLUME 0.5 [sound2.amp(0.5);]
     sound2.amp(0);
     }
    }
     //VID 02 - Screen 01
     if (avgX&gt;50 &amp;&amp; avgX&lt;200){
    tint(255, (avgX)/3);
    image(vid, 0-(1920/2), 0);
    }else{
       tint(0, (avgX)/3);
       image(vid, 0-(1920/2), 0);
     }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Beginner Question: How to Build Sound Player that Creates &amp; Plays Random mp3 Playlist?</title>
      <link>https://forum.processing.org/two/discussion/27620/beginner-question-how-to-build-sound-player-that-creates-plays-random-mp3-playlist</link>
      <pubDate>Sun, 01 Apr 2018 20:55:01 +0000</pubDate>
      <dc:creator>sammy</dc:creator>
      <guid isPermaLink="false">27620@/two/discussions</guid>
      <description><![CDATA[<p>Hello! I'm a musician and <em>complete</em> programming noob. Thanks for making this space so welcoming! I'm trying to wrap my head around a sound project I'm working on. I welcome any direction you can provide.</p>

<p>Basically, I'm trying to create web-based sound player that, when clicked, plays a randomized playlist of sound files. I'm imagining that to create this, I'll use a variant on this p5 Load and Play Sound code (<a rel="nofollow" href="https://p5js.org/examples/sound-load-and-play-sound.html" title="Load and Play Sound">link</a>). Other stuff I'll need, in addition to the components in the example, (I'm guessing) will be:</p>

<ul>
<li><p>A set of mp3s in a folder.</p></li>
<li><p>Calling these mp3s somehow, maybe with <code>random()</code>.</p></li>
<li><p>Either triggering each new mp3 from the end of the previous mp3, or assembling them in order when the player is clicked.</p></li>
</ul>

<p>Does that sound right? Any general or specific recommendations about how to make this happen?</p>

<p>Thanks a lot!</p>
]]></description>
   </item>
   <item>
      <title>Playing audio files from a playlist with Minin</title>
      <link>https://forum.processing.org/two/discussion/26805/playing-audio-files-from-a-playlist-with-minin</link>
      <pubDate>Tue, 13 Mar 2018 12:02:52 +0000</pubDate>
      <dc:creator>JBradley</dc:creator>
      <guid isPermaLink="false">26805@/two/discussions</guid>
      <description><![CDATA[<p>I have an application where audio ques are selected from a playlist (array). Minin has an example of just playing a single file. I am confused on how to declare and setup these file arrays. Which variable has the arry? Can you point me to an example?
Thanks</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>trigger Sound when Mouse is Over a Ellipse</title>
      <link>https://forum.processing.org/two/discussion/25910/trigger-sound-when-mouse-is-over-a-ellipse</link>
      <pubDate>Thu, 11 Jan 2018 10:15:56 +0000</pubDate>
      <dc:creator>delmenhorst</dc:creator>
      <guid isPermaLink="false">25910@/two/discussions</guid>
      <description><![CDATA[<p>Hey.
Im looking for a solution to trigger soundfiles.</p>

<p>I want that the mouse trigger random soundfiles just with moving in the browser.
Can anyone help me that is my code. 
I tried many stuff.
Thanks!!!! If anyone can help me.</p>

<pre>
var positionen = 50;
var buttons = [];
var songs = [];
var totalSongs = 9;
var lieder = [];
var tunes = [];

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}


function setup() {
  createCanvas(windowWidth, windowHeight);

  var protection = 0;

  while (lieder.length &lt; positionen) {
    var lied = {
      x: random(width),
      y: random(height),
      r: random(6, 150)
    }

    var overlapping = false;
    for (var j = 0; j &lt; lieder.length; j++) {
      var other = lieder[j];
      var d = dist(lied.x, lied.y, other.x, other.y);
      if (d &lt; lied.r + other.r) {
        overlapping = true;
      }
    }
    if (!overlapping) {
      lieder.push(lied);
    }

    protection++;
    if (protection &gt; 10000) {
      break;
    }
  }

  for (var z = 0; z &lt; totalSongs; z++) {
    ton(z, 'assets/dorrbell-00' + z + '.mp3');
  }
  for (var i = 0; i &lt; lieder.length; i++) {
    buttons[i] = new Button(i, lieder[i].x, lieder[i].y, (lieder[i].r * 1.5));
  }

}


function ton(index, filename) {
  loadSound(filename, soundLoaded);

  function soundLoaded(sound) {
    songs[index] = sound;
    for (var u = 0; u &lt; buttons.length; u++) {
      randomSound(u, random(songs));
    }
  }
}

function randomSound(index, tune) {
  tunes[index] = tune;
}

function draw() {
  background(255);
  for (var i = 0; i &lt; buttons.length; i++) {
    //buttons[i].playSound(mouseX, mouseY);
    buttons[i].display(mouseX, mouseY);

  }
}


// function mouseMoved() {
//   for (var i = 0; i &lt; buttons.length; i++) {
//     if (buttons[i].contains(mouseX, mouseY) &amp;&amp; !tunes[i].isPlaying()) {
//       tunes[i].playMode('restart');
//       tunes[i].setVolume(1);
//       tunes[i].play();
//     } else {
//       //tunes[i].setVolume(0, 1);
//       //tunes[i].stop();
//     }
//   }
// }

var Button = function(i_, x_, y_, r_) {
  var x = x_;
  var y = y_;
  var r = r_;
  var mouseisOver = false;

  this.contains = function(mx, my) {
    if (dist(mx, my, x, y) &lt; r) {
      return true;
    } else {
      return false;
    }
  };

  this.display = function(mx, my) {
    if (this.contains(mx, my)) {
      mouseisOver = true;
      fill(100);
    }
    if (!this.contains(mx, my)) {
      fill(175);
      mouseisOver = false;
    }
    print(mouseisOver);
    noStroke(0);
    ellipse(x, y, r, r);
  };

  // // this.playSound = function(mx, my) {
  // //   (buttons[i].contains(mouseX, mouseY) &amp;&amp; !tunes[i].isPlaying()){
  //      tunes[i].playMode('restart');
  //       tunes[i]].play();
  //       tunes[i].setVolume(1,2);
  //       tunes[i].play();
  //     } else {
  //       //tunes[i].setVolume(0, 1);
  //       //tunes[i].stop();
  //   }
  // };

}
</pre>
]]></description>
   </item>
   <item>
      <title>tell is a soundFile is playing</title>
      <link>https://forum.processing.org/two/discussion/25818/tell-is-a-soundfile-is-playing</link>
      <pubDate>Thu, 04 Jan 2018 16:38:14 +0000</pubDate>
      <dc:creator>bridgetbaird</dc:creator>
      <guid isPermaLink="false">25818@/two/discussions</guid>
      <description><![CDATA[<p>using the sound processing library</p>
]]></description>
   </item>
   <item>
      <title>Minim Sound Stops Playing After A While</title>
      <link>https://forum.processing.org/two/discussion/25423/minim-sound-stops-playing-after-a-while</link>
      <pubDate>Wed, 06 Dec 2017 21:00:46 +0000</pubDate>
      <dc:creator>mlehman6</dc:creator>
      <guid isPermaLink="false">25423@/two/discussions</guid>
      <description><![CDATA[<p>So I found a sample code that I altered that reads my Arduino through the serial port and plays several different sounds that tell me to either sit, stand, or move. I've added rewind, so the sounds play more than once, but after several hours the sounds no longer play. Does that functionality time out? I added a few lines to print if the program thinks the song is playing and that all goes through fine. I would appreciate any help because I would like to not have to restart this program several times throughout the day.</p>

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

import ddf.minim.*;


Minim minim;

AudioPlayer stand;

AudioPlayer sit;

AudioPlayer move;

AudioPlayer bitch;

AudioPlayer beep;


int lf = 10; 

String myString = null;

Serial myPort; 

int sensorValue = 0;


void setup() {


  printArray(Serial.list());


  myPort = new Serial(this, Serial.list()[0], 9600);

  myPort.clear();

  myString = myPort.readStringUntil(lf);

  myString = null;

  minim = new Minim(this);


  stand = minim.loadFile("stand.mp3"); 

  sit = minim.loadFile("sit.mp3");

  move = minim.loadFile("move.mp3");

  bitch = minim.loadFile("bitch.mp3");

  beep = minim.loadFile("beep.mp3");

}


void draw() {

  while (myPort.available() &gt; 0) {

    myString = myPort.readStringUntil(lf);

    if (myString != null) {

      myString = myString.trim();  

      if(myString.length() &gt; 0) {

        println(myString);      

        }

      if(myString.equals("sit")){

            println("sound");

            beep.rewind();

            sit.rewind();

            beep.play();

            delay(800);

            sit.play();

            if (sit.isPlaying() == true){

              println("sound2");

            }

        }      

      if(myString.equals("stand")){

            println("sound");

            beep.rewind();

            stand.rewind();

            beep.play();

            delay(800);

            stand.play();

            if (stand.isPlaying() == true){

              println("sound2");

            }

        }     

      if(myString.equals("move")){

            println("sound");

            beep.rewind();

            move.rewind();

            bitch.rewind();

            beep.play();

            delay(800);

            move.play();

            delay(550);

            bitch.play();

            if (bitch.isPlaying() == true){

              println("sound2");

            }

            }

          }

    }

  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Infinite loop?</title>
      <link>https://forum.processing.org/two/discussion/25057/infinite-loop</link>
      <pubDate>Fri, 17 Nov 2017 01:49:22 +0000</pubDate>
      <dc:creator>LaxOfBayDay</dc:creator>
      <guid isPermaLink="false">25057@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on an audio sample machine using minim. I want one player to pause another and I've gotten the timer to stop but does anyone know why this snippet causes a loop my app can't get out of?.</p>

<pre><code>while(Ads[i].isPlaying()){
        if (Ads[i].position()==Ads[i].length()) {
        Ads[i].pause();
        }
       savedTime=millis();
     }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to customize button appearance or make button an image?</title>
      <link>https://forum.processing.org/two/discussion/24546/how-to-customize-button-appearance-or-make-button-an-image</link>
      <pubDate>Sat, 14 Oct 2017 16:44:49 +0000</pubDate>
      <dc:creator>Clova</dc:creator>
      <guid isPermaLink="false">24546@/two/discussions</guid>
      <description><![CDATA[<p>I need to to make an audio file play when clicking a button, such as in Dan Schiffman's example: 
var song;
var button;</p>

<p>function setup() {
  createCanvas(200, 200);
  song = loadSound("rainbow.mp3", loaded);
  button = createButton("play");
  button.mousePressed(togglePlaying);
  background(51);
}</p>

<p>function togglePlaying() {
  if (!song.isPlaying()) {
    song.play();
    song.setVolume(0.3);
    button.html("pause");
  } else {
    song.stop();
    button.html("play");
  }
}</p>

<p>function loaded() {
  console.log("loaded");
}</p>

<p>However, what if I wanted the button to be red instead of grey, or circular instead of rectangular, or larger? Or positioned somewhere specific? Or more preferably, how could I replace the button with an image that plays the song when clicked? 
I need multiple buttons, and I want them all to look different and play different audio files when clicked.</p>

<p>I've already seen examples where you can click ellipses to change the color or something, but I can't find or figure out how to make it work specifically for audio. I'm extremely new to p5.js and don't understand much of it.</p>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>HELP! How to play different audio files in one sketch?</title>
      <link>https://forum.processing.org/two/discussion/23256/help-how-to-play-different-audio-files-in-one-sketch</link>
      <pubDate>Thu, 29 Jun 2017 12:30:31 +0000</pubDate>
      <dc:creator>Bellschen</dc:creator>
      <guid isPermaLink="false">23256@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,
On one hand, I'm trying to play 10 different audio files in one sketch with minim. On the other hand, I need the program to ignore every following mouse press if the player is playing until its done. However, I dont get how to set up the "false" command. I would be so happy if someone could take a look at my sketch and help me out! Thanks a lot.</p>

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

Minim minim;
AudioPlayer[] player;

String[] SONGS = {"Fact01.mp3", "Fact02.mp3", "Fact04.mp3", "Fact05.mp3", "Fact06.mp3", "Fact07.mp3", "Fact08.mp3", "Fact09.mp3", "Fact10.mp3"};

void setup() {
  size(200, 200, P3D);
  minim = new Minim(this);
    player= new AudioPlayer[10];

  for (int i=0; i&lt;SONGS.length; i++) {
    player[i] = minim.loadFile(SONGS[i]);
  }
}

void draw() {
  background(0);
}

void mousePressed() {

  if(player.isPlaying()==false){
  }

  int v=int(random(SONGS.length));
  player[v].rewind();
  player[v].play();
</code></pre>
]]></description>
   </item>
   <item>
      <title>Processing Sound - isPlaying() returns int instead of boolean</title>
      <link>https://forum.processing.org/two/discussion/22998/processing-sound-isplaying-returns-int-instead-of-boolean</link>
      <pubDate>Fri, 09 Jun 2017 13:52:09 +0000</pubDate>
      <dc:creator>einraum</dc:creator>
      <guid isPermaLink="false">22998@/two/discussions</guid>
      <description><![CDATA[<p>In the src files and in the github repo the isPlaying function of the processing sound library returns a boolean. It seems that there is no current compiled library in the contribution manager. (the change to boolean instead of integer as return type has been months ago in github). 
I need to get the current compiled library version or the src files of the version that is in the contribution manager because I need to extend the SoundFile class for further functionality.</p>
]]></description>
   </item>
   <item>
      <title>Song code to work p5.js</title>
      <link>https://forum.processing.org/two/discussion/21393/song-code-to-work-p5-js</link>
      <pubDate>Tue, 14 Mar 2017 17:05:59 +0000</pubDate>
      <dc:creator>blank1000</dc:creator>
      <guid isPermaLink="false">21393@/two/discussions</guid>
      <description><![CDATA[<dl>
<dt>My code</dt>
<dd>
<p>var a=0;
var song;
function setup() {
song = loadSound('assets/lucky_dragons_-_power_melody.mp3');
createCanvas(600,600);
background(0);
frameRate(70);</p>
</dd>
</dl>

<p>}</p>

<p>function mousePressed() {
  if ( song.isPlaying() ) { // .isPlaying() returns a boolean
    song.stop();
    background(0,0,0);
  } else {
    song.play();
    background(0,0,0);
  }<br />
function draw() {
    strokeWeight(6);
    var l=random(400);
    stroke(0);
    fill (400)
    line (a,1,a,0);
    stroke(800);
    line(a,1,a,l);
    a=a+5;
    if (a&gt;600){
      a=0;
    }</p>

<p>if ( song.isPlaying() ) {
    song.stop();
    background(0,0,0);
  } else {
    song.play();
    background(0,0,0);
  }
}</p>

<p>Im trying to put my image together with the song to click on but it's not working as much as expected.....</p>
]]></description>
   </item>
   <item>
      <title>Music Play/Pause Button</title>
      <link>https://forum.processing.org/two/discussion/20183/music-play-pause-button</link>
      <pubDate>Tue, 10 Jan 2017 22:21:21 +0000</pubDate>
      <dc:creator>tawn</dc:creator>
      <guid isPermaLink="false">20183@/two/discussions</guid>
      <description><![CDATA[<p>Hey i want a Play/Pause button in my Visualizer can you help me??</p>

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

PImage hintergrund;

Minim minim;
AudioPlayer Player;
FFT fft;
int w;
int farbe;


void setup()
{
  size(500,300,P3D);
  minim = new Minim(this);
  Player = minim.loadFile("bla.mp3"); // Spielt die Mp3 datei ab
  Player.loop(); // Wiederholt den aktuellen Song
  fft = new FFT(Player.bufferSize(), Player.sampleRate());
  fft.logAverages(60, 7);
  stroke(255);
  w = width/fft.avgSize();
  strokeWeight(w);
  strokeCap(SQUARE);
  farbe = 0;

}

void draw()
{
  hintergrund = loadImage("hintergrund.jpg");
  image(hintergrund,0,0);

  fft.forward(Player.mix);

  colorMode(HSB);
  stroke(farbe, 255, 255);
  colorMode(RGB);

  for(int i = 0; i &lt; fft.avgSize(); i++){
    line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);

}

  farbe += 5;
  if( farbe &gt; 255)
  {
    farbe = 0;
  }
}
</code></pre>

<p>This is atm my Code
also i would donate a few euro if you can help me :)</p>
]]></description>
   </item>
   <item>
      <title>How to get one audio track to stop playing when another starts playing (Minim)</title>
      <link>https://forum.processing.org/two/discussion/19857/how-to-get-one-audio-track-to-stop-playing-when-another-starts-playing-minim</link>
      <pubDate>Tue, 20 Dec 2016 22:09:19 +0000</pubDate>
      <dc:creator>amumu</dc:creator>
      <guid isPermaLink="false">19857@/two/discussions</guid>
      <description><![CDATA[<p>I have two soundtracks- one named rain and another named heartbeat. The goal is to trigger these audio files when a key is pressed. My problem is that I need to ensure that when one is playing the other stops, and for some reason processing isn't recognizing the .stop() or .pause() functions.</p>

<p>I'm only a beginner with code, so if anyone can let me know what I'm doing wrong/how I can fix this, I'd appreciate it a lot!</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 minim;
    AudioPlayer heartbeat;
    AudioPlayer rain; 

    void setup()
    {
      size(400, 600);
      minim = new Minim(this);
      heartbeat = minim.loadFile("heartbeat.mp3");
      rain = minim.loadFile("rainforest.mp3");
    }

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

    void keyPressed() {
      if (key == 'h') {
        heartbeat.rewind();
        heartbeat.play();
        if (key == 'p') {
            heartbeat.pause(); }
      }
       if (key == 'r' &amp;&amp; !rain.isPlaying()) {
        rain.rewind();
        rain.play();
        if (key == 's') {
            rain.pause(); }
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>faster trigger audio clips for 'drum roll'</title>
      <link>https://forum.processing.org/two/discussion/18696/faster-trigger-audio-clips-for-drum-roll</link>
      <pubDate>Mon, 24 Oct 2016 23:22:29 +0000</pubDate>
      <dc:creator>ArtStudent</dc:creator>
      <guid isPermaLink="false">18696@/two/discussions</guid>
      <description><![CDATA[<pre><code>Hi Everybody
My professor (Kate Hartman) has generously helped my team and I develop the following code, trying to get a single 'drum tap' thing going. However, there's an issue.

I'd like to be able to play the sound quickly, like a drum roll, but right now I'm unable. I believe currently, I can only re'trigger the sound once it's stopped playing, so I can't play it more than once every 1/4 second or so.

I think I may need to add 'restart' for play mode somewhere, but I'm not sure where. Can anyone assist me or point me in the right direction? 

Much much thanks.

.aS.



`function preload() {
  soundFormats('wav');
  sample = loadSound('snare.wav');
}

function setup() {
  createCanvas(displayWidth, displayHeight);
  //fullscreen(true);
  sample.play();
}

function draw() {

  if (sample.isPlaying()) {
    background('white');
    fill('blue');
    stroke('none');
    ellipse(windowWidth / 2, windowHeight / 2, 175, 175);
  } else {
    background('blue');
    noStroke();
    fill('white');
    ellipse(windowWidth / 2, windowHeight / 2, 175, 175);
  }

}

function mousePressed() {
  if (sample.isPlaying()) {
    //sample.pause();
    sample.playMode('restart');
    //do nothing!
  } else {
    sample.play();
}
}

`
</code></pre>
]]></description>
   </item>
   <item>
      <title>Java mode .isPlaying()</title>
      <link>https://forum.processing.org/two/discussion/18992/java-mode-isplaying</link>
      <pubDate>Fri, 11 Nov 2016 18:43:43 +0000</pubDate>
      <dc:creator>bworld1</dc:creator>
      <guid isPermaLink="false">18992@/two/discussions</guid>
      <description><![CDATA[<p>First, I don't see a Java mode category for my question. This has probably been asked hundreds of times and I think it works differently in p5.js mode. I notice that when calling the .isPlaying() method, before the sound starts playing, it has no value, shouldn't it be 0? (I get a null point exception if I call it before the sound starts), since it returns an int of 1 when it starts playing. And shouldn't it return to 0 when the sound is done playing, currently it just stays at 1 (this doesn't make any sense, most people would like to know when the sound stops playing). It would solve a lot of my problems if it worked this way.</p>
]]></description>
   </item>
   <item>
      <title>How to stop audio from overlapping?</title>
      <link>https://forum.processing.org/two/discussion/18833/how-to-stop-audio-from-overlapping</link>
      <pubDate>Tue, 01 Nov 2016 21:27:10 +0000</pubDate>
      <dc:creator>Coder1911</dc:creator>
      <guid isPermaLink="false">18833@/two/discussions</guid>
      <description><![CDATA[<p>I'm fairly new to processing, started in september. In my class right now were making experments based off of pacman. Right now I'm trying to have the waka waka sound play upon a key press and use loop to repeat it. The problem is that as I continue to use the keys the sound starts over again mutiple times overlapping each over. How can I make the audio run once until the key is released to stop the sound and repeat itself again.</p>
]]></description>
   </item>
   <item>
      <title>How to stop audio playing twice when tapped on android devices?</title>
      <link>https://forum.processing.org/two/discussion/18741/how-to-stop-audio-playing-twice-when-tapped-on-android-devices</link>
      <pubDate>Thu, 27 Oct 2016 02:56:20 +0000</pubDate>
      <dc:creator>ArtStudent</dc:creator>
      <guid isPermaLink="false">18741@/two/discussions</guid>
      <description><![CDATA[<p>Hi Guys,</p>

<p>I'm trying to make a simple drum tap thing, and it works well in Safari and on iPhone.
However, on both of my friends Android phones, one tap on the screen plays the hit twice.</p>

<p>It's got me stumped. Any tips for me?</p>

<pre><code>var song, analyzer;

function preload() {
  soundFormats('wav');
  song = loadSound('warble.wav');
}

function setup() {
  createCanvas(500, 1146);
  fullscreen(false);

  // create a new Amplitude analyzer
  analyzer = new p5.Amplitude();

  // Patch the input to an volume analyzer
  analyzer.setInput(song);
}


function mouseClicked() {
  if (song.isPlaying()) {
    //sample.pause();
    song.playMode("restart");
    song.play();
    //do nothing!
  } else {
    song.play();
}
}


function draw() {

  background(255);

  // Get the average (root mean square) amplitude
  var rms = analyzer.getLevel();


  //rectMode(CENTER);  // Set rectMode to CENTER
  fill(0,150,220);
  ellipse(width/2, height/2, 100+rms*2500, 100+rms*2500);

  fill(255);


 ellipse(width/2, height/2, 50+rms*1200, 50+rms*1200);



  // Draw an ellipse with size based on volume



}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Minim pause() does not work</title>
      <link>https://forum.processing.org/two/discussion/16413/minim-pause-does-not-work</link>
      <pubDate>Tue, 03 May 2016 20:37:44 +0000</pubDate>
      <dc:creator>pet0103</dc:creator>
      <guid isPermaLink="false">16413@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am working on a tangible music player with Arduino and for this I am using the minim library. However, the player.pause() function does not work in my code. It only stops the song for a few milliseconds and then continues to play the song.</p>

<p>The code for the pause function is as the following:</p>

<pre lang="javascript">
    boolean state = false;
    
    if (keyPressed) {
        if (key == 'p' &amp;&amp; !state) {
          state = true;
          player[currentSong].pause();
        }
        else if (key == 'p' &amp;&amp; state) {
        state = false;
        player[currentSong].play();
      }
</pre>

<p>Is there something else that I have to add in order to let it pause until I press the P key again?</p>
]]></description>
   </item>
   <item>
      <title>boolean isPlaying()</title>
      <link>https://forum.processing.org/two/discussion/15867/boolean-isplaying</link>
      <pubDate>Tue, 05 Apr 2016 21:09:51 +0000</pubDate>
      <dc:creator>clem</dc:creator>
      <guid isPermaLink="false">15867@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I probably asked this in the wrong department. 
I have a sketch written in 1.5.1 which worked and is now not working and I am not sure why
it is hanging up on 
boolean isPlaying(){
return playing;
}
it is hanging up on 'playing'  cannot find anything named playing
not sure why.........
can anyone help?
just downloaded processing 1.5.1  (thought it best to stick to original version) on mac mini running 10.9.4  2.3GHZ Intel Core 17 processor and 4GB 1600MHz DDR3 memory</p>

<p>I can send all the code along if it helps?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Play single audio file multiple times</title>
      <link>https://forum.processing.org/two/discussion/15705/play-single-audio-file-multiple-times</link>
      <pubDate>Sun, 27 Mar 2016 12:06:32 +0000</pubDate>
      <dc:creator>blyk</dc:creator>
      <guid isPermaLink="false">15705@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make a particle attractor with processing where some particles are moving randomly and they get attracted towards a master attarctor when they come close to it. Doing this was fairly easy and I have completed the code. The problem is with the minim sound play part where I need to play a sound file when the particles hit the master attractor. I am using only one audio file which needs to play whenever the particle hits the master attractor.</p>

<p>The problem is that when a particle hits the master attractor it plays the sound but as soon as another particle hits the sound it reset the sound and sound doesn't play properly.</p>

<p>when I do this processing plays multiple instance and it doesn't sound good.</p>

<pre><code>  if (P.loc.dist(M.loc)&lt;50) {
      stroke(0, 50);
      line(P.loc.x, P.loc.y, M.loc.x, M.loc.y);  
        player.pause();
        player.rewind();
        player.play(); 
    }
</code></pre>

<p>When I  do this the whole processing sketch gets slowed down</p>

<pre><code>   if (P.loc.dist(M.loc)&lt;50) {
      stroke(0, 50);
      line(P.loc.x, P.loc.y, M.loc.x, M.loc.y);  
       player = minim.loadFile("1.MP3", 2048); 
        player.pause(); 
    }
</code></pre>

<p>And when I do this the sound plays only few times because it waits until the previous instance gets finished.</p>

<pre><code>  if (P.loc.dist(M.loc)&lt;50) {
      stroke(0, 50);
      line(P.loc.x, P.loc.y, M.loc.x, M.loc.y); 
      if (!player.isPlaying()) {
        player.pause();
        player.rewind();
        player.play();
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Simple rollover animations with image and sounds for mouseX and mouseY</title>
      <link>https://forum.processing.org/two/discussion/15352/simple-rollover-animations-with-image-and-sounds-for-mousex-and-mousey</link>
      <pubDate>Mon, 07 Mar 2016 20:34:35 +0000</pubDate>
      <dc:creator>mnoble</dc:creator>
      <guid isPermaLink="false">15352@/two/discussions</guid>
      <description><![CDATA[<p>Hello Forum,</p>

<p>I work with a beginning code class of teen-aged students. For the ones who struggle, I have a simple design project where they program a series of images (stop-motion type thinking) to move with mouseX and mouseY. I would like them also to be able to add a sound effect at different places with specific images. I am doing something like the code below but I would like the sound to just play once rather than looping when mouse hovers? And, I am assuming there are better ways to set up roll-over SFX - would love thoughts on how to make the sounds play once and other cool ways to simplify the loading of sound with roll-over images. Thanks!</p>

<pre><code>//SOUND
import ddf.minim.*;
Minim minim;//audio context 
AudioPlayer song1;
AudioPlayer song2;
AudioPlayer song3;
AudioPlayer song4;

PImage img1, img2, img3, img4; 

//setup
void setup () {
  size (670,237);
  background (255);


  img1 = loadImage("bird1.png");
  img2 = loadImage("bird2.png");
  img3 = loadImage("bird3.png");
  img4 = loadImage("bird4.png");

}

//draw function that loops
void draw () {

  //draw lines to divide quadrants


  //upper left quadrant is red
  if ((mouseX &lt; 150) &amp;&amp; mouseY &gt; 0) {
 image(img1, 0,0);
  minim=new Minim(this); 
  song1=minim.loadFile("one.mp3",1000);
  song1.play();


  //upper right quadrant cyan
  } else if ((mouseX &lt; 250)&amp;&amp; (mouseY &gt; 0)){
   image(img2, 0,0);
     minim=new Minim(this); 
  song2=minim.loadFile("two.mp3",1000);
  song2.play();


  //lower left quadrant gray
   }else if ((mouseX &lt; 340) &amp;&amp; (mouseY &gt;0)) {
   image(img3, 0,0);
        minim=new Minim(this); 
  song3=minim.loadFile("three.mp3",1000);
  song3.play();


 // lower right quadrant black
  }else if ((mouseX &lt; 440) &amp;&amp; (mouseY &gt; 0)){
 image(img4,0,0);
      minim=new Minim(this); 
  song4=minim.loadFile("four.mp3",1000);
  song4.play();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to crop an image in P5?</title>
      <link>https://forum.processing.org/two/discussion/14125/how-to-crop-an-image-in-p5</link>
      <pubDate>Wed, 23 Dec 2015 10:39:51 +0000</pubDate>
      <dc:creator>jordy</dc:creator>
      <guid isPermaLink="false">14125@/two/discussions</guid>
      <description><![CDATA[<p>I am working on a program in P5, an offshoot of Processing, that allows the user to upload an image, draw a line on top of the image, and then crop everything outside of the drawn shape out of the image.</p>

<p><a rel="nofollow" href="https://forum.processing.org/two/uploads/imageupload/614/208JHBXYM5BT.png" title="Screen Shot 2015-12-23 at 11.30.32">Screen Shot 2015-12-23 at 11.30.32</a>
<img src="https://forum.processing.org/two/uploads/imageupload/919/FP51RP5O3COA.png" alt="Screen Shot 2015-12-23 at 11.27.21" title="Screen Shot 2015-12-23 at 11.27.21" />
(The green line jitters around on purpose)</p>

<p>I managed to get the points of the drawn line into an array, as well as make a shape out of these points. However, the cropping of the image is still a problem.</p>

<p>Processing has this functionality in vertex:
(<a href="https://processing.org/reference/vertex_.html" target="_blank" rel="nofollow">https://processing.org/reference/vertex_.html</a>)</p>

<p>However, I don't believe P5 has this functionality. I really don't want to have to convert the entire sketch into Processing. Is there any way to do this in P5, or to quickly convert this sketch into processing?</p>

<pre><code>    // Make a variable to store the start image, as well as the drop image.
    var img;

    var cropX = [];
    var cropY = [];
    var pos = 25;
    // Make an array for all paths.
    var paths = [];

    // Make a bool for whether or not I am painting.
    var painting = false;

    // Int for how long until drawing the next circle
    var next = 10;

    // Make vars for vectors that determine where the line is drawn.
    var current;
    var previous;

    // Make ints for how much the lines dance around.
    var shake = 10;
    var minShake = shake * -1;
    var maxShake = shake * 1;

    // Make an int for the line thickness.
    var thickness = 2;
    var camera;
    var tracing = false;

    // Make vars to store the random values for colours into. 
    var rc1;
    var rc2;
    var rc3;

    // Variable for the framerate.
    var fr;

    // Variable that disables drawing lines when you didn't upload an image yet.
    var tracing = false;


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


    function preload() {

      //Load the starting image, and store it in img.
      img = loadImage("assets/startscreen.png");

      //Load the sound that plays when you export a screenshot.
      soundFormats('mp3');
      camera = loadSound('assets/camera.mp3');

    }


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


    function setup() {



      // Set the framerate so the lines don't jump about too quickly.
      fr = 20;

      // Setup a canvas
      var c = createCanvas(1680, 1050);

      // Store a random value out of 255 into the random colour values.
      rc1 = random(255);
      rc2 = random(255);
      rc3 = random(255);

      // Apply the right framerate
      frameRate(fr);

      // Add an event named drop, that runs function gotFile when a file is dropped onto the canvas
      c.drop(gotFile);

      // Store 0,0 vectors in current and previous.
      current = createVector(0, 0);
      previous = createVector(0, 0);

    };

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

    function draw() {


      // Colour the background dark grey.
      background(200);

      // Draw the loaded image at 0,0 coordinates.
    image(img, 0, 0);



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


      // Count if I've been painting for longer than the 'next' variable.
      // Also check if tracing is enabled (if I've dropped an image or not).
      // If these are true I can draw a new line.
      if (millis() &gt; next &amp;&amp; painting &amp;&amp; tracing) {

        // Grab mouse position and store it in variables mouseX and mouseY.  
        current.x = mouseX;
        current.y = mouseY;

        // Add new particle
        paths[paths.length - 1].add(current);

        // Update the 'next' variable, to allow itself 200 extra millisecond for drawing the actual line.
        next = millis() + 200;

        // Move the mouse values used to draw the end of the line
        // to a variable used to draw the start of the line,
        // so that the line is continuous.
        previous.x = current.x;
        previous.y = current.y;
        append(cropX, current.x);
        append(cropY, current.y);
      }

      // Make an integer called i, with a value of 0.
      // Add 1 to i for each item in the array paths.

      // Run this once for each item in the array.
      // Name each item in the array 'i' while working.
      // Display each item in the array.
      for (var i = 0; i &lt; paths.length; i++) {

        // Update the current object in the array.
        paths[i].update();

        // Display each item in the array.
        paths[i].display();
      } 
      noStroke();
      noFill();
         beginShape();

         for (var i = 0; i &lt; cropX.length; ++i) {
           vertex(cropX[i], cropY[i]);
         }
         endShape(CLOSE);


    }


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

    var ready = false;

    // Make a function called gotFile, using the variable file.
    function gotFile(file) {

      // Check if the dropped file is an image file
      if (file.type === 'image') {

        // Enable drawing lines.
        tracing = true;

        // if (ready) {
        //   img.remove();
        // }
        // Store the dropped image in the container which used to hold the startimage.
        img = createImg(file.data).style("opacity: 100; position: absolute; top: -10; right: -10; z-index: 100;draggable=false;");

        ready = true;

        // Error message in case not an image file.
      } else {
        println('Not an image file!');
      }
    }


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

    function mouseWheel(event) {
      //event.delta can be +1 or -1 depending
      //on the wheel/scroll direction
      print(event.delta);
      //move the square one pixel up or down
      pos += event.delta;
      //uncomment to block page scrolling
      return false;
    }

    function mouseDragged() {
    return false;
      }


    // If left mousebutton is pressed down,
    function mousePressed() {
      if (mouseButton == LEFT) {

        // set the variable counting when to place a new line to 0,
        next = 0;

        // set painting to true,
        painting = true;

        // store the mouse coordinates in mouseX and mouseY,
        previous.x = mouseX;
        previous.y = mouseY;

        // and add a new Path method to the array.
        paths.push(new Path());
      }
    }

    // When mouse is released, set painting to false, which disables any paths being drawn.
    function mouseReleased() {
      painting = false;
    }


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


    // Describe the Path function that should be pushed to the array.
    function Path() {

      // Create an array inside this function named particles.
      this.particles = [];
    }

    // Add the variable position to the function Path as its function'()' variable.
    Path.prototype.add = function(position) {

      // Add a new particle to this particle array with a position and hue.
      this.particles.push(new Particle(position, this.hue));
    }

    // Take the Path() function, and and add this command to it.
    Path.prototype.update = function() {

      // Make an integer called i, with a value of 0.
      // Add 1 to i for each item in the array paths.

      // Run this once for each item in the array.
      // Name each item in the array 'i' while working.
      // Display each item in the array.
      for (var i = 0; i &lt; this.particles.length; i++) {
        this.particles[i].update();
      }
    }

    // Display the Path array.
    Path.prototype.display = function() {

      // Loop through the array of particles backwards.
      for (var i = this.particles.length - 1; i &gt;= 0; i--) {

        // Display each of these particles.
        this.particles[i].display(this.particles[i + 1]);

      }

    }

    // Particles along the path
    function Particle(position, hue) {

      // Set the position of Particles to the mouseposition by creating a vector.
      this.position = createVector(position.x, position.y);
    }

    // Constantly update Particle.
    Particle.prototype.update = function() {}

    // Draw particle and connect it with a line
    // Draw a line to another
    Particle.prototype.display = function(other) {
      stroke(255, 255);

      // If we need to draw a line
      if (other) {
        stroke(rc1, rc2, rc3);
        strokeWeight(thickness);
        line(this.position.x + random(minShake, maxShake), this.position.y + random(minShake, maxShake), other.position.x + random(minShake, maxShake), other.position.y + random(minShake, maxShake));
      }
      if (keyIsDown(LEFT_ARROW) &amp;&amp; !camera.isPlaying()) {
        camera.play();
        save('myRemix.jpg');
        print(cropX);
        print(cropY)

      }

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Minim NullPointerException after multiple player.play() executions</title>
      <link>https://forum.processing.org/two/discussion/13896/minim-nullpointerexception-after-multiple-player-play-executions</link>
      <pubDate>Fri, 11 Dec 2015 18:07:04 +0000</pubDate>
      <dc:creator>rmodesi</dc:creator>
      <guid isPermaLink="false">13896@/two/discussions</guid>
      <description><![CDATA[<p>The following code gives me a NullPointerException</p>

<pre><code>// file: Lily.pde

import ddf.minim.*;
AudioPlayer player;
Minim minim; //audio context



// List of animals
StringList animalList = new StringList(
      "alligator", "bear", "cat", "dog", "elephant",
      "frog", "goat", "horse", "jay",
      "koala", "lion", "monkey", "newt", "owl",
      "pig", "raccoon", "squirrel", "turkey", "vulture",
      "whale", "yak", "zebra");

// animal image, sound and name matricies 
PImage[] images = new PImage[animalList.size()];
String[] animalSound = new String[animalList.size()]; 
String[] animalName = new String[animalList.size()];

String aList = "";
String aName = "";
PImage lily;
String imgName;
String sound;
int col;

void setup() {
  size(1024, 960);
  textSize(128);
 imageMode(CENTER);

  // Create and load image &amp; sound matricies
  // ---------------------------------------
  int i = 0;
  for (String animal : animalList) {
    imgName = "data/" + animal + ".jpg";
    images[i] = requestImage(imgName);
    //images[i].resize(width,height);
    sound = "data/" + animal + ".mp3";
    animalSound[i] = sound;
    aName = "data/say-" + animal + ".mp3";
    animalName[i] = aName;
    aList += animal.charAt(0);
    i ++;
  }

  minim = new Minim(this);

  // Load start image and sound
  // --------------------------
  showLily();

    }

void draw() {

}

void keyPressed(){
 if(player.isPlaying()) {
    player.pause();
  }

  col = color(random(255), random(255),random(255));
  background(col);
  int key1 = aList.indexOf(key);
  if (key1 == -1) {
    background(col);
    fill(#18ED76);
    text(Character.toUpperCase(key), width/2, height/2);
  return; }

  playName(key1);

  showImage(key1);

  playSound(key1);

  char letter = aList.charAt(key1);
  showLetter(letter, animalList.get(key1));
}

void playSound(int k) {
  player = minim.loadFile(animalSound[k]);
  player.play();                                              &lt;&lt;- null pointer occurs here or below
}

void playName(int k) {
 player = minim.loadFile(animalName[k]);
 player.play();                                                 &lt;&lt;- null pointer also occurs here
}

void showLetter(char letter, String animal) {
  col = color(random(255), random(255),random(255));
  fill(col);
  letter = Character.toUpperCase(letter);
  textAlign(LEFT);
  text(letter, 50, 110);
  textAlign(CENTER);
  text(animal, width/2 - (animal.length()/2), height -75);
  textAlign(RIGHT);
  text(letter, width-100, height-50);
}

void showImage(int k) {
 image(images[k], width/2, height/2, 700,600);
}

void showLily() {
  col = color(random(255), random(255),random(255));
  background(col);
  player=minim.loadFile("data/kookaburra.mp3");
  player.play();
  imgName = ("data/Lily1.jpg");
  lily = loadImage(imgName);
  image(lily, width/2, height/2);
  fill(255);
  showLetter('L', "Lily");
}

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

<p>I get the NullPointerException at the places indicated above. I have tried placing</p>

<pre><code>if(player.isPlaying()) {
    player.pause();
}
</code></pre>

<p>at the top of both the playSound() and playName() functions but neither has the effect I expect which is to let the next sound proceed. NullExceptionPointers do not occur after every new keystroke but as I increase the speed after about 5 or 6 keys I will get the exception. This application is for my 18 month old grand-daughter so of course she will "pound" the keyboard. Anyone have any ideas.
I am using Processing 3.01 with the Minim imbeded library.</p>
]]></description>
   </item>
   <item>
      <title>play mp3 files from an array using minim?</title>
      <link>https://forum.processing.org/two/discussion/13699/play-mp3-files-from-an-array-using-minim</link>
      <pubDate>Sun, 29 Nov 2015 21:24:23 +0000</pubDate>
      <dc:creator>dms91</dc:creator>
      <guid isPermaLink="false">13699@/two/discussions</guid>
      <description><![CDATA[<p>Hi im new to using processing/java , just wondering if anyone can help me , i am using minim , and it would love any help/code on how to play an mp3 file from an array.  Any help would be appreciated thanks.</p>
]]></description>
   </item>
   <item>
      <title>File Length .mp3 or .wav with Minim and Processing</title>
      <link>https://forum.processing.org/two/discussion/13656/file-length-mp3-or-wav-with-minim-and-processing</link>
      <pubDate>Wed, 25 Nov 2015 19:15:19 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">13656@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>Is Possible to know Which time to complete a sound (music) an .mp3 or .wav of a file in Processing, using the Minim library?</p>

<p>For example, I need at the end of a particular sound, perform a certain action, so I need to know when to finished.</p>

<p>This is the code I used as an example, although I'm using is in another project.</p>

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

AudioPlayer player[] = new AudioPlayer[3];
String filenames[]   = new String[] {"groove.mp3", "jingle.mp3", "Kalimba.mp3"};

void setup(){
  minim = new Minim(this);
  for(int i = 0; i &lt; 3; i++){
    player[i] = minim.loadFile(filenames[i], 2048);
  }
}

void draw(){
  //
}

void keyPressed(){
  int som;

  if (key == 'A' || key == 'a') som = 0;
  else if (key == 'B' || key == 'b') som = 1;
  else som = 2;

  playSom(som);
}

void playSom(int opcSom){
  for (int i = 0; i &lt; 3; i++){
    if (player[i].isPlaying()) 
      player[i].pause();
  }

  player[opcSom].rewind();   
  player[opcSom].play();
  println("Duration: "); //???
}  

void stop(){
  for(int i = 0; i &lt; 3; i++){
    player[i].close();
  }

  minim.stop();
  super.stop();
}
</code></pre>

<p>Thanks for attention.</p>
]]></description>
   </item>
   <item>
      <title>Minim For loop play();</title>
      <link>https://forum.processing.org/two/discussion/13637/minim-for-loop-play</link>
      <pubDate>Wed, 25 Nov 2015 00:03:20 +0000</pubDate>
      <dc:creator>iankookane</dc:creator>
      <guid isPermaLink="false">13637@/two/discussions</guid>
      <description><![CDATA[<p>Hello Everyone,</p>

<p>I have a simple for loop that plays different sounds using minim. However it does not finish an iteration thru the loop until it is done playing the mp3 file.  Is there anyway to do the next iteration while the before mp3 file is still playing? Like go to the next iteration right after the play() function starts?</p>
]]></description>
   </item>
   <item>
      <title>What's the best way of telling when a sound file has finished playing?</title>
      <link>https://forum.processing.org/two/discussion/13494/what-s-the-best-way-of-telling-when-a-sound-file-has-finished-playing</link>
      <pubDate>Thu, 12 Nov 2015 08:54:05 +0000</pubDate>
      <dc:creator>dhmstark</dc:creator>
      <guid isPermaLink="false">13494@/two/discussions</guid>
      <description><![CDATA[<p>I'm putting together an application which plays a series of sound files in sequence; I want to be able to tell when a file has finished.</p>

<p>The obvious ways of doing this (checking for the currentTime() &gt;= duration() and checking for !.isPlaying() &amp;&amp; !.isPaused()) don't work - when a sound file finishes playing, currentTime() returns 0, and the second statement is also true when there's nothing playing at all.</p>

<p>I can probably sort this by tracking the currentTime and watching for a jump down from a non-zero value, but this seems like a hacky way of doing things. Have I missed something obvious or is there a feature that isn't documented that would solve my problem?</p>

<p>Relatedly, it seems like it would be useful for the soundFile to raise some sort of event when it finishes playing, or alternatively for its currentTime to remain equal to its duration rather than resetting to zero.</p>
]]></description>
   </item>
   </channel>
</rss>