<?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 rewind() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=rewind%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:13:34 +0000</pubDate>
         <description>Tagged with rewind() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedrewind%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to switch from one text to another according to time with the Geomerative library?!</title>
      <link>https://forum.processing.org/two/discussion/28017/how-to-switch-from-one-text-to-another-according-to-time-with-the-geomerative-library</link>
      <pubDate>Fri, 25 May 2018 14:51:04 +0000</pubDate>
      <dc:creator>lolonulu</dc:creator>
      <guid isPermaLink="false">28017@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I have an issue with Geomerative. I'd like to switch from text to text using this library according to a time schedule.
It works but when switching to a shorter text I still see the previous text! How can I switch properly from a text to another?! Thanks a lot in advance for your help. Best, L</p>

<pre><code>import geomerative.*;
// Liste de liste de points. La 1ère correspond au nombre de phrases, ici 4, la 2ème correspond au nom total de points par phrase
RPoint[][] myPoints = new RPoint[4][0];
RFont font;

String [] FR1 = {
  "On me dit de te haïr et je m'y efforce", 
  "Je t'imagine cruel, violent, implacable", 
  "Mais à te voir je n'ai bientôt plus de force", 
  "Et de te blesser je suis bien incapable", 
}; 
String [] FR2 = {
  "Tous mes camarades combattent avec rage", 
  "Et pleurent la nuit au souvenir des supplices", 
  "Infligés à leurs frères qui sont du même âge", 
  "et rêvent comme eux de toucher une peau lisse"
}; 
String [] FR3 = {
  "Et de pouvoir enfin caresser des obus", 
  "Autres que ceux produits par le pouvoir obtus", 
  "Je rêve de quitter ces boyaux infernaux"
};
String [] FR4 = {
  "De laisser ces furieux des deux bords du Rhin", 
  "Et de pouvoir embrasser ta chute de rein", 
  "Et porter notre amour sur les fonts baptismaux"
};

final color textColor = color(245);
// TIME
int startTime;


//----------------SETUP---------------------------------

void setup() {
  size(1920, 1080, JAVA2D);

  smooth();
  RG.init(this);
  font = new RFont("FreeSans.ttf", 86, CENTER);
  stroke(textColor);
  strokeWeight(0.05);
  //INIT
  initAll();
  changePhrases(0);
  changePhrases(1);
  changePhrases(2);
  changePhrases(3);
  // TIME
  startTime=millis();
}

//----------------DRAW---------------------------------

void draw() {
  background(255);



  translate(width/2, height/1.5);

  for (int i=0; i&lt; myPoints.length; i++) {
    for (int j=0; j&lt; myPoints[i].length-1; j++) {

      pushMatrix(); 
      translate(myPoints[i][j].x, myPoints[i][j].y-420+i*180);
      noFill();
      stroke(0, 200);
      strokeWeight(0.25);
      float angle = TWO_PI*10;
      rotate(j/angle);
      bezier(-2*(noise(10)), 10, 25*(noise(10)), -5, 2*noise(5), -15, 10, -3);
      //bezier(-10*(noise(20))+mouseX/15, 30+mouseY/10, -10*(noise(10))+mouseX/15, 20+mouseY/15, -20*noise(20)+mouseX/15, -20+mouseY/5, 10+mouseX/15, -10+mouseY/15);
      popMatrix();
    }
  }
  if (millis()-startTime &gt; 0 &amp;&amp; millis()-startTime &lt; 3000) {
    changePhrases(0);
  }

  if (millis()-startTime &gt; 3000 &amp;&amp; millis()-startTime &lt; 6000) {
    changePhrases(1);
  }

  if (millis()-startTime &gt; 6000 &amp;&amp; millis()-startTime &lt; 9000) {
    changePhrases(2);
  }

  if (millis()-startTime &gt; 9000 &amp;&amp; millis()-startTime &lt; 12000) {
    changePhrases(3);
  }

}

//----------------INITIALIZE---------------------------------
void initAll() {
  for (int j=0; j&lt;FR1.length; j++) {
    RGroup myGroup = font.toGroup(FR1[j]);
    myGroup = myGroup.toPolygonGroup();
    myPoints[j] = myGroup.getPoints();
  }
}

//FUNCTION TO SWITCH PHRASES
void changePhrases(int state) {

  switch(state) {
  case 0:
    for (int j=0; j&lt;FR1.length; j++) {
      RGroup myGroup = font.toGroup(FR1[j]);
      myGroup = myGroup.toPolygonGroup();
      myPoints[j] = myGroup.getPoints();
    }
    break;
  case 1:
    for (int j=0; j&lt;FR2.length; j++) {
      RGroup myGroup = font.toGroup(FR2[j]);
      myGroup = myGroup.toPolygonGroup();
      myPoints[j] = myGroup.getPoints();
    }
    break;
  case 2:
    for (int j=0; j&lt;FR3.length; j++) {
      RGroup myGroup = font.toGroup(FR3[j]);
      myGroup = myGroup.toPolygonGroup();
      myPoints[j] = myGroup.getPoints();
    }
    break;
  case 3:
    for (int j=0; j&lt;FR4.length; j++) {
      RGroup myGroup = font.toGroup(FR4[j]);
      myGroup = myGroup.toPolygonGroup();
      myPoints[j] = myGroup.getPoints();
    }
    break;
  }
}
//////////////////////////////////////////////
</code></pre>
]]></description>
   </item>
   <item>
      <title>Play .mp3s in Sequence with onended()?</title>
      <link>https://forum.processing.org/two/discussion/27896/play-mp3s-in-sequence-with-onended</link>
      <pubDate>Tue, 01 May 2018 23:33:27 +0000</pubDate>
      <dc:creator>sammy</dc:creator>
      <guid isPermaLink="false">27896@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,
Continuing n00b adventures with p5.sound here. I'm trying to create a shuffle player in the browser.  This code preloads a list of .mp3s called 1.mp3, 2.mp3, etc., up to 5.mp3, and then plays one file chosen with random() on mousePressed().</p>

<p>My questions: how to trigger each randomly selected file from the end of the previous file? How to loop this process, so that one randomly chosen file plays from the end of the previous one, on and on?</p>

<p>I suspect <a rel="nofollow" href="https://p5js.org/reference/#/p5.MediaElement/onended">onended()</a> will help. <a rel="nofollow" href="https://forum.processing.org/two/discussion/comment/55753/#Comment_55753">This thread</a> addresses the use of onended() to trigger messages. I appreciate any clues you can provide! Thanks.</p>

