LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Using STB to load OGG files, decode vs open.  (Read 539 times)

MasterAbdoTGM50

  • Newbie
  • *
  • Offline Offline
  • Posts: 4
Using STB to load OGG files, decode vs open.
« 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
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1835
Re: Using STB to load OGG files, decode vs open.
« Reply #1 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 for an example of a simple music player.
Logged

MasterAbdoTGM50

  • Newbie
  • *
  • Offline Offline
  • Posts: 4
Re: Using STB to load OGG files, decode vs open.
« Reply #2 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
Logged