<?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 amp() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=amp%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:57:01 +0000</pubDate>
         <description>Tagged with amp() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedamp%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <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>Sound synthesis on Android (Oscillators)</title>
      <link>https://forum.processing.org/two/discussion/25633/sound-synthesis-on-android-oscillators</link>
      <pubDate>Mon, 18 Dec 2017 21:24:22 +0000</pubDate>
      <dc:creator>snebtor</dc:creator>
      <guid isPermaLink="false">25633@/two/discussions</guid>
      <description><![CDATA[<p>Hi!
I am looking for some advice on what tool to use to play generative sounds into an android device.
So far I have had success playing .wav and .mp3 files using the "Cassette" library. However, what I want is to use a sound synthesizer like the one available for Processing 3: import processing.sound.*;
Using functions to control oscillators, envelopes (etc.) for example:
sine.amp(amp);
sine.pan();
SinOsc
SawOsc
SqrOsc
TriOsc
Pulse</p>

<p>Thank you!
E</p>
]]></description>
   </item>
   <item>
      <title>I have tried do change the volume of a synth in p5.sound.js, it hasnt worked</title>
      <link>https://forum.processing.org/two/discussion/23449/i-have-tried-do-change-the-volume-of-a-synth-in-p5-sound-js-it-hasnt-worked</link>
      <pubDate>Fri, 14 Jul 2017 22:18:26 +0000</pubDate>
      <dc:creator>truffel</dc:creator>
      <guid isPermaLink="false">23449@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have a synth that goes like this:</p>

<pre><code>var attackLevel4 = 1.0;
var releaseLevel4 = 0;

var attackTime4 = 0.1;
var decayTime4 = 0.2;
var susPercent4 = 0.01;
var releaseTime4 = 0.5;

var env4, sinOsc4;

env4 = new p5.Env();
  env4.setADSR(attackTime4, decayTime4, susPercent4, releaseTime4);
  env3.setRange(attackLevel3, releaseLevel3);

  sinOsc4 = new p5.Oscillator('sine');
  sinOsc4.amp(env4);
  sinOsc4.start();
  sinOsc4.freq(546);

function playEnv4(){
  env4.play();
}
</code></pre>

<p>The function setVolume() did not work, it sends an error in the console. So based on <a rel="nofollow" href="https://github.com/processing/p5.js-sound/issues/182">https://github.com/processing/p5.js-sound/issues/182</a> , I tried to modify the p5.sound.js file in line 1065, but It really doesn't  make a difference. Because I beleive the next thing shouldn't sound at all:</p>

<pre><code>function playEnv4(){
  env4.play(0, 0, 0);
}
</code></pre>

<p>But it sounds with the same volume. And the same thing happens if I move the "volume" to 0.5, 0.001, 0.8, etc</p>

<p>How could I change the volume of my synth in an efficient way?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>An object, which itself contains an array of objects</title>
      <link>https://forum.processing.org/two/discussion/23269/an-object-which-itself-contains-an-array-of-objects</link>
      <pubDate>Fri, 30 Jun 2017 16:23:11 +0000</pubDate>
      <dc:creator>danlj</dc:creator>
      <guid isPermaLink="false">23269@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm trying to create an object, which itself contains an array of p5.Oscillator objects, but I can't get the code to work the way I want it to. I would like to be able to have a separate methods for playing the sound, changing the frequency, etc... but I can't seem to access p5.Oscillator's methods outside of the function in which I fill the 'this.harmonic' array with instances of the p5.Oscillator object. I keep getting the error: Cannot read property 'start' of undefined.</p>

<p>I'm probably going about this the complete wrong way, but I've posted my code below. Any ideas on what i'm doing wrong?</p>

