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 › how to make a button with sound
Page Index Toggle Pages: 1
how to make a button with sound ? (Read 1653 times)
how to make a button with sound ?
Jan 12th, 2006, 7:51pm
 
    I've being trying to make a button that make sounds while its being pressed. Also it's "pressed" by the system and should also make sound, in a decreasing time interval.
   The sound is a simple and continuos "buzz", like old computer sounds.
   First I tried to make a long wav file with the sound, and call play() and stop() in  decreasing intervals. A loud "click" noise could be heard every time it plays or stops. This "click" noise became a real problem that I could not solve after trying a lot of differents ways.
  It's important to say that I got no experience in programing and that Processing is my first contact with code. I read some tutorial and start to try, so is very probably that I'm making silly mistakes, the code is as it came out and I can't even say how terrible it is.
  I was trying to avoid sonia couse of the need of a plugin. I tried to loop it and raise or lower the volume, but there was a click in each increase or decrease. In some hardwares you could not hear it, in others very loud.
 Than I tried ESS, and the same problem appears, in the various ways I tried.
 I went around it by making a two frames (30 fps frames) long buzz, with fade in and out in a sound editor, and looping each time less times, it's not really a good way, not just for the lack of elegance, but the sound is not very synced with the light in buttons and the sync is very dependent in the hardware performance, and very limiting.
 How is the way to do it ? Please help.
There's a working in progress of the applet at:

http://genius.kubrusly.com/fr3/

Also there is a sample of the buzz in a wav file if it could do any good at:

http://genius.kubrusly.com/fr3/buzz.wav

Comments very appreciated
thanks

VK

Also comments about any thing at the code and all.








translation
Reply #1 - Jan 12th, 2006, 9:01pm
 
Sorry it's in portuguese, you need to click to give the applet attention , then any key start or restart the game.
Re: how to make a button with sound ?
Reply #2 - Jan 12th, 2006, 9:20pm
 
It seems to work for me. But I am using Java 1.5

Here's what I see on my java console though:
Code:

Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:40)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:41)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:42)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:43)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:44)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Couldn't get gain control for this .wav file
java.lang.IllegalArgumentException: Unsupported control type: Master Gain
at com.sun.media.sound.AbstractLine.getControl(Unknown Source)
at processing.core.PSound2.<init>(PSound2.java:83)
at processing.core.PApplet.loadSound(PApplet.java:2772)
at Genius_beta_01.setup(Genius_beta_01.java:45)
at processing.core.PApplet.display(PApplet.java:1147)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1031)
at java.lang.Thread.run(Unknown Source)
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Cannot set the volume for this sound.
Re: how to make a button with sound ?
Reply #3 - Jan 13th, 2006, 3:24pm
 
Thanks John,
It's good to know that it is working. But all those errors in console are not good are they?
Is this click noise behavior normal?
There isnt a better way to do it?
thanks again
Page Index Toggle Pages: 1