<pre><code>//Create array of .mp3s numbered 1 to 5.
const FOLDER = '1to5/', EXT = '.mp3',
      INDEX_START = 1, INDEX_END = 5,
      INDEX_TOTAL = 1 + INDEX_END - INDEX_START,
      sounds = Array(INDEX_TOTAL);

//Preload those files.
function preload() {
  for (let i = 0; i &lt; INDEX_TOTAL; ++i) {
    sounds[i] = loadSound(FOLDER + (i + INDEX_START) + EXT);
    print("i = " + i);
  }

}

function setup() {
  createCanvas(200, 200);
  textAlign(CENTER);
  fill(100);
  noStroke();
  text("CLICK TO PLAY", width/2, height/2);
}

//Play one randomly chosen file.
function mousePressed() {
    var j = int(random(5));
    print("j = " + j);
    sounds[j].play();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Creating a Piano (need help with keyReleased)</title>
      <link>https://forum.processing.org/two/discussion/27919/creating-a-piano-need-help-with-keyreleased</link>
      <pubDate>Fri, 04 May 2018 23:25:14 +0000</pubDate>
      <dc:creator>rpinkall</dc:creator>
      <guid isPermaLink="false">27919@/two/discussions</guid>
      <description><![CDATA[<p>I am creating a music machine and when I press the 'a' key the function begins to hold the note.
When I release the 'a' key, the sound file stops, as i want it to.</p>

<p>But when I go to press the 'a' key again, no sound comes out at all.  I feel like the key1.pause(); function stops it correctly but wont load the same sound file when pressing the 'a' key again.</p>

<p>When I use the key1.rewind(); under the keyReleased function, it plays the sound upon releasing the key 'a' in a rewind manner.</p>

<p>This is my final project for Programming for Visual Artists and really could use some assistance please!</p>

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

            Minim minim;

            AudioPlayer key1;

            void setup() {

            size(1440, 770);

            minim = new Minim(this);
            key1 = minim.loadFile("key1.mp3", 512);
            }

            void draw() {
            }

            void keyPressed() {
              if (key=='a')
                key1.play();
            }
            void keyReleased() {
              key1.pause();

            }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to 'store' previous keyPressed data in the same sketch</title>
      <link>https://forum.processing.org/two/discussion/27750/how-to-store-previous-keypressed-data-in-the-same-sketch</link>
      <pubDate>Thu, 12 Apr 2018 17:18:16 +0000</pubDate>
      <dc:creator>mariamalz</dc:creator>
      <guid isPermaLink="false">27750@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/866/TDK20E721F1F.png" alt="Screen Shot 2018-04-12 at 7.18.27 PM" title="Screen Shot 2018-04-12 at 7.18.27 PM" /></p>

<p>I can get one colored bar to expand as I hold down the key. I have another an issue of getting another colored bar to continue where the other one left off? Essentially it continues right after the previous rectangle depending on where it stops. Here's a picture of what I want to achieve (assuming each colored rectangle is a different length).</p>

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

<pre><code>int rectWidth=0;
int rectHeight=250;

int x = -rectWidth;  

void setup(){
  size(800,800);
  background(0);
  noStroke();
  smooth();

}

void draw(){

 rect(0, 0, rectWidth, rectHeight);

 if(keyPressed){
   rectWidth++;


  if((key == 'a')) {
   fill(#8fcd9c); }

 if((key == 'b')) {
    fill(#96c6ea); }

 if((key == 'c')) {
    fill(#ef3942); }

 if((key == 'd')) {
    fill(#fdf04d); }

 if((key == 'e')) {
    fill(#c6e9f6); }

 if((key == 'f')) {
    fill(#ef5a7a); }

 if((key == 'g')) {
    fill(#f8971d); } 
 }
</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>Array of identical samples. Minim triggering sample issue.</title>
      <link>https://forum.processing.org/two/discussion/26862/array-of-identical-samples-minim-triggering-sample-issue</link>
      <pubDate>Thu, 15 Mar 2018 15:35:32 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">26862@/two/discussions</guid>
      <description><![CDATA[<p>Hi there. I have an array of identical samples for two bouncing orbs which are also in an array. A sample is to play each time a ball falls below a virtual water level. They trigger just fine, but there seems to be constant or random glitches in sample sounds at various other times when it has not crossed this threshold. The line in question where I set this threshold is contained within the orb_class. Perhaps this is completely wrong, but it triggers the samples at least:</p>

<pre><code>  void playSample(int arrayIndex){ 
    if (orby &lt; waterSurfaceHeight){   
      popsound[arrayIndex].rewind();
      popsound[arrayIndex].play();
    } 
  } 
</code></pre>

<p>*Edit. The code is shortened to relevant code only an is quoted in a reply below this one.</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>Play and replay the video after few second of the playing time message.</title>
      <link>https://forum.processing.org/two/discussion/26370/play-and-replay-the-video-after-few-second-of-the-playing-time-message</link>
      <pubDate>Thu, 15 Feb 2018 21:10:43 +0000</pubDate>
      <dc:creator>moonilsun</dc:creator>
      <guid isPermaLink="false">26370@/two/discussions</guid>
      <description><![CDATA[<p>Hello</p>

<p>I was trying to make a code for playing my project. 
But I couldn't figure out how to make the same video play and after finished showing few second (maybe 5 seconds) of how many times video played. and again playing the video.</p>

<ol>
<li>after the finished video, then showing the message</li>
<li>the message counting how many times played.</li>
<li>5 sec after automatically play again.</li>
</ol>

<p>It could be a very obvious question, but few days of searching, I still couldn't find the solution...</p>

<p>please anyone can advise on this problem?</p>

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

Movie vid;
boolean ended;

void setup() {
  frameRate(30);
  textSize(050);
  textAlign(CENTER, BASELINE);
  fill(0);

  vid = new Movie(this, "StudioOutside.mov") {
    @ Override public void eosEvent() {
      super.eosEvent();
      myEoS();
    }
  };

  vid.play();
  while (vid.width == 0 | vid.height == 0)  delay(10);

  surface.setSize(vid.width, vid.height); // P3
  //size(vid.width, vid.height); // P2
}

void draw() {
  if (!ended)  background(vid);
  else {
    if (key == ' ' || key == ' ') {
      keyPressed = true;
    if (keyPressed == true) {
     background(vid);
     vid.play();
    }
      } else {
    vid.stop();
    background(255);
    text("Playback has finished!", width&gt;&gt;1, height&gt;&gt;1);
  }
  }
}

void movieEvent(final Movie m) {
  m.read();
}

void myEoS() {
  ended = true;
  frameRate(1);
}
</code></pre>
]]></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>How to play a minim track at a specific time using millis()</title>
      <link>https://forum.processing.org/two/discussion/26299/how-to-play-a-minim-track-at-a-specific-time-using-millis</link>
      <pubDate>Sat, 10 Feb 2018 13:17:19 +0000</pubDate>
      <dc:creator>amycroft</dc:creator>
      <guid isPermaLink="false">26299@/two/discussions</guid>
      <description><![CDATA[<p>I am attempting to write a code which sets of a beep at controlled but random intervals using millis and minim. I can't understand why the beeps are not playing using the code below. Can anyone help?</p>

<p>I am very new to processing!</p>

<p>Thank you,</p>

<p>Amy</p>

<p>&lt;</p>

<p>pre lang="javascript"&gt;</p>

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

    import oscP5.*;
    import netP5.*;

    OscP5 oscP5;
    NetAddress otherSketch;

    Minim minim;
    AudioPlayer beep;

    PFont f;
    int [] beeps = new int [5];
    int ms;
    int start;
    int totalBeeps;
    boolean pressEnter;

    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 12000 */
      otherSketch = new NetAddress("127.0.0.1",8000);

    beeps [0] = int(random(10,60))*1000;//these numbers aren't right but give an earlier beep!
    beeps [1] = int(random(1260,1739))*1000;
    beeps [2] = int(random(1860,2339))*1000;
    beeps [3] = int(random(2460,2939))*1000;
    beeps [4] = int(random(3060,3539))*1000;

    printArray (beeps);

    minim = new Minim(this);
    beep = minim.loadFile ("ping.wav");

    }

    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);

      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);

        OscMessage myMessage = new OscMessage("/time in milliseconds");//this isn't the correct place but a test
        myMessage.add(ms); 
        oscP5.send(myMessage, otherSketch); 
      }else {
        text("Press Enter to begin",10,100);
      }

    for (int i=0;i&lt;beeps.length;i++){ //this for loop should initiate the beeps in the array to sound if their value matches int ms (which is millis - millis when ENTER pressed) 
    if (beeps[i] == ms) 
         {
      beep.play();
      totalBeeps =totalBeeps+1;
        }
      else if ( beep.position() == beep.length() )
      {
        beep.rewind();
       }
      }
    }
</code></pre>

<p></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>Use of If and Else conditional to make sound pause and play.</title>
      <link>https://forum.processing.org/two/discussion/25385/use-of-if-and-else-conditional-to-make-sound-pause-and-play</link>
      <pubDate>Mon, 04 Dec 2017 22:15:42 +0000</pubDate>
      <dc:creator>gotuhooked</dc:creator>
      <guid isPermaLink="false">25385@/two/discussions</guid>
      <description><![CDATA[<p>Hello! I am almost complete with my project. I have decided to use the keyboard function to have a certain key play a sound. 
I have gotten as far as that. But, I am stuck at how to pause the sound and also play for the same key. 
For Example: if you press a letter once, it'll play, and if you do it again, it'll pause it and so forth.</p>

<p>I've tried to use filename.rewind(); but that doesn't help from all my sounds playing at once.</p>

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

Minim minim;
AudioPlayer winter;
AudioPlayer summer;
AudioPlayer spring;
AudioPlayer fall;


MyImage flower;
MyImage fire;
MyImage sun;
MyImage snowman;
float xpos, ypos;    // Starting position of shape    

float xspeed = 5;  // Speed of the shape
float yspeed = 15;  // Speed of the shape

int xdirection = 1;  // Left or Right
int ydirection = 1;  // Top to Bottom

color c;

void setup() {
  size(800, 800);
  c = color(random(255), random(255), random(255));
  noStroke();


  xpos = width/1.8;
  ypos = height/3;
  flower=new MyImage("Flower.png");
  fire=new MyImage("Sun.png");
  sun=new MyImage("campfire.png");
  snowman=new MyImage("snowman.png");

  // will play sound
  minim = new Minim(this);
  winter = minim.loadFile("Winter Mix.wav");
  summer = minim.loadFile("Summer Mix.wav");
  spring = minim.loadFile("Spring Mix.wav");
  fall = minim.loadFile("Fall Mix.wav");
}   


void draw() {
  background(c);
  textSize(20);
  text("R for Spring S for Summer &amp; W for Winter", 80, 100);
  flower.update();
  sun.update();
  fire.update();
  snowman.update();

  flower.draw();
  sun.draw();
  fire.draw();
  snowman.draw();

  if ((keyPressed == true) &amp;&amp; ((key == 'S') || (key =='s'))) {
    summer.play();
    summer.rewind();
  }
  if ((keyPressed == true) &amp;&amp;((key == 'W') || (key=='w'))) {
    winter.play();
  }
  if ((keyPressed == true) &amp;&amp; ((key == 'R') || (key =='r'))) {
    spring.play();
  }
  if ((keyPressed == true) &amp;&amp; ((key == 'F') || (key =='f'))) {
    fall.play();
  }
}
void mousePressed() {
  c = color(random(255), random(255), random(255));
}

class MyImage {  // A class that specifically keeps the images within the canvas. Helped with Forum in Processing 

  PImage img;
  float x, y;
  int w, h;
  float xspeed, yspeed;


  MyImage(String flower) {
    w=h=200;   
    x=random(w, width-w);
    y=random(h, height-h);
    xspeed=yspeed=5;
    img=loadImage(flower);
    img.resize(200, 200);
  }

  MyImage() {
    w=h=200;   
    x=random(w, width-w);
    y=random(h, height-h);
    xspeed=yspeed=5;
    img=getMeImage(color(0));
  }

  MyImage(color c) {
    w=h=200;   
    x=random(w, width-w);
    y=random(h, height-h);
    xspeed=random(9, 13);    
    yspeed=random(7, 10);
    img=getMeImage(c);
  }


  PImage getMeImage(color c) {

    PImage img=createImage(w, h, RGB);
    img.loadPixels();
    for (int i=0; i&lt;200*200; i++)
      img.pixels[i]=c;
    img.updatePixels();
    return img;
  }

  void update() {
    if (x &gt; width-w || x &lt; 0) {
      xspeed *= -1;
    }
    if (y &gt; height-h || y &lt; 0) {
      yspeed *= -1;
    }
    x+=xspeed;
    y+=yspeed;
  }

  void draw() {
    image(img, x, y);  //ImageMode corners
  }
}
</code></pre>

<p>This is the full code. Thank you for your help</p>

<p>Melanie</p>
]]></description>
   </item>
   <item>
      <title>How come the sounds won't reload in "paths" code (but images do?)</title>
      <link>https://forum.processing.org/two/discussion/25314/how-come-the-sounds-won-t-reload-in-paths-code-but-images-do</link>
      <pubDate>Fri, 01 Dec 2017 01:47:14 +0000</pubDate>
      <dc:creator>mnoble</dc:creator>
      <guid isPermaLink="false">25314@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am a teacher helping my students complete their projects for a 12th grade exhibition. In this project, there are 4 roll-over photos and sounds in path 1. When we cycle through to path 0 and then path 1 again, the photo roll-overs work but the sounds don't. Looking for advice - thank you!!!</p>

<pre><code>PImage photo1;
PImage photo2;
PImage photo3;
PImage photo4;
PImage photo5;
PImage photo6;
PImage photo7;
PImage photo8;

int path = 0;

import ddf.minim.*;
Minim minim;
AudioPlayer thunder;
AudioPlayer thunder2;
AudioPlayer thunder3;
AudioPlayer thunder4;


void setup(){
  size (1000,700);
  photo1 = loadImage ("StartScfinal.png");
  photo2 = loadImage ("goodcopbadcop.png");
  photo3 = loadImage ("stereotypes.png");
  photo4 = loadImage ("goodcopbadcopfettyfettywap.png");
  photo5 = loadImage ("goodcopbadcophatecrimes.png");
  photo6 = loadImage ("goodcopbadcopsikhsikh2.png");
  photo7 = loadImage ("latinomanlm.png");
  photo8 = loadImage ("newbolt.png");

 minim = new Minim(this);
 thunder = minim.loadFile ("thunderthunder.mp3");
    thunder2 = minim.loadFile ("thunderthunder2.mp3");
      thunder3 = minim.loadFile ("thunderthunder3.mp3");
       thunder4 = minim.loadFile ("thunderthunder4.mp3");

}

  void draw(){
    println(mouseX,mouseY);
    println ("path=",path);

    if (path == 0) {
      imageMode(CENTER);
      image (photo1,500,350);
      cursor (HAND);
    if ((mousePressed) &amp;&amp; (mouseX &gt; 178) &amp;&amp; (mouseX &lt; 805) &amp;&amp; (mouseY &gt; 524) &amp;&amp; (mouseY &lt; 593)){
      path = 1;
    }
    }
    if (path == 1) {
      cursor(photo8);
    {
      image (photo2,500,350,1000,700); 
      imageMode(CENTER);
  }
    if ((mouseX &gt; 153) &amp;&amp; (mouseX &lt; 250) &amp;&amp; (mouseY &gt; 402) &amp;&amp; (mouseY &lt; 578)){ 
      thunder.play();
      image (photo6,500,350,1000,700); 
  }
    if ((mouseX &gt; 541) &amp;&amp; (mouseX &lt; 612) &amp;&amp; (mouseY &gt; 373) &amp;&amp; (mouseY &lt; 544)){
      image (photo4,500,350,1000,700);
      thunder2.play();
  }
    if ((mouseX &gt; 912) &amp;&amp; (mouseX &lt; 969) &amp;&amp; (mouseY &gt; 384) &amp;&amp; (mouseY &lt; 539)){  
      image (photo7,500,350,1000,700);
      thunder3.play();
  }
    if ((mouseX &gt; 820) &amp;&amp; (mouseX &lt; 881) &amp;&amp; (mouseY &gt; 375) &amp;&amp; (mouseY &lt; 575)){  
      image (photo5,500,350,1000,700);
      thunder4.play();

    }

  }
  if (path == 1) {
    if (keyPressed == true){
      path = 0; 
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Reading .CSV file and displaying visuals in accordance with the data</title>
      <link>https://forum.processing.org/two/discussion/24685/reading-csv-file-and-displaying-visuals-in-accordance-with-the-data</link>
      <pubDate>Sun, 22 Oct 2017 02:08:33 +0000</pubDate>
      <dc:creator>MeganCodey</dc:creator>
      <guid isPermaLink="false">24685@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I have a spreadsheet with the first 1 million numbers in PI.
The goal is to have different visuals displayed along with music tones in accordance with the numbers in the chart (0-9).
The sound works, however I cannot get the program to show any visuals at the same time.
Eg. I want the program to draw an ellipse whenever "0" is read from the .CSV file.</p>

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

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

import ddf.minim.*;

Minim minim;

AudioPlayer DO;
AudioPlayer RE;
AudioPlayer MI;
AudioPlayer FA;
AudioPlayer SOL;
AudioPlayer LA;
AudioPlayer TI;
AudioPlayer DOO;

void setup() {
  size(500, 500);
  background(50);
  minim = new Minim(this);
  data = loadTable("pi.csv", "header");

  DO = minim.loadFile("do.wav");
  RE = minim.loadFile("re.wav");
  MI = minim.loadFile("mi.wav");
  FA = minim.loadFile("fa.wav");
  SOL = minim.loadFile("sol.wav");
  LA = minim.loadFile("la.wav");
  TI = minim.loadFile("ti-WAV.wav");
  DOO = minim.loadFile("do-octave.wav");
}

void draw() {
  fill(250);
  stroke(250);


  row = new int[ data.getRowCount()]; //create an array for row


  for (TableRow row : data.rows()) {
    for (int i=0; i &lt; 10; i++) { // for loop with an increasing "i" allows program go get info through the rows
      int A = row.getInt(i);  //intA is equal to the number in the row

      delay(200);
      ellipse(mouseX, mouseY, 100, 50);

      if (A==0) {
        delay(500);
        ellipse(100, 100, 100, 50);
      }

      if (A==1) {
        RE.rewind();
        RE.play();
        ellipse(200, 200, 50, 50);
      }

      if (A==2) {
        MI.rewind();
        MI.play();
      }

      if (A==3) {
        FA.rewind();
        FA.play();
      }

      if (A==4) {
        SOL.rewind();
        SOL.play();
      }

      if (A==5) {
        LA.rewind();
        LA.play();
      }
      if (A==6) {
        TI.rewind();
        TI.play();
      }
      if (A==7) {
        DOO.rewind();
        DOO.play();
      }
      if (A==8) {
        delay(300);
      }

      if (A==9) {
        DO.rewind();
        DO.play();
      }
    }
  }
}
</code></pre>

<p>What can I do?
Thank you!!</p>
]]></description>
   </item>
   <item>
      <title>How to get sound files in processing.py</title>
      <link>https://forum.processing.org/two/discussion/23738/how-to-get-sound-files-in-processing-py</link>
      <pubDate>Mon, 07 Aug 2017 20:47:36 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">23738@/two/discussions</guid>
      <description><![CDATA[<p>I was looking at the forum as saw SoundFile() but this doesnt seem to work in python.  Any ideas</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>Minim Question: Is there a possibility to sync multiple mp3s?</title>
      <link>https://forum.processing.org/two/discussion/22960/minim-question-is-there-a-possibility-to-sync-multiple-mp3s</link>
      <pubDate>Tue, 06 Jun 2017 15:43:05 +0000</pubDate>
      <dc:creator>fransoletti</dc:creator>
      <guid isPermaLink="false">22960@/two/discussions</guid>
      <description><![CDATA[<p>Hello there, newbie here.</p>

<p>I made a sketch which plays 9 mp3 files simultaneously using Minim. Those 9 files represent a whole track split into its individual instruments. 
My problem is that the files are not being triggered at the exact same time and therefore don't play in sync.
Is there a way to preload the files in advance so processing can trigger them at the exact same time, or is there anything else i could do?</p>

<p>Thanks in advance! :)</p>

<pre><code>import ddf.minim.*;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
AudioPlayer player3;
AudioPlayer player4;
AudioPlayer player5;
AudioPlayer player6;
AudioPlayer player7;
AudioPlayer player8;
AudioPlayer player9;

void setup()
{
  size(1128, 575, P2D);
  minim = new Minim(this); 
  player = minim.loadFile("track1.mp3");
  player2 = minim.loadFile("track2.mp3");
  player3 = minim.loadFile("track3.mp3");
  player4 = minim.loadFile("track4.mp3");
  player5 = minim.loadFile("track5.mp3");
  player6 = minim.loadFile("track6.mp3");
  player7 = minim.loadFile("track7.mp3");
  player8 = minim.loadFile("track8.mp3");
  player9 = minim.loadFile("track9.mp3");
}

void draw()
{
  background(240);
  stroke(150, 100, 40); 

  //WAVEFORMS
  for (int i = 0; i &lt; player.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player.bufferSize(), 0, width);
    line( x1, 75 + player.left.get(i)*50, x2, 75 + player.left.get(i+1)*50 );
    line( x1, 100 + player.right.get(i)*50, x2, 75 + player.right.get(i+1)*50 );
  }

  stroke(20, 150, 90); 

  for (int i = 0; i &lt; player2.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player2.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player2.bufferSize(), 0, width);
    line( x1, 125 + player2.left.get(i)*50, x2, 125 + player2.left.get(i+1)*50 );
    line( x1, 150 + player2.right.get(i)*50, x2, 125 + player2.right.get(i+1)*50 );
  }

  stroke(0, 70, 130); 

  for (int i = 0; i &lt; player3.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player3.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player3.bufferSize(), 0, width );
    line( x1, 175 + player3.left.get(i)*50, x2, 175 + player3.left.get(i+1)*50 );
    line( x1, 200 + player3.right.get(i)*50, x2, 175 + player3.right.get(i+1)*50 );
  }

  stroke(80, 70, 130); 

  for (int i = 0; i &lt; player4.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player4.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player4.bufferSize(), 0, width );
    line( x1, 225 + player4.left.get(i)*50, x2, 225 + player4.left.get(i+1)*50 );
    line( x1, 250 + player4.right.get(i)*50, x2, 225 + player4.right.get(i+1)*50 );
  }

  stroke(#9CC6A1); 

  for (int i = 0; i &lt; player5.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player5.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player5.bufferSize(), 0, width );
    line( x1, 275 + player5.left.get(i)*50, x2, 275 + player5.left.get(i+1)*50 );
    line( x1, 300 + player5.right.get(i)*50, x2, 275 + player5.right.get(i+1)*50 );
  }


  stroke(#FA8A56); 

  for (int i = 0; i &lt; player6.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player6.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player6.bufferSize(), 0, width );
    line( x1, 325 + player6.left.get(i)*50, x2, 325 + player6.left.get(i+1)*50 );
    line( x1, 350 + player6.right.get(i)*50, x2, 325 + player6.right.get(i+1)*50 );
  }

  stroke(#1ACFFF);

  for (int i = 0; i &lt; player7.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player7.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player7.bufferSize(), 0, width );
    line( x1, 375 + player7.left.get(i)*50, x2, 375 + player7.left.get(i+1)*50 );
    line( x1, 400 + player7.right.get(i)*50, x2, 375 + player7.right.get(i+1)*50 );
  }

  stroke(#D567DE); 

  for (int i = 0; i &lt; player8.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player8.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player8.bufferSize(), 0, width );
    line( x1, 425 + player8.left.get(i)*50, x2, 425 + player8.left.get(i+1)*50 );
    line( x1, 450 + player8.right.get(i)*50, x2, 425 + player8.right.get(i+1)*50 );
  }

  stroke(#5A555A);

  for (int i = 0; i &lt; player9.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player9.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player9.bufferSize(), 0, width );
    line( x1, 475 + player9.left.get(i)*50, x2, 475 + player9.left.get(i+1)*50 );
    line( x1, 500 + player9.right.get(i)*50, x2, 475 + player9.right.get(i+1)*50 );
  }
}

void keyPressed()
{

    player.rewind();
    player.play();
    player2.rewind();
    player2.play();
    player3.rewind();
    player3.play();
    player4.rewind();
    player4.play();
    player5.rewind();
    player5.play();
    player6.rewind();
    player6.play();
    player7.rewind();
    player7.play();
    player8.rewind();
    player8.play();
    player9.rewind();
    player9.play();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I play the same soundfile multiple times simultaneously?</title>
      <link>https://forum.processing.org/two/discussion/21316/how-do-i-play-the-same-soundfile-multiple-times-simultaneously</link>
      <pubDate>Fri, 10 Mar 2017 17:24:01 +0000</pubDate>
      <dc:creator>Eiroth</dc:creator>
      <guid isPermaLink="false">21316@/two/discussions</guid>
      <description><![CDATA[<p>It sounds a bit strange, but basically I want a sound effect to play every time something special happens in my sketch, but the results vary from the soundfile only playing ones to cases where later attempts to play the file innterupts earlier instantations. I've tried both Minim and the processing Sound library, but I haven't been able to make it work. How could this be done?</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>Reading several files using multiple audioplayers, minim library</title>
      <link>https://forum.processing.org/two/discussion/19236/reading-several-files-using-multiple-audioplayers-minim-library</link>
      <pubDate>Wed, 23 Nov 2016 10:59:14 +0000</pubDate>
      <dc:creator>lolonulu</dc:creator>
      <guid isPermaLink="false">19236@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to read several files using multiple audioplayers with minim library.</p>

<p>There are 4 .wav files corresponding to a zone, when one plays the others stop.</p>

<p>I am stuck with the index and would very much appreciate some help.</p>

<p>Thanks a lot in advance !</p>

<p>best,
laurent</p>

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

Minim minim;
String [] fileNames = {"MOUSE", "WORDS", "FLOW", "VORTEX"};
int numSounds = fileNames.length-1;
int Border = 50;
/**AudioPlayer sounds1;
 AudioPlayer sounds2;
 AudioPlayer sounds3;
 AudioPlayer sounds4;*/
AudioPlayer [] sounds = new AudioPlayer[numSounds];
int idx;

void setup () {
  size(1080, 1080, P2D);
  minim = new Minim (this);
  /*sounds1 = minim.loadFile("MOUSE.wav");
   sounds2 = minim.loadFile("WORDS.wav");
   sounds3 = minim.loadFile("FLOW.wav");
   sounds4 = minim.loadFile("VORTEX.wav");*/

    for (byte idx = 0; idx != numSounds;
sounds[idx] = minim.loadFile (fileNames [idx++] +".wav"));

}
void draw() {
  background (255);
  fill(255, 0, 0);
  rect(25, 25, 50, 50);

  fill(0, 0, 255);
  rect(125, 25, 50, 50);
}

void mouseMoved() {
  if (mouseX &gt; Border &amp;&amp; mouseX &lt; 350) {
    sounds [(int)(idx)].play(); 

    println("sound0:"+sounds);
  } else if (mouseX &lt; 750) {

  } else {
  } 
  if (mouseX &lt; Border &amp;&amp; mouseX &gt; height-Border) {
  }

}
    void stop() {
      for ( byte idx = 0; idx != numSounds; sounds[idx++].close() );
      minim.stop();
      super.stop();
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sound (Minim)</title>
      <link>https://forum.processing.org/two/discussion/19343/sound-minim</link>
      <pubDate>Mon, 28 Nov 2016 01:23:00 +0000</pubDate>
      <dc:creator>imanseif</dc:creator>
      <guid isPermaLink="false">19343@/two/discussions</guid>
      <description><![CDATA[<p>Does anyone know how to add sound in processing? I want to add sound when my ball moves, which only moves when I click around the ball by a specific range max. I downloaded the song, saved the file in my processing code file, but still can't get it added in my codes.</p>
]]></description>
   </item>
   <item>
      <title>playing multiple tracks at the same time and adjusting volume</title>
      <link>https://forum.processing.org/two/discussion/19287/playing-multiple-tracks-at-the-same-time-and-adjusting-volume</link>
      <pubDate>Fri, 25 Nov 2016 03:03:16 +0000</pubDate>
      <dc:creator>kena1226</dc:creator>
      <guid isPermaLink="false">19287@/two/discussions</guid>
      <description><![CDATA[<p>This is for an art project. 
I'm trying to play 4 wav. files on an infinite loop at the volume 0.
when I press a button, the volume should rise up to 100.
each button is connected with a wav. file, so when I press button A, file A's volume would rise to 100.
I hope this makes things clear enough?</p>

<p>This is the ARDUINO code, I only have 2 wav files at the moment.</p>

<pre lang="c">
  int ledPin = 2;
  int ledPin3 = 3;
  int value = 0;

  void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, INPUT);
  pinMode(ledPin3, INPUT);
 
}
 
void loop()
{
  if (digitalRead(ledPin) == HIGH)
  {
    Serial.println("1");
    delay (50);
  }
  else
  {
   Serial.println("2");
   delay (50);
  }

    if (digitalRead(ledPin3) == HIGH)
  {
    Serial.println("3");
    delay (50);
  }
  else
  {
   Serial.println("4");
   delay (50);
  }
 
  
}

</pre>

<p>This is the PROCESSING file, also with two files.</p>

<pre lang="java">
import ddf.minim.*;
import processing.serial.*;
 
Serial port;
float value = 0;
float old = 0;
 
Minim minim;
AudioPlayer player;


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

  minim = new Minim(this);
  player = minim.loadFile("harp.wav");
  player.play();
  player.shiftGain(-80,-80,100);
  player.rewind();

 
  port = new Serial(this, "/dev/cu.usbmodem1421", 9600);
  port.bufferUntil('\n');
}
 
void draw()
{
  background(0);
  if ((value == 1) || (value == 2))
  {
  if (value != old)
  { 
  if (value == 1)
  {
    //volume up
    player.shiftGain(-80, 0, 100);
    
  }
 else if (value == 2)
 {
   //volume down
   player.shiftGain(0,-80,100);
  
 }
 
  }
 old = value;
 
}
}
void serialEvent (Serial port)
{
  value = float(port.readStringUntil('\n'));
}`

</pre>

<pre lang="java">

This is PROCESSING file version B, 

`import ddf.minim.*;
import processing.serial.*;
 
Serial port;
float value = 0;
 
Minim minim;
Minim minim2;
AudioPlayer player;
AudioPlayer player2;

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

  minim = new Minim(this);
  player = minim.loadFile("basses.wav");
  player.play();
  player.mute();
  player.rewind();
  
  minim2 = new Minim(this);
  player2 = minim2.loadFile("harp.wav");
  player2.play();
  player2.mute();
  player2.rewind();
 
 
  port = new Serial(this, "/dev/cu.usbmodem1421", 9600);
  port.bufferUntil('\n');
}
 
void draw()
{
  background(0);
  if (value == 2)
  {
    player.unmute();
    delay(3000);
    
  }
 if (value == 1);
 {
   player.mute();
   delay(3000);
  
 }
 
   if (value == 4)
  {
    player2.unmute();
    delay(3000);
    
  }
 if (value == 3);
 {
   player2.mute();
   delay(3000);
  
 }
 
}

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

</pre>

<p>The problem is that
a) files are not playing at the same time
b) it's clicking when the button is pressed
c) overall, it's not really responding to the button, just playing on and off by itself.
Any ideas or an easier way to do this maybe?
I really appreciate it.</p>
]]></description>
   </item>
   <item>
      <title>How can I make this sound play every time the snake eats a square?</title>
      <link>https://forum.processing.org/two/discussion/19159/how-can-i-make-this-sound-play-every-time-the-snake-eats-a-square</link>
      <pubDate>Sat, 19 Nov 2016 12:54:42 +0000</pubDate>
      <dc:creator>daniel00101</dc:creator>
      <guid isPermaLink="false">19159@/two/discussions</guid>
      <description><![CDATA[<p>So i'm makin' a snake game as a project, and fortunately i'm almost there. The last thing I need is to make a sound every time the snake eats one of the random squares, but as it is right now, it only plays the sound the first time. How can I fix this?</p>

<p>Another thing I don't know how to do is to make a restart button for the game over screen. How can I make a function that makes the game start all over again as if you closed the window and run the code over again?</p>

<p>Project file here, and make sure to have the minim audio extension installed!</p>

<p><a href="http://www.filedropper.com/snake_2" target="_blank" rel="nofollow">http://www.filedropper.com/snake_2</a></p>
]]></description>
   </item>
   <item>
      <title>Adding Sound to a Object when it is clicked. (URGENT!!!)</title>
      <link>https://forum.processing.org/two/discussion/18955/adding-sound-to-a-object-when-it-is-clicked-urgent</link>
      <pubDate>Wed, 09 Nov 2016 08:18:47 +0000</pubDate>
      <dc:creator>DannyM220</dc:creator>
      <guid isPermaLink="false">18955@/two/discussions</guid>
      <description><![CDATA[<p>Okay Guys! So, basically I want to be able to incorporate a 'Ding' sound using the minim library that is played every time the Target is hit, which in this case is our Saucer.png. The problem is not with registering a click on the saucer but rather being able to incorporate the code necessary so when the Target is hit, it will play the sound and then continue to do so everytime it is hit</p>

<p>Here is my code:
    import ddf.minim.*;
    int rad = 60;                                   // Width of the shape
    float xpos, ypos;                               // Starting position of shape<br />
    float xspeed = 2.0;                             // Speed of the shape
    float yspeed = 2.0;                             // Speed of the shape<br />
    int xdirection = 1;                             // Left or Right
    int ydirection = 1;                             // Top to Bottom
    int score=0;                                     //Inital score
    int lives=5;                                     //Number of lives you start with
    boolean lost=false;                              //Have you lost yet?<br />
    int speed=1;<br />
    PImage bg;
    PImage Target;
    int y;
    AudioPlayer player;
    Minim minim;</p>

<pre><code>void setup() 
{
  size(736,460);
  minim = new Minim(this);
  fill(255,255,255);
  noStroke();
  frameRate(60);
  Target = loadImage("Saucer (1).png");
  xpos = width/2;                                 // Set the starting position of the shape
  ypos = height/2;
  bg = loadImage("space 2.jpg");                  //Load Image (jpg,png,gif)
  player = minim.loadFile("Song 1.mp3");          //Load Audio File (mp3,wav)
  player.loop();

}

void draw() 
{
  background(bg);
  image(Target,xpos,ypos,60,60);
  xpos = xpos + ( xspeed * xdirection );         // Update the position of the shape
  ypos = ypos + ( yspeed * ydirection );


  if (xpos &gt; width-rad || xpos &lt; rad) {          // Test to see if the shape exceeds the boundaries of the screen
                                                 // If it does, reverse its direction by multiplying by -1
    xdirection *= -1; 
  }
  if (ypos &gt; height-rad || ypos &lt; rad) {
    ydirection *= -1;
  }
  text("score = "+score,10,10);                     //Print the score on the screen
  text("lives = "+lives,width-80,10);               //Print remaining lives
  if (lives&lt;=0)                                     //Check to see if you lost
  {
    textSize(50);
    text("Click to Restart", 450,200);
    noLoop();                                       //Stop looping at the end of the draw function
    lost=true;
    textSize(13);
  }
}
void mousePressed()                                 //Runs whenever the mouse is pressed
{
  if (dist(mouseX, mouseY, xpos, ypos)&lt;=rad)        //Did we hit the target?
  {
    score=score+speed;                              //Increase the speed
    speed=speed+1;                                  //Increase the Score
  }
  else                                              //We missed
  {
    if (speed&lt;1)                                    //If speed is greater than 1 decrease the speed
    {
    speed=speed-1;
    }
    lives=lives-1;                                  //Take away one life
  }
  if (lost==true)                                   //If we lost the game, reset now and start over 
  {
    speed=1;                                        //Reset all variables to initial conditions
    lives=5;
    score=0;
    xpos=width/2;
    xdirection=1;
    lost=false;
    loop();                                         //Begin looping draw function again
  }
}
</code></pre>

<p>Thank you to everyone that can help me, feel free to give me code or modify the code above as well as provide  links to reference pages!</p>
]]></description>
   </item>
   <item>
      <title>Minim Loop when If(true)</title>
      <link>https://forum.processing.org/two/discussion/18673/minim-loop-when-if-true</link>
      <pubDate>Sun, 23 Oct 2016 19:29:17 +0000</pubDate>
      <dc:creator>liong4x</dc:creator>
      <guid isPermaLink="false">18673@/two/discussions</guid>
      <description><![CDATA[<pre><code>import ddf.minim.*;

Minim minim;
AudioPlayer player;

void setup() {
  minim = new Minim(this);
  player = minim.loadFile("alert.mp3");
}

void draw() {
  if (true) {
    player.loop();
  }
}
</code></pre>

<p>I want to do when If statement is true let the song loop.
But, It always stay at first second, don't go around.</p>

<p>I have tried rewind + play, it has same problem. 
I want to loop, when If is true.</p>

<p>help me...</p>
]]></description>
   </item>
   <item>
      <title>Error message when using Minim</title>
      <link>https://forum.processing.org/two/discussion/17071/error-message-when-using-minim</link>
      <pubDate>Thu, 09 Jun 2016 18:46:11 +0000</pubDate>
      <dc:creator>dtools22</dc:creator>
      <guid isPermaLink="false">17071@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I'm writing a program that has a sound effect play when an image pops up on screen.  The code appears to be working but I get the following error message in my command window at the bottom of the IDE.</p>

<pre><code>==== JavaSound Minim Error ====
==== Don't know the ID3 code PRIV
</code></pre>

<p>What exactly is causing this error?  Here is my code.  Thanks in advance for any help.</p>

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

Minim minim;
AudioPlayer tick;

String codeword;
PImage [] bground;

int i = 0;  //This variabe will be used to change the background images
int k = 0;  //This variable loads in the different images
int n = 4;  //The number of images for the background that we need
long bgroundtimer = 0;

void setup(){
  size(700, 500);
  background(0);
  bground = new PImage[n];
  for(k = 0; k &lt; bground.length; k++){
    bground[k] = loadImage("C:/Users/Steven/Documents/Processing/My Saves/Word_Clock_Final/Background/bground" + k + ".png");
  }
  minim = new Minim(this);
  tick = minim.loadFile("C:/Steven/Processing/Tick.mp3");
}

void draw(){
   if(i &lt; bground.length){
     image(bground[i], 0, 0);
     if(millis() - bgroundtimer &gt;= 5000){
       bgroundtimer = millis();
       tick.play();
       tick.rewind();
       i++;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I make the text to sound?</title>
      <link>https://forum.processing.org/two/discussion/16862/how-can-i-make-the-text-to-sound</link>
      <pubDate>Sat, 28 May 2016 12:28:36 +0000</pubDate>
      <dc:creator>jeremy_wilde</dc:creator>
      <guid isPermaLink="false">16862@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys, I asked this once, but still can't make it works..</p>

<p>I want to make the sentence I make to convert little melody when enterkey pressed.</p>

<p>those are codes</p>

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

Minim minim; 
AudioPlayer c, d, e, f, g, a, b;

PFont font; 
int num = 500; 
char t[] = new char[num]; 
int key_num = 0; 
int text_w_gap = 30; 
int text_h_gap = 50; 
int ypos = 50; 
int xpos = 10; 
int val;

boolean playSong=false;

void setup() { 
  size(500, 400); 
  font = createFont("whiteday10-48.vlw", 14); 
  textFont(font, 32); 
  fill(7,161,8);
  minim = new Minim(this);

  c = minim.loadFile("c.mp3"); 
  d = minim.loadFile("d.mp3"); 
  e = minim.loadFile("e.mp3"); 
  f = minim.loadFile("f.mp3"); 
  g = minim.loadFile("g.mp3"); 
  a = minim.loadFile("a.mp3");
}

void draw() { 
  background(0);

  if (playSong) { 
    for (int i=0; i&lt;key_num; i++) { 
      playNote(t[i]);
    }
  } else
  { 
    for (int i=0; i&lt;key_num; i++) { 
      text(t[i], 
        (xpos+(i*text_w_gap))%width, 
        ypos+( (int(xpos+(i*text_w_gap))) / width * text_h_gap));
    } 
    if (key_num &gt;= num) { 
      key_num = 0;
    }
  }
}

void keyPressed() { 
  if (key!=8) { 
    t[key_num] = key; 
    key_num++;
  } else if (key==RETURN||key==ENTER) { 
    playSong=true;
  } else if (key==8) { 
    key_num--;
  } 
  println("pressed " + int(key) + " " + keyCode);
}

void playNote(int KeyCode) { 
  if (KeyCode==65) { 
    c.play();
  }
  if (KeyCode==66) { 
    d.play();
  }
  if (KeyCode==67) { 
    e.play();
  }
  if (KeyCode==68) { 
    f.play();
  }
  if (KeyCode==69) { 
    g.play();
  }
  if (KeyCode==70) { 
    a.play();
  }
  if (KeyCode==71) {
    b.play();
  }
}
</code></pre>

<p>keycodes are just examples..</p>

<p>I hope someone shows me the functional code that I can understand.
thanks for reading..</p>
]]></description>
   </item>
   <item>
      <title>How can I make this idea possible? (sound alphabet)</title>
      <link>https://forum.processing.org/two/discussion/16855/how-can-i-make-this-idea-possible-sound-alphabet</link>
      <pubDate>Fri, 27 May 2016 17:33:40 +0000</pubDate>
      <dc:creator>jeremy_wilde</dc:creator>
      <guid isPermaLink="false">16855@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm 22yo design major student.</p>

<p>Sorry for the bad english. I might be suck to understand.
I try to make some kind of interaction work that by writing some words,
It becomes a short melody on processing. And you can see your typewriting like usual web environment.
It don't have to be a certain word and I try to make them sound when enterkey pressed.</p>

<p>this is the example)</p>

<p>In blank space, cursor blinking. You write some short sentences. 
  You press enterkey. It becomes little melody that matched the keycode that you pressed.
  Like if you write 'a little butterfly' It became 'a' note melody~ 'l' note melody~ 'i' note melody~.</p>

<p>I used Pfont function for the text and Minim for the sound part.
However I can't make them work togher.</p>

<p>A little example will helps me to understand, I really appreciate.</p>

<p>Thanks for reading this mess.</p>
]]></description>
   </item>
   <item>
      <title>Use an Array of mp3 files which when on keyPressed plays a random selection from it at the same time</title>
      <link>https://forum.processing.org/two/discussion/15739/use-an-array-of-mp3-files-which-when-on-keypressed-plays-a-random-selection-from-it-at-the-same-time</link>
      <pubDate>Tue, 29 Mar 2016 02:07:26 +0000</pubDate>
      <dc:creator>vincepat</dc:creator>
      <guid isPermaLink="false">15739@/two/discussions</guid>
      <description><![CDATA[<p>I know it seems convoluted, Im struggling to play more than one track at a time using minim.
I would like to know how to set up an array of maybe 10 tracks I have  (bass,chords,melody etc), then on a key command to play a random selection of maybe four of the ten tracks at the same time, ?</p>

<p>Is this difficult to do?
Any pointers very much appreciated.</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>
   </channel>
</rss>