javax.sound streaming

T

taylorius

I am converting some sound code from old style sun audio to
javax.sound
The sound I'm playing is already resident in memory, so I'm converting
it to an AudioInputStream, and playing it via a Clip.
All well and good, except some of the sounds are on the large side, (>
1Mb) and I get "Requested buffer too large" exceptions. Fair enough, I
suppose clips are only designed for small samples.

My question is, is there a method of playing an arbitrary sized sound
sample that is resident in memory, without having to spoon feed the
data to the audio Line myself (line events etc). I like the behaviour
of a clip (just gets on and plays the sound), but in my situation, it
needn't copy the data (I presume this is where it is failing on the
large samples), as it is already resident in memory.

Many thanks for any help people may be able to offer


Matthew Taylor
 
K

Knute Johnson

taylorius said:
I am converting some sound code from old style sun audio to
javax.sound
The sound I'm playing is already resident in memory, so I'm converting
it to an AudioInputStream, and playing it via a Clip.
All well and good, except some of the sounds are on the large side, (>
1Mb) and I get "Requested buffer too large" exceptions. Fair enough, I
suppose clips are only designed for small samples.

My question is, is there a method of playing an arbitrary sized sound
sample that is resident in memory, without having to spoon feed the
data to the audio Line myself (line events etc). I like the behaviour
of a clip (just gets on and plays the sound), but in my situation, it
needn't copy the data (I presume this is where it is failing on the
large samples), as it is already resident in memory.

Many thanks for any help people may be able to offer


Matthew Taylor

There is a finite limit to Clip size. I don't remember what but you've
probably exceeded it. Just make a loop and write the data to a
SourceDataLine.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top