Arduino: Adding some sound - Minim issues...
in
Integration and Hardware
•
2 months ago
Hi,
I am using the following Processing code to produce a score board for a reaction timer game running on an Arduino. Every time the score is increased the new value is sent by the Arduino to Processing via the serial port.It works well and the score is displayed in a big font.
However I would really like to also produce a sound every time the score is updated. I have briefly looked at Minim but it seems to me that it cannot be used during a draw loop very easily. I got a sound to play once but not repetitively. It seems that once the sound is played you need to close the sound before it can be played again? But how can the software know when the sound has finished in order to close the sound. Most attempts ended in crashed sketches!
So perhaps it is not possible. But if anyone knows how then I would be grateful. I must point out that I am a very newbie!
- void draw ()
- {
- fill (255, 255, 255);//white fill
- rect (0, 0, 1500, 800);//draw a big box on the screen 1500 x 800 pixels (filled white)
- int line=600;// y offset value - see below
- if (myPort.available()>0) //if there is anything in the serial buffer
- {
- count=myPort.read();//read the value from the port and make it equal to variable "count".
- fill(0,0,0);//black fill for font characters
- textFont(f, 800);// define a huge font size!
- text(count, 70, line);// write the value of count, 70 pixels in from the left and 600 down from the top of the box
- //I would like a short sound (.WAV or .mp3) to be played HERE!
- }
- }
1