I wrote the below program to set up and play the game breakout as an assignment for Stanford's CS106 programming class. I wrote it on my old mac running OSX 10.6.8, with the version of Eclipse JDK that works on that machine. When I tested it back on the mac, the program worked normally. But now I am using a Windows 8.1 computer with the corresponding version of eclipse, and when I test the program again, the sound effect I coded does not play. I get the following error message in console when the ball hits the paddle or brick, which previously caused the sound clip to play.
Exception in thread "Thread-4" java.lang.IllegalArgumentException: Requested value -120.0 smaller than allowable minimum value -80.0.
at javax.sound.sampled.FloatControl.setValue(Unknown Source)
at com.sun.media.sound.DirectAudioDevice$DirectDL$Gain.setValue(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I have no idea what the values it refers to could mean, or why my code would request a value below the min. I am using the mediatools class that is part of the ACM libraries we are required to use for the class to play the sound in question, found here: http://cs.stanford.edu/people/eroberts/jtf/rationale/UtilPackage.html#MediaTools.
I went ahead and tested all parts of the program and the missing sound effect is the only problem. Here is my complete code:
Has anyone else tried running the code on their machine to see if they can reproduce?
Dennis Ouyang wrote:Has anyone else tried running the code on their machine to see if they can reproduce?
Works fine for me, but I'm using another sound file. Why don't you try using that one (or another). In particular, can the acm package handle au files?
UPDATE: I just tried an au file and it worked fine. I'm using Java 1.8.
Also, I am using java 1.7.0_67-b01, according to about menu in the java control panel.
First I tried using it in the default .wav format. Got the exact same error message.
then tried changing the format to .au , restarting eclipse JDK, changing file format to .au in my MediaTools method, refreshing the package and playing again. Exact same error message. Is anyone else getting this on their machine?
Here's the download page for Java 1.7.
I keep thinking it must have something to do with my new hardware. I tried playing around with my speakers and sound settings in windows, tried having sound come from the "AMD HD audio device" connected to my monitor. Same problem.
Dennis Ouyang wrote:No, sorry. I moved on to other chapters and assignments since I didn't want to spend too much time on this issue. Out of curiosity, do you use Windows 8?
Noup, I'm using OS X Yosemite 10.10.1 thanks anyway.
First, add this import: import java.net.URL;
Second, add this (I added it at the end of the program):
Third: Substitute this: AudioClip bounceClip = MediaTools.loadAudioClip("bounce.au");
With this: AudioClip bounceClip = Applet.newAudioClip(Get_Location("bounce.au"));
I hope it works for you or anyone else.