We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi guys, i'm working on my first interactive piece using makeymakey, i want to play a sound on a click / keyPressed. So far I've managed to get a sound played on a click, however it works only once then it stops, so if i try clicking again it doesn't play the sound again. Here's a bit of code i've written.
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.*;
Minim minim;
AudioPlayer one; //variable name
void setup(){
// germanloop();
size(500,500);
minim = new Minim(this);
one =minim.loadFile("german.wav");
//germanloop();
}
void draw(){
background(0);
//sou =minim.loadFile("german.wav");
}
void mousePressed(){
if (mousePressed == true);
one.play();
}
void mouseReleased()
{
if (mousePressed || true);
one.close();
}
Answers
Maybe use pause() instead of close()? :-/
@GoToLoop i'd ideally like he sound to play again from the beginning on the next click, would pause() not just pause it?
There's also rewind(). Complete API here: http://code.Compartmental.net/minim/
i managed to get it running as i wanted: @GoToLoop thanks for tips
true
.false
. No need for thoseif ()
blocks.