Playing sound files

R

Ravi

I want to play small sound files in my application that too at shorter
duration which can be stopped and played instantly. I tried using
sun.audio,AudioPlayer but it leaves large gaps at the end even for
files as short as of duration 0.8 seconds.

Please suggest a better library to do this.
 
R

Roedy Green

I tried using
sun.audio,AudioPlayer but it leaves large gaps at the end even for
files as short as of duration 0.8 seconds.

The API has tools to chop off a sound prematurely. How would you be
able to tell the difference between silence at the end of a clip and a
clip finishing when expected?
 
M

Michael Jung

Roedy Green said:
The API has tools to chop off a sound prematurely. How would you be
able to tell the difference between silence at the end of a clip and a
clip finishing when expected?

By comparing the results with another soundplayer, presumably not
written in Java.

Michael
 
M

Michael Jung

Roedy Green said:
what would you notice different?

[You removed context]

The length of clip - whether it was arbitrarily extended or not by
sun.sound.Audioplayer.

Michael
 
A

Andrew Thompson

I want to play small sound files in my application that too at shorter
duration which can be stopped and played instantly. I tried using
sun.audio,AudioPlayer

Why would you use an undocumented sound API
(who's package and classname, let alone the
methods, might change in the next release,
when the ...
.. but it leaves large gaps at the end even for
files as short as of duration 0.8 seconds.

Please suggest a better library to do this.

... javax.sound.sampled API is publicly
documented and entirely capable of doing
pretty much whatever it is you want with
sounds that have formats and encodings
that are compatible.
 
R

Roedy Green

The length of clip - whether it was arbitrarily extended or not by
sun.sound.Audioplayer.

I am going to give up in a minute. How can you tell the difference
between an extension of silence and the clip ending on time. Both
tails sound like silence, right?
 
M

Michael Jung

Roedy Green said:
I am going to give up in a minute. How can you tell the difference
between an extension of silence and the clip ending on time. Both
tails sound like silence, right?

Like in
me@here> time java sun.sound.AudioPlayer clip.au

real 0m0.500s
....

me@here> time mplayer clip.au

real 0m1.000s
....

I leave it as an exercise to correct the commandline arguments,
eliminate process startup waste, sound card buffering, etc. This is
so trivial, that I wonder where you see the problem. If you
repeatedly play the clip (in a series) you might even hear the
difference in the "silence tails".

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top