We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › By click on picture random play of soundfilefolder
Page Index Toggle Pages: 1
By click on picture random play of soundfilefolder (Read 732 times)
By click on picture random play of soundfilefolder
Sep 24th, 2009, 1:01pm
 
Hello everyone,
I am new to Processing and I would like to play a rondom soundfile of a folder everytime i click on the same picture.
I have the feeling this is probably not that difficult but i just don't have a clue! I hope someone can help me.
Re: By click on picture random play of soundfilefolder
Reply #1 - Sep 24th, 2009, 1:21pm
 
maybe you do it one by one. First try to play a sound using this librarie for example : http://sonia.pitaru.com/

ok, now use http://processing.org/reference/mouseClicked_.html to play the sound when the mouse is clicked.

dont know exactly how sonia is used, but next would be to random select an audio file. the easiest way is probably to load and name your sound files 0,2,3,4 etc and do something like play sound int(random(4))+".mp3"  or load them into an array if you want to. like i said, dont know exactly how sonia works so you have to look up the syntax.

And then, load an image, using PImage and draw it to the screen. Now in the mouseClicked function check if your mouse is over the image and if it is play the sound.
Page Index Toggle Pages: 1