I have some sample code that works with point sounds, but I think it should be fairly trivial to convert it to use background sounds.
Here's the smallest standalone sound sample I've
been able to create:
http://clearwater.com.au/java/J3DSound6.java
Maybe that will help get you going.Cheers, Guy.
P.S. There are several problems with the sound implementation. Below are a couple issues I have explored. I'm including them also because they include links to more audio sample code.
Bug 4787253 - Sound setEnable(false) not work
OS VERSION
Windows 2000OVERVIEW
when using the Sound.setEnable(boolean) method to stop and restart an
audio clip, if the audio clip is enabled immediately after it is
disabled (or
completes), it continues playing after it is subsequently disabled. 1) sound.setEnable(true) // sound starts playing
(time passes)
2) sound.setEnable(false) // sound stops playing
3) sound.setEnable(true) // sound starts playing again
(time passes)
4) sound.setEnable(false) // sound SHOULD stop but continues At (4) sound node enters some sort of invalid state where it
continues
to play the original sound, but can be re-enabled and it will play
a mix
of the continuing stream and a new stream, with both played out at
an accelerated rate.WORKAROUND
Adding a sleep of >100ms between (2) and (3) above seems to prevent the problem.
REPRO
The sample code at
http://clearwater.com.au/java/J3DSound8.java
reproduces the problem. Note that there is an
if (false) {
wait()
}
block at the end of the program that enables the workaround.Bug 4787026 - Sound.setRelease(true) is not yet implement
OS VERSION
Windows 2000TITLE
Sound.setRelease(true) doesn't work correctly with setLoop(>0)SUMMARY
Calling setRelease(true) followed by setEnable(false) should allow
the
audio to continue to the end of the current cycle. When the sound
in question
is set to loop, the sound continues to the end of the number of loops
specified in the most recent call to setLoop(), including calls
made after
the sound was enabled. The loop count should not affect the
behavior at all. For example if the sound was started with
sound.setLoop(INFINITE_LOOPS);
sound.setEnable(true);
and is currently in the middle of the second loop, the following
effects are observed: CASE 1)
sound.setRelease(true);
sound.setEnable(false);The sound continues looping infinitely insetad of stopping at the end of the 2nd loop.
CASE 2)
sound.setLoop(0);
sound.setRelease(true);
sound.setEnable(false);The sound stops immediately instead of stopping at the end of the 2nd loop.
CASE 3)
sound.setLoop(3);
sound.setRelease(true);
sound.setEnable(false);The sound continues to the end of the 4th pass instead of stopping at the end of the 2nd pass.
REPRO
The code at http://www.clearwater.com.au/java/J3DSound10.java exhibits cases 2 and 3.
At 05:45 PM 21/07/2003 -0700, Dr. Thomas wrote:
I am trying to add background sound to a Java3d application. I have a *.wav file in my Java directory. My program creates a "BackgroundSound" object. It also creates a "MediaContainer" object and references to MediaContainer object to the sound. It sets the appropriate 'loop' values, 'initialgains', etc. I have found virtually nothing on this topic in Sun's online tutorial. I have examined the SIGGRAPH 98 Java 3D technology course notes, available on line. However, using their example has been unavailing. I also consulted the book, "Java 3D API Jump-Start". It provides a brief sample of code. Using their example, my code compiles. However, it produces no sound. Does anyone have a relatively simple example of code that works? Conversely, can anyone refer me to literature that explains this topic. Thank you in advance.
JT.
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
