Loop a OGG without loading into memory?

Hey,

I’m wondering if anyone can give me a hand looping an OGG file with the VorbisSPI WITHOUT loading the file into memory as a byte[ ]. So far, I can loop it as a byte[ ] by extending the ByteInputStream to be a loopingByteInputStream…but that only works if the samples are loaded into memory…and as we all know uncompressed files in memory takes up alot of space.

Any help would be appreciated :slight_smile:

 ~J~

You can use OggInputStream to read only as much as you need. You’ll have to write a player that streams the data yourself.

Thanks :slight_smile: Now I just need to figure out how to write the player part to stream it and intergrate it into my sound system…If only I had thought ahead!

Okay, as my forum title dictates I am quite obviously a fscking n00b and cannot figure this out. I keep getting null pointer exceptions each time I try to set it up to read X amount of bytes, play them, then replace those bytes with the next set of bytes…etc…

So can someone explain the theory behind this, as I think I have misunderstood the theory or I’m just too plain stupid to understand the Javadoc details for the OggInputStream.

It would help if you could point to the line where you get the NullPointerException. Now all we can do is guess what is wrong.

OggInputStream is quite simple. The constructor takes a InputStream containg the ogg. That is the compressed file as it is on disk. You can use a FileInputStream, ByteArrayInputStream or Class.getResourceAsStream as some examples of where your reading it from. Then you use the read() function to get the RAW, decompressed audio data out. In that way it work in the same way as any InputStream.

Doh! I noticed a problem straight out. I’ve been sending it a decompressed InputStream.

And the nullpointer exception is in JAvaEventDispatchThreadLine:145 apparently, followed by a bunch of error messages I dont understand.

Lemme try re-writing my method sending it the compressed stream and I’ll get back to you! Thanks again :slight_smile: