ogg vorbis help
Hi, i''ve reached the audio stage of my game development and have decided to go with ogg vorbis for size vs. quality and it''s royalty free aspect. But I''m having trouble finding a starting point on the code needed to simply play an ogg vorbis file. I''m having trouble making heads or tails of the included docs. I was wondering if someone can give just an overview of the steps needed for me to play an ogg file in my win32/directX game. Any additional info would be appreciated as well. Thank You much
- Free Your Mind -
I think this would make a great topic for an article.
The documents are a bit obfuscated, or at least tough to get started on.
The documents are a bit obfuscated, or at least tough to get started on.
I don''t see what''s so obfuscated about the documentation. Have you seen this example yet?
Basically, that example program reads an Ogg Vorbis file from stdin, and writes PCM data to stdout. To actually use that example, you''ll read from some file, decode the data in to a buffer, and tell whatever sound library you''re using to play from the buffer with the PCM data in it.
I have some example code, where I use VorbisFile to decode data and feed it to OpenAL from a std::istream. I can upload it somewhere (again) if you''re interested (I have it online now, but it''s part of a much larger project).
Basically, that example program reads an Ogg Vorbis file from stdin, and writes PCM data to stdout. To actually use that example, you''ll read from some file, decode the data in to a buffer, and tell whatever sound library you''re using to play from the buffer with the PCM data in it.
I have some example code, where I use VorbisFile to decode data and feed it to OpenAL from a std::istream. I can upload it somewhere (again) if you''re interested (I have it online now, but it''s part of a much larger project).
Well, perhaps I''m just dumb. It didn''t help that I was learning DirectAudio while I was learning Vorbis, so it was problems all around for me.
ogg player using directsound (8), its not very good though. it needs some major reworking.
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-OggVorbisPlayerClass&forum=cotd&id=-1
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-OggVorbisPlayerClass&forum=cotd&id=-1
so after the OGG is decoded into the pcm buffer, can you just pass this buffer directly to DirectSound? what happens after Direct Sound plays what''s in the buffer, how do you get more ogg data without having gaps in audio? I''m sorry if these seem like stupid questions, but I''m not too good with audio programming. Thanks again
- Free Your Mind -
I can''t tell you how to stream the PCM data to DirectSound (maybe the example in Billybob''s post would help), but I can tell you how I stream OGG Vorbis data to OpenAL (ignore the next paragraph if you don''t care ).
OpenAL has a nice mechanism for callback-less streaming: each sound source can have a queue of buffers. I start a thread that monitors the sound source I created to stream the OGG Vorbis file, and whenever the remaining queued buffers go under a certain count, I try to decode more PCM data and queue it to the source.
Not having used DirectSound, I can''t say if that''s at all helpful .
OpenAL has a nice mechanism for callback-less streaming: each sound source can have a queue of buffers. I start a thread that monitors the sound source I created to stream the OGG Vorbis file, and whenever the remaining queued buffers go under a certain count, I try to decode more PCM data and queue it to the source.
Not having used DirectSound, I can''t say if that''s at all helpful .
quote: Original post by brewknowc
so after the OGG is decoded into the pcm buffer, can you just pass this buffer directly to DirectSound? what happens after Direct Sound plays what's in the buffer, how do you get more ogg data without having gaps in audio? I'm sorry if these seem like stupid questions, but I'm not too good with audio programming. Thanks again
Yes, you can pass the buffer directy to directsound. As for how to put more stuff in the buffer, that's a streaming audio thing and not really related to ogg vorbis. What I would do is create two buffers, while one is playing write to the other. Then swap them when the first is finished playing.
digital radiation
[edited by - directrix on February 14, 2003 12:18:36 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement