LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: MasterAbdoTGM50 on February 05, 2017, 17:06:55

Title: Using STB to load OGG files, decode vs open.
Post by: MasterAbdoTGM50 on February 05, 2017, 17:06:55
Hi,

I've been reading on OpenAL and decided to finally use it so thanks a lot for the demos they helped a lot but getting to the question I notice that STBVorbis has 2 methods to load OGG files

1.decode: which loads the whole thing into a buffer
2.open: which requires an STBVoribisInfo object/struct and if I understood correctly doesn't load it completely but a frame by frame and I enqueue the loaded parts into the source playing the sound

Is there any difference between the two? and what are some benefits of using one over the other or are they just different ways to load the buffer for convenience?

Thanks alot for reading and sorry if my questions were misplaced
Title: Re: Using STB to load OGG files, decode vs open.
Post by: spasi on February 05, 2017, 17:16:00
Indeed, using stb_vorbis_get_frame_* and stb_vorbis_get_samples_* lets you do stream decoding. Without decoding the entire file, or even having it entirely in memory.

See the Vorbis demo (https://github.com/LWJGL/lwjgl3/blob/master/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java) for an example of a simple music player.
Title: Re: Using STB to load OGG files, decode vs open.
Post by: MasterAbdoTGM50 on February 05, 2017, 17:33:01
So essentially it's only a question of whether I want the whole file buffered or do I wanna stream it

Thank you alot Spasi :D