<?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 trigger() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=trigger%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:52:17 +0000</pubDate>
         <description>Tagged with trigger() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedtrigger%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>[minim] Saving audioSample to .wav</title>
      <link>https://forum.processing.org/two/discussion/27965/minim-saving-audiosample-to-wav</link>
      <pubDate>Mon, 14 May 2018 08:19:23 +0000</pubDate>
      <dc:creator>AiSard</dc:creator>
      <guid isPermaLink="false">27965@/two/discussions</guid>
      <description><![CDATA[<p>I recorded with audioRecorder, then converted it to audioSample to access it's arrays and mess around with the sounds (playing it back with .trigger() ) But I'm now stumped on how to actually save this audioSample to a .wav
(the audioRecorder has to be able to record all the while in parallel with whatever the method for saving is as well..)</p>

<p>Hopefully someone has a method that could work for this? Diving deeper in to the library but no glimpse of how to achieve this yet :(</p>
]]></description>
   </item>
   <item>
      <title>Double buffering?? But how do I do this!? - Programmers please assist!</title>
      <link>https://forum.processing.org/two/discussion/26742/double-buffering-but-how-do-i-do-this-programmers-please-assist</link>
      <pubDate>Fri, 09 Mar 2018 20:49:10 +0000</pubDate>
      <dc:creator>rpinkall</dc:creator>
      <guid isPermaLink="false">26742@/two/discussions</guid>
      <description><![CDATA[<p>Working in Processing, I have a generative program that creates a random colorful image.</p>

<p>An ellipse randomizes its direction each frame and draws on the canvas, leaving it's trail, creating the art canvas.
furthermore, everytime the ellipse hits the edge of the screen, it returns to the middle, with a new color, and begins again.</p>

<p>I want to have this giphy of bob ross follow the same location of the randomized x and y, of the ellipse that draws.
yet, I don't want bobross also to leave a trail on the screen, for it ruins the art.</p>

<p>this is my code:</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[] bobross = new PImage[78];
int counter = 0;

Minim minim;
AudioSample boop;
AudioSample boopp;
AudioPlayer bg;


float ex = 0;
float ey = 0;
float direction = random(-3, 3);
float ddirection = random(-3, 3);
String str = "01234";
int p0 = str.indexOf("0");
int p1 = str.indexOf("1");
int p2 = str.indexOf("2");
int p3 = str.indexOf("3");
int p4 = str.indexOf("4");



void setup() {
  size(1200, 600);
  ex = width/2;
  ey = height/2;
  background(255);

  imageMode(CENTER);
  for (int i = 0; i &lt; bobross.length; i++) {
    bobross[i]= loadImage("data/bobross" + nf(i, 1) + ".png");
  }

  frameRate(140);
  minim  = new Minim(this);
  boop = minim.loadSample("boop.mp3", 512);
  bg = minim.loadFile("bach.mp3", 1024);
  bg.loop();
}

void draw() {
    if (frameCount % 6 == 0) {
    if (counter &gt;= 77) {
      counter = 0;
    } else {
      counter++;
    }
  }


  image(bobross[counter], ex, ey);


  ellipse(ex, ey, 12, 12);
  ex += direction;
  ey += ddirection;
  direction = random(-10, 10);
  ddirection = random(-10, 10);

  if ( ex &gt; width || ex &lt; 0) {

    textSize(32);
    text(p0++, random(100,1100), random(100,500));
    fill(0, 102, 153);
    ex = 600;
    ey = 300;
    ex += direction;
    ey += ddirection;
    boop.trigger();
    stroke(random(0,255),random(0,255),random(0,255));

  }

  if (ey &gt; height || ey &lt; 0) {

    textSize(32);
    text(p0++, random(100,1100), random(100,500));
    fill(0, 102, 153);

    ex = 600;
    ey = 300;
    ex += direction;
    ey += ddirection;
    direction = random(-10, 10);
    ddirection = random(-10, 10);
    boop.trigger();
    stroke(random(0,255),random(0,255),random(0,255));



    fill(random(0, 255), random(0, 255), random(0, 255));
  }
}

void keyPressed() {
  if (key=='s')
    saveFrame();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Why can I only load four audio files in Minum</title>
      <link>https://forum.processing.org/two/discussion/21953/why-can-i-only-load-four-audio-files-in-minum</link>
      <pubDate>Wed, 12 Apr 2017 13:57:03 +0000</pubDate>
      <dc:creator>Grumpy_Mike</dc:creator>
      <guid isPermaLink="false">21953@/two/discussions</guid>
      <description><![CDATA[<p>I want to play a sound file controlled by a number.
I have written this simplified code:-</p>

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

Minim minim;
AudioPlayer [] player= new AudioPlayer[5];

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

player[0] = minim.loadFile("1.wav");
player[1] = minim.loadFile("1.wav");
player[2] = minim.loadFile("1.wav");
player[3] = minim.loadFile("1.wav");
player[4] = minim.loadFile("1.wav");
}

void draw()
{ }
</code></pre>

<p>So I am loading in the same file five times. Four times it works fine but the fifth gives an error message:-
    ==== JavaSound Minim Error ====
    ==== Unable to return a SourceDataLine: unsupported format - PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian</p>

<pre><code>=== Minim Error ===
=== Couldn't load the file 1.wav
</code></pre>

<p>It is the same file so how can the format be wrong?
I am using a Raspberry Pi, and four files ( different ones ) will play fine but when I extend it to 5 or above it fails.
Is their another way to do what I want?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>I'm trying to use minim to create a sounds when the balls collide, but i'm a bit lost. Thank you!</title>
      <link>https://forum.processing.org/two/discussion/21211/i-m-trying-to-use-minim-to-create-a-sounds-when-the-balls-collide-but-i-m-a-bit-lost-thank-you</link>
      <pubDate>Mon, 06 Mar 2017 21:21:51 +0000</pubDate>
      <dc:creator>framos</dc:creator>
      <guid isPermaLink="false">21211@/two/discussions</guid>
      <description><![CDATA[<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.*;


    Ball[] balls =  { 
      new Ball(100, 400, 20), 
      new Ball(700, 400, 80)
    };


      Minim minim;

      Sampler b;

      AudioOutput out;

      Sampler d;

    void setup() {
      size(640, 360);
      minim = new Minim(this);
      b = new Sampler("Bell.mp3", 100, minim);
      out = minim.getLineOut();
      d = new Sampler("Door.mp3", 3, minim);

    }

    void draw() {
    background(51);
    for (Ball b : balls) {
    b.update();
    b.display();

       b.checkBoundaryCollision();
      }

  balls[0].checkCollision(balls[1]);
}

void mouseMoved () {

  b.trigger();

  d.trigger();
}

class Ball {

  PVector position;

  PVector velocity;

  float radius, m;

  Sampler sampler;


  Ball(float x, float y, float r_, Sampler a) {

    Sampler = a;

    position = new PVector(x, y);

    velocity = PVector.random2D();

    velocity.mult(3);

    radius = r_;

    m = radius*.1;
  }

  void update() {

    position.add(velocity);
  }

  void checkBoundaryCollision() {

    if (position.x &gt; width-radius) {

      position.x = width-radius;

      velocity.x *= -1;

      triggerSample();

    } else if (position.x &lt; radius) {

      position.x = radius;

      velocity.x *= -1;

    } else if (position.y &gt; height-radius) {

      position.y = height-radius;

      velocity.y *= -1;

    } else if (position.y &lt; radius) {

      position.y = radius;

      velocity.y *= -1;
    }
  }

  void checkCollision(Ball other) {


    PVector distanceVect = PVector.sub(other.position, position);

    float distanceVectMag = distanceVect.mag();


    float minDistance = radius + other.radius;

    if (distanceVectMag &lt; minDistance) {
      float distanceCorrection = (minDistance-distanceVectMag)/2.0;
      PVector d = distanceVect.copy();
      PVector correctionVector = d.normalize().mult(distanceCorrection);
      other.position.add(correctionVector);
      position.sub(correctionVector);

      float theta  = distanceVect.heading();

      float sine = sin(theta);
      float cosine = cos(theta);


      PVector[] bTemp = {
        new PVector(), new PVector()
      };


      bTemp[1].x  = cosine * distanceVect.x + sine * distanceVect.y;
      bTemp[1].y  = cosine * distanceVect.y - sine * distanceVect.x;


      PVector[] vTemp = {
        new PVector(), new PVector()
      };

      vTemp[0].x  = cosine * velocity.x + sine * velocity.y;
      vTemp[0].y  = cosine * velocity.y - sine * velocity.x;
      vTemp[1].x  = cosine * other.velocity.x + sine * other.velocity.y;
      vTemp[1].y  = cosine * other.velocity.y - sine * other.velocity.x;


      PVector[] vFinal = {  
        new PVector(), new PVector()
      };

      vFinal[0].x = ((m - other.m) * vTemp[0].x + 2 * other.m * vTemp[1].x) / (m + other.m);
      vFinal[0].y = vTemp[0].y;

      vFinal[1].x = ((other.m - m) * vTemp[1].x + 2 * m * vTemp[0].x) / (m + other.m);
      vFinal[1].y = vTemp[1].y;


      bTemp[0].x += vFinal[0].x;
      bTemp[1].x += vFinal[1].x;


      PVector[] bFinal = { 
        new PVector(), new PVector()
      };

      bFinal[0].x = cosine * bTemp[0].x - sine * bTemp[0].y;
      bFinal[0].y = cosine * bTemp[0].y + sine * bTemp[0].x;
      bFinal[1].x = cosine * bTemp[1].x - sine * bTemp[1].y;
      bFinal[1].y = cosine * bTemp[1].y + sine * bTemp[1].x;

      other.position.x = position.x + bFinal[1].x;
      other.position.y = position.y + bFinal[1].y;

      position.add(bFinal[0]);


      velocity.x = cosine * vFinal[0].x - sine * vFinal[0].y;
      velocity.y = cosine * vFinal[0].y + sine * vFinal[0].x;
      other.velocity.x = cosine * vFinal[1].x - sine * vFinal[1].y;
      other.velocity.y = cosine * vFinal[1].y + sine * vFinal[1].x;
    }
  }

  void display() {

    noStroke();

    fill(204);

    ellipse(position.x, position.y, radius*2, radius*2);

  }
  void triggerSample(){

    sampler.rate.setLastValue(10 / radius);

    sampler.trigger();
  }
}

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>MINIM - I got so far then got stuck -random audio player</title>
      <link>https://forum.processing.org/two/discussion/15771/minim-i-got-so-far-then-got-stuck-random-audio-player</link>
      <pubDate>Wed, 30 Mar 2016 21:25:17 +0000</pubDate>
      <dc:creator>vincepat</dc:creator>
      <guid isPermaLink="false">15771@/two/discussions</guid>
      <description><![CDATA[<p>Im trying to make .mp3 audio play from 3 separate arrays randomly.
Each Array has 3 or 4 tracks. On a key or mouse press i want each array to play one track at the same time. Then on mouse press repeat and play a different 3 tracks.</p>

<p>My code is incomplete but I have</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.*;

import ddf.minim.*;

Minim minim;
AudioSample[] songArray = new AudioSample [10];

void setup()
{
  size(100, 100);
   minim = new Minim(this);
 for (int i = 0 ; i &lt; 3 ; i++) {
  songArray[i] = minim.loadSample("sound" + i +".mp3");
 }
  for (int p = 0 ; p &lt; 3 ; p++) {
  songArray[p] = minim.loadSample("sounds" + p +".mp3");
 }
  for (int s = 0 ; s &lt; 4 ; s++) {
  songArray[s] = minim.loadSample("soundss" + s +".mp3");
 }

}

void draw()
{

}

 void mousePressed(){

 .play();

 }
</code></pre>

<p>If anyone can add useful pointers I'd be grateful</p>

<p>thanks</p>
]]></description>
   </item>
   </channel>
</rss>