<pre><code>function Wavetable(theFreq, theAmp, theMaxHarmonics) {
    this.freq = theFreq;
    this.amp = theAmp;
    this.maxHarmonics = theMaxHarmonics;
    this.harmonic = []

    this.init = function() {    
           for(var i = 1; i &lt;= this.maxHarmonics; i++) {
            this.harmonic[i] = new p5.Oscillator();
            this.harmonic[i].setType('sine');
            this.harmonic[i].freq(this.freq * (i+1));
            this.harmonic[i].amp(this.amp / (i+1));
            // this.harmonic[i].start(); // &lt;- This works fine
        }
    };

    this.play = function() {
        for(var i = 0; i &lt; this.harmonic.length; i++) {
            this.harmonic[i].start();  // &lt;- This gives an error: "Cannot read property 'start' of undefined"
        }
     }; 

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>My program slows down when executed several times - buffer problem?</title>
      <link>https://forum.processing.org/two/discussion/20748/my-program-slows-down-when-executed-several-times-buffer-problem</link>
      <pubDate>Sat, 11 Feb 2017 12:25:58 +0000</pubDate>
      <dc:creator>ruski15</dc:creator>
      <guid isPermaLink="false">20748@/two/discussions</guid>
      <description><![CDATA[<p>Apologies for my ignorance but I am trying to run this code and I feel it is less sensitive to the mouse movement when I run it several times. Please try it and let me know. It happens when you press Silence and then Sound again. The more you do it the slower it gets.</p>

<p>Is this a buffer problem?</p>

<p>Any solutions?</p>

<p>Thank you!</p>

<p>[code below]</p>
]]></description>
   </item>
   <item>
      <title>How to run multiple sinOscs in class objects</title>
      <link>https://forum.processing.org/two/discussion/16625/how-to-run-multiple-sinoscs-in-class-objects</link>
      <pubDate>Sun, 15 May 2016 20:02:50 +0000</pubDate>
      <dc:creator>_spaces</dc:creator>
      <guid isPermaLink="false">16625@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, new to Processing and would appreciate some help!</p>

<p>I'm trying to make a class where each instance of it has a sinOsc playing at a different frequency, with a slowly decreasing (and then increasing) volume for each.  I can't find much in the way of in-depth tutorials on this object, and am stuck!  here's the code:</p>

<pre><code>PImage img;
import processing.sound.*;
SinOsc sine;


Sphere s1;
Sphere s2;

void setup() {
  size(665, 800);
  img = loadImage("MK.png");
  s1 = new Sphere(random(0, (img.height/2)), random(0, (img.width/2)), 255, 10);
  s2 = new Sphere(random(0, (img.height/2)), random(0, (img.width/2)), 255, 17);
  sine = new SinOsc(this);
  image (img, 0, 0, img.width/2, img.height/2);

  s1.bells();
  s2.bells();
}

//variables
int time = millis();  


void draw() {
  s1.run();
  s2.run();


}
</code></pre>

<p>`</p>

<p>and for the class (Sphere) itself:</p>

<pre><code>class Sphere {

  //GLOBAL
  float xpos = 0;//set variables for the class, default for all of this type
  float ypos = 0;
  int col1 = 255;
  int decay = 8;
  int timer;
  Float amp = 0.5;
  Float freq = (random(80, 400));
  int trans = 255;



//CONSTRUCTOR
    Sphere(float _xpos, float _ypos, int _col1, int _decay){
      xpos = _xpos;//args for each instantiation can then alter the global vars
      ypos = _ypos;
      col1 = _col1;
      decay = _decay;
    }


void run(){
  display();

}

void display(){
fill(col1, 0, 0, trans);
  ellipse(xpos, ypos, 10, 10);//global vars now altered to reflect creation args

  if (millis() - timer &gt;= (decay * 10)){
     trans = trans - 10;
     amp = amp - 0.1;
     timer = millis();
   }

  if (trans &lt;= 0){
     trans = 255;
   }
}

void bells(){

  sine.play();
  sine.freq(freq);
  sine.amp(amp);

}
}
</code></pre>

<p>Any help would be appreciated!</p>
]]></description>
   </item>
   <item>
      <title>something wrong with this sketch ? please need direction .. (p5 oscillator)</title>
      <link>https://forum.processing.org/two/discussion/15914/something-wrong-with-this-sketch-please-need-direction-p5-oscillator</link>
      <pubDate>Fri, 08 Apr 2016 04:00:39 +0000</pubDate>
      <dc:creator>wierdweird</dc:creator>
      <guid isPermaLink="false">15914@/two/discussions</guid>
      <description><![CDATA[<p>I tried to play with audio and tried to form object with a oscillator as one of its property ,did mange get some sounds ,but does stop making noises after a while (same count every time ).I am pretty sure i got something wrong but cant figure out 
here is script ..would be nice if  u cud point me in the rite direction.thanks</p>

<p>var canvas;
var counter=0;
var boby=0 ;
var obj1 = 0;
var obj2 = 1;
var obj3 = 2;
var changesize=0;
var attackLevel = 1.0;
var releaseLevel = 0;
var attackTime = 0.001
var decayTime = 0.1;
var susPercent = 0.2;
var releaseTime = 0.5;
var env, Osc;
var state;
var start;
function setup(){
masterVolume(0.06);
canvas= createCanvas(displayWidth/2,displayHeight/2);
noStroke();
noLoop();
canvas.mousePressed(theplanes);</p>

<p>}</p>

<p>function theplanes(){</p>

<p>ourtimer(300,70,2,800,500);</p>

<p>}</p>

<p>function sound(freq){
env = new p5.Env();
env.setADSR(attackTime, decayTime);
env.setRange(attackLevel, releaseLevel);
Osc = new p5.Oscillator('sawtooth');
Osc.amp(env);
Osc.start();
Osc.freq(freq);
env.play();
}</p>

<p>function ourtimer(xloc,yloc,count,freq,wait){</p>

<p>setInterval(plane1,wait,xloc,yloc,count,freq);</p>

<p>function plane1(xloc,yloc,count,freq){</p>

<p>sound(freq);
var size= (map(sin(changesize),-1,1,0,60));</p>

<p>colorvalues=255/count;
steps=size/count;</p>

<p>for (i = 0; i &lt; count; i++) {
fill(i<em>colorvalues);
stroke(0);
strokeWeight(1);
rectMode(CENTER);
rect(xloc, yloc, size - i</em>steps, size - i*steps);</p>

<p>} 
changesize++;</p>

<p>}</p>

<p>}
function draw(){
background(100);</p>

<p>}﻿</p>
]]></description>
   </item>
   <item>
      <title>Action triggered by a sound level</title>
      <link>https://forum.processing.org/two/discussion/14774/action-triggered-by-a-sound-level</link>
      <pubDate>Fri, 05 Feb 2016 17:46:36 +0000</pubDate>
      <dc:creator>monkeyspasm</dc:creator>
      <guid isPermaLink="false">14774@/two/discussions</guid>
      <description><![CDATA[<p>I'm building an art installation controlled my processing. In the previous version of it, the sound played was triggered by a mouse press and a key press using MakeyMakey keyboard durning a test run. As my research is done about the reactions of the users to the experience, i'm shifting the code to something different. I'd like to make a final installation be triggered not by a key or mouse press, but by a sound of surrounding environment, so a sound would be played when the noise level captured by a microphone reaches a certain level.</p>

<p>What code could I use for it? Is there any tutorial about the microphone triggers?</p>

<p>Here is my code from the previous run if anyone would be keen to suggest changes.</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 processing.sound.*;
import processing.video.*;
Minim minim;
AudioPlayer one; //variable name
AudioPlayer male;
Capture cam;

void setup(){
//println(Capture.list());
  //size(640,360);
  fullScreen();

 cam = new Capture(this,1280,720,30);
  cam.start();


  minim = new Minim(this);
  one =minim.loadFile("german.wav");
 male=minim.loadFile("male.wav");

}

void draw(){

  //background(0);
 if (cam.available()) {
    cam.read();
if (mousePressed == true);    
     saveFrame();
  }


image(cam,0,0);

}

void mousePressed(){
 //if (mousePressed == true);
  one.play();
  cam.start();
  //  saveFrame();
}

void mouseReleased()
{
  if (mousePressed || true);
  one.close();
  one =minim.loadFile("german.wav");
  //cam.close() 
  //cam.stop(); 
}

void keyPressed()
{
  if (key == ' ' );
  male.play();

}

void keyReleased(){
  male =minim.loadFile("male.wav");
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Non-Linear/Exponential Sound</title>
      <link>https://forum.processing.org/two/discussion/14692/non-linear-exponential-sound</link>
      <pubDate>Sat, 30 Jan 2016 19:37:21 +0000</pubDate>
      <dc:creator>Annakinsnywalker</dc:creator>
      <guid isPermaLink="false">14692@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>How do I create non-linear/exponential sound with sinewave code. 
Below is the code I am currently working with. The frequency is very choppy.</p>

<p>Thanks</p>

<pre><code>    import processing.serial.*;
    import processing.sound.*;
    import cc.arduino.*;

    Arduino arduino;
    SinOsc sine;

    int total1;
    //int total2;
    //int total3;

    float freq=400;
    float amp=0.5;
    float pos;

    void setup() {
      // window size
      size(470, 280);
      background(0);
      // print out all the device connected to serial ports
      println(Arduino.list());

      arduino = new Arduino(this, Arduino.list()[1], 57600);

       // Create and start the sine oscillator.
       sine = new SinOsc(this);

       //Start the Sine Oscillator. 
       sine.play();

    }

    void draw() {
      fill(0,0,0,5);
      rect(0,0,width,height);


     // read capacitive sensor value sent via firmata 
      total1=arduino.analogRead(8) ;

     print("total1 : ");
     print(total1);
     println();

    if (total1 &gt;=40 &amp;&amp; total1 &lt;=1200){
    // Map from 0.0 to 1.0 for amplitude
      amp=map(total1, 40, 1200, 0.0, 1.0);
      sine.amp(amp);
    } else if (total1 &lt;=40) {
      amp = 0;
      sine.amp(amp);
    }
      println(total1);

      if (total1 &gt;=40 &amp;&amp; total1 &lt;=1200){

    // Map from 20Hz to 1000Hz for frequency  
        freq=map(total1, 40, 1200, 500.0, 1000.0);
        sine.freq(freq);

      }

      // Map from -1.0 to 1.0 for left to right 
      pos=0.0;//map(mouseX, 0, width, -1.0, 1.0);
      sine.pan(pos);

    } // end draw
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to get a sound file to play if the amp goes above or below a certain level</title>
      <link>https://forum.processing.org/two/discussion/14414/how-to-get-a-sound-file-to-play-if-the-amp-goes-above-or-below-a-certain-level</link>
      <pubDate>Tue, 12 Jan 2016 14:12:00 +0000</pubDate>
      <dc:creator>Irish005</dc:creator>
      <guid isPermaLink="false">14414@/two/discussions</guid>
      <description><![CDATA[<p>Hello, 
I am trying to get a sound file to play if the microphone registered amplitude either above or below a certain level. I do not have any code for this and any help would be appreciated! Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>How to change the volume of audio whilst playing</title>
      <link>https://forum.processing.org/two/discussion/14281/how-to-change-the-volume-of-audio-whilst-playing</link>
      <pubDate>Tue, 05 Jan 2016 22:41:58 +0000</pubDate>
      <dc:creator>_buchan</dc:creator>
      <guid isPermaLink="false">14281@/two/discussions</guid>
      <description><![CDATA[<p>So I have a code which goes through Processing into Arduino. It controls an LED and makes it pulsate like a heartbeat. What I want to achieve is the WhiteNoise increasing and decreasing in volume at the same time as the brightness of the LED gets brighter and dimmer.</p>

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

<pre><code>import processing.serial.*;
import cc.arduino.*;
Arduino arduino;  
import processing.sound.*;
WhiteNoise noise;

int ledPin = 9;

void setup()
{
  //println(Arduino.list());
  arduino = new Arduino(this, "/dev/cu.usbmodem1411", 57600);
  arduino.pinMode(ledPin, Arduino.OUTPUT);

  size(640, 360);
  background(255);

  // Create the noise generator
  noise = new WhiteNoise(this);
  noise.play();
  noise.amp(0.5);
}      


void draw()

{  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue &lt;= 255; fadeValue +=5) { 
    // sets the value (range from 0 to 255):
    arduino.analogWrite(ledPin, fadeValue);         
    // wait for 20 milliseconds to see the dimming effect    
    delay(20);                            
  } 

  delay(1000);
  arduino.analogWrite(ledPin, 0);
  delay (80);
  arduino.analogWrite(ledPin, 255);  
  delay (100);
  arduino.analogWrite(ledPin, 0);
  delay (80);
  arduino.analogWrite(ledPin, 255);  

  // fade out from not-quite-max to min in increments of 5 points:
  for(int fadeValue = 200 ; fadeValue &gt;= 0; fadeValue -=random(2,20)) { 
    // sets the value (range from 0 to 200):
    arduino.analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  } 
}
</code></pre>

<p>So at the moment, all that happens is that the LED performs as I want it to perform, but the WhiteNoise just plays solidly.</p>

<p>I think I could achieve the dip and rise in volume using the timing of the delays. However, so far, I have not been able to achieve volume changing at all.</p>

<p>Any help appreciated. Thank you.</p>
]]></description>
   </item>
   <item>
      <title>osc.amp() issue</title>
      <link>https://forum.processing.org/two/discussion/13588/osc-amp-issue</link>
      <pubDate>Sat, 21 Nov 2015 15:22:03 +0000</pubDate>
      <dc:creator>Joghurt</dc:creator>
      <guid isPermaLink="false">13588@/two/discussions</guid>
      <description><![CDATA[<p>Hi all</p>

<p>I’m trying to do some first steps in the sound library in p5js. The idea is simple: press a button, start an osc. Press it again, turn it off. I started with the example in the reference. When running the code, the osc.amp(0,0.05) runs once with a hearable sine tone which fades out (when increasing the 0.05, it fades out longer). From then, everything works at it should. But: there shouldn’t be any sound when starting, as osc.amp is set to 0 in setup.</p>

<p>Is this a bug, or what am I doing wrong?</p>

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

<pre><code>var startX, startY;
var faderY;
var buttonClicked = false;
var isPlaying = false;
var osc;

function setup() {
  createCanvas(windowWidth, windowHeight);
  startX = 50;
  startY = 50;
  faderY = startY+200;

  osc = new p5.Oscillator();
  osc.setType('sine');
  osc.freq(240);
  osc.amp(0);
  osc.start();
}

function draw() {
  background(190);
  fill(80);
  rect(startX, startY, 10, 200);
  fill(255);
  rect(startX-5, faderY, 20, 10);

  if (buttonClicked) {
    fill(10);
  } else {
    fill(230);
  }
  rect(startX+100, startY, 50, 50);



  if (buttonClicked) {
    //osc.amp(((faderY-(startY+190))/200), 0.05);
    osc.amp(0.5, 0.05);
  } else {
    osc.amp(0, 0.05);
  }

}

function mouseDragged() {
   if (mouseX &gt; startX-5 &amp;&amp; mouseX &lt; startX+15 &amp;&amp; mouseY &gt; startY-5 &amp;&amp; mouseY &lt; startY+200) {
  faderY = mouseY-5;
  }
}


function mouseClicked() {
  if (mouseX &gt; startX+100 &amp;&amp; mouseX &lt; startX+150 &amp;&amp; mouseY &gt; startY &amp;&amp; mouseY &lt; startY+50) {
    buttonClicked = !buttonClicked;
  }
}
</code></pre>

<p>Best,
Joghurt</p>
]]></description>
   </item>
   <item>
      <title>Processing + Xbox Controller + Sound</title>
      <link>https://forum.processing.org/two/discussion/13292/processing-xbox-controller-sound</link>
      <pubDate>Tue, 27 Oct 2015 05:15:02 +0000</pubDate>
      <dc:creator>Newbie1315</dc:creator>
      <guid isPermaLink="false">13292@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm new to processing and every time I try to play my program, I always get this message "NullPointExpectation" and my program doesn't want to work, can someone help me please.</p>

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

<p>import org.gamecontrolplus.gui.*;
import org.gamecontrolplus.*;
import net.java.games.input.*;</p>

<p>import processing.sound.*;</p>

<p>ControlIO control;
ControlDevice stick;
float X, Y;</p>

<p>ArrayList  shadows = new ArrayList();</p>

<p>SoundFile soundfile;</p>

<p>public void setup() {
  size(400, 400);</p>

<p>soundfile = new SoundFile(this, "vibraphon.aiff");</p>

<p>println("SFSampleRate= " + soundfile.sampleRate() + " Hz");
    println("SFSamples= " + soundfile.frames() + " samples");
    println("SFDuration= " + soundfile.duration() + " seconds");</p>

<pre><code>soundfile.loop();// Should play the file in a loop
</code></pre>

<p>control = ControlIO.getInstance(this);</p>

<p>stick = control.getMatchedDevice("joystick");
  if (stick == null) {
    println("No suitable device configured");
    System.exit(-1);
  }</p>

<p>stick.getButton("SHADOW").plug(this, "dropShadow", ControlIO.ON_PRESS);</p>

<p>soundfile = new SoundFile(this, "vibraphon.aiff");</p>

<p>println("SFSampleRate= " + soundfile.sampleRate() + " Hz");
    println("SFSamples= " + soundfile.frames() + " samples");
    println("SFDuration= " + soundfile.duration() + " seconds");</p>

<pre><code>soundfile.loop();// Should play the file in a loop
</code></pre>

<p>}</p>

<p>// Poll for user input called from the draw() method.
public void getUserInput() {
  X = map(stick.getSlider("X").getValue(), -1, 1, 0, width);
  Y = map(stick.getSlider("Y").getValue(), -1, 1, 0, height);
}</p>

<p>// Event handler for the SHADOW button
public void dropShadow() {
  // Make sure we have the latest position
  getUserInput();
  shadows.add(new PVector(X, Y, 40));
}</p>

<p>public void draw() {
  getUserInput(); // Polling</p>

<p>fill(0, 0, 255, 32);
  noStroke();
  for (PVector shadow : shadows)
    ellipse(shadow.x, shadow.y, shadow.z, shadow.z);</p>

<p>stroke(255, 70, 70, 70);
  fill(255, 70, 70, 70);
  ellipse(X, Y, 20, 20);</p>

<p>soundfile.rate(map(X, 0, width, 0.25, 4.0));</p>

<p>soundfile.amp(map(Y, 0, width, 0.2, 1.0));</p>

<p>soundfile.pan(map(Y, 0, width, -1.0, 1.0));
}</p>
]]></description>
   </item>
   <item>
      <title>addPhrase() error in p5.sound</title>
      <link>https://forum.processing.org/two/discussion/10009/addphrase-error-in-p5-sound</link>
      <pubDate>Tue, 24 Mar 2015 10:41:19 +0000</pubDate>
      <dc:creator>FreshMint</dc:creator>
      <guid isPermaLink="false">10009@/two/discussions</guid>
      <description><![CDATA[<p>I want to use the p5 sound library with p5.Part to play back a composition, but I can't even get it to work properly with the simplest examples. The examples on the p5.js site (like <a rel="nofollow" href="http://p5js.org/reference/#/p5.Phrase">this</a> ) work just fine and throw up no console errors, but if I try to paste this code into my own sketch (obviously using different audio files) it doesn't work. It is loading the files (there is no server issue; I'm hosting it on a local server this is not the problem, and the same thing happens if I actually post it online) because it plays something, but what it plays is a garbled sequence of drums which is slightly different every time the page is loaded. You can see the code below is almost directly from the composition example that works fine on the p5.js site, only with my files and simpler sequences in an effort to get it to work. It should play the low drum four beats, followed by the high drum four beats. It throws the following console error times the length of the sequences (in this case, 8) when I run it:</p>

<p>TypeError: undefined is not an object (evaluating 'phraseArray.length') p5.sound.js:5196</p>

<p>I think this indicates that somehow, when I'm passing boxPat or drumPat to addPhrase(), it's empty/unefined (even though it's clearly defined globally). I'm using the most up-to-date version of both p5.js and the sound library.</p>

<p>Why is this happening? Any ideas or help are greatly appreciated!</p>

<pre><code>var box, drum;
var boxPat = [1,1,1,1,0,0,0,0];
var drumPat = [0,0,0,0,1,1,1,1];
var osc, env;

function preload() {
  box = loadSound('DrumLo.mp3');
  drum = loadSound('DrumHi.mp3');
}

function setup() {
  var myPart = new p5.Part();
  myPart.addPhrase('box', playBox, boxPat);
  myPart.addPhrase('drum', playDrum, drumPat);
  myPart.setBPM(60);
  myPart.start();

  osc = new p5.Oscillator();
  env = new p5.Env(0.01, 1, 0.2, 0);
}

function playBox(playbackRate, time) {
  box.rate(playbackRate);
  box.play(time);
}

function playDrum(playbackRate, time) {
  drum.rate(playbackRate)
  drum.play(time);
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>