Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Cross-platform sound reliability issues -- anyone have experience with this?

Thread view: 
cadar6@gmail.com - 15 Mar 2007 19:14 GMT
Hi, I'm hoping that someone out there can share their experience and
perhaps let me know why I'm having problems trying to play several 1-
second sound clips in a Java 1.5 applet. In particular, I'm having
different kinds of problems on the Mac vs. the PC. By the way, I'm
writing this application for an academic lab that would like to
conduct language learning experiments over the web using a Java
applet.

I'm just going to list the performance problems that I've had (and not
yet solved), and if anyone can give me either a solution to any of
them or just let me know that there *is* no known solution, I would
appreciate it!

I'm doing my development on the PC, and here are the problems I've had
on that platform:

1. If I open a SourceDataLine and leave it open for multiple (that is,
hundreds) of write() calls, with calls to drain() interspersed
periodically (as required by the design of my application), then I'll
eventually get a fraction of a second of a sound repeating every 5
seconds or so, independent of the continued calls to write() (which
succeed and cause new sounds to be played).

2. To deal with this, I tried creating a SourceDataLine for each
individual sound clip I need to play, call write(), then drain(), then
close(). But this introduces another problem: every once in a while,
there is an unexplained second or so of silence between sound clips.
The gap is too long to be explained by inopportune garbage collection.

On the Mac, the situation is even worse.

3. (Mac only.) If I create a new SourceDataLine for each clip, as in
problem #2 above, then I get a new thread which never goes away
(close() seems to have no effect). If I play 20 cilps, I have 20 new
threads. This is obviously unacceptable if I'm going to play hundreds
of clips.

4. (Mac only.) The sound clips come from little MP3s, which I decode
using JLayer 1.0. If I decode them on the fly, I get loud, annoying
clicking sounds at the end of the 4th or 5th clip, and every clip
thereafter. Further testing shows that the computer is amply able to
decode fast enough to keep the sound buffer full. I temporarily solved
this problem by decoding all the clips into memory first (before
playing any of them), and then playing the clips directly from memory,
but this will not be practical for us in the long run. I think this
problem has to do with competition for CPU time among the threads.

Again, any information would be most helpful, thanks!

Samuel
Andrew Thompson - 16 Mar 2007 00:21 GMT
On Mar 16, 5:14 am, cad...@gmail.com wrote:
> Hi, I'm hoping that someone out there can share their experience and
> perhaps let me know why I'm having problems trying to play several 1-
> second sound clips in a Java 1.5 applet.

You can expect no end of problems deploying
applets in browsers.  Launch your applet using
web start and take 1 complication from the
problem description.  E.G.
<http://www.physci.org/jws/#jtest>

Andrew T.
Knute Johnson - 16 Mar 2007 00:46 GMT
> Hi, I'm hoping that someone out there can share their experience and
> perhaps let me know why I'm having problems trying to play several 1-
[quoted text clipped - 24 lines]
> there is an unexplained second or so of silence between sound clips.
> The gap is too long to be explained by inopportune garbage collection.

I can maybe help with these two.  They are both related.  If you open a
SourceDataLine, you need to keep sending it data to keep it's buffer
full or you will have these problems.  You might consider using the Clip
interface instead.  You don't have to keep feeding it.

Signature

Knute Johnson
email s/nospam/knute/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.