Ogg Vorbis and WAV streaming support
by Kurtis Seebaldt · in Torque Game Engine · 04/16/2002 (9:31 pm) · 51 replies
I've finished up my Ogg Vorbis and WAV streaming support. I've added one new field to the AudioDescription datablock 'isStreaming'. Set it to true and then create an AudioProfile using the streaming description and a WAV or Ogg Vorbis file and go. It supports looping by setting 'isLooping' in AudioDescription.
It is theoretically cross-platform, but I've only updated the VC6 project files. I'm not to good with Makefiles so I haven't tested Linux support, and I don't have a Mac to test either. It only uses the Ogg Vorbis library, OpenAL and the Torque Resource Manager so it should be ok.
This one uses the Ogg Vorbis SDK files instead of full source):
www.flamultimedia.com/audioStreaming2.zip
It is theoretically cross-platform, but I've only updated the VC6 project files. I'm not to good with Makefiles so I haven't tested Linux support, and I don't have a Mac to test either. It only uses the Ogg Vorbis library, OpenAL and the Torque Resource Manager so it should be ok.
This one uses the Ogg Vorbis SDK files instead of full source):
www.flamultimedia.com/audioStreaming2.zip
About the author
#2
04/17/2002 (7:16 am)
Btw, anybody else tried to integrate this?
#4
04/17/2002 (8:18 am)
Sorry guys, I just noticed I had the ogg and vorbis include and lib paths on my global VC directory list. Let me fix up the project files and replace the broken zip.
#5
www.flamultimedia.com/audioStreaming2.zip
04/17/2002 (8:34 am)
Ok, I fixed the paths in the project files.www.flamultimedia.com/audioStreaming2.zip
#6
04/17/2002 (9:19 am)
I'm thinking it may be simpler to just include prebuilt Ogg Vorbis LIBs and DLLs instead of rebuilding them every time. When I get home tonight I'll look into it. Should shrink the size of the zip too.
#7
04/17/2002 (9:35 am)
Sorry, but there are still errors:F:\ToRK\torque\engine\audio\audioDataBlock.cc(425) : error C2509: 'preload' : member function not declared in 'AudioProfile'
../engine\audio/audioDataBlock.h(108) : see declaration of 'AudioProfile'
audioFunctions.cc
audioStreamSourceFactory.cc
../engine\audio/vorbisStream.h(26) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory
vorbisStream.cc
F:\ToRK\torque\engine\audio\vorbisStream.cc(23) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory
vorbisStreamSource.cc
../engine\audio/vorbisStream.h(26) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory
wavStreamSource.ccThe header file is still missing, don't know where the other errors are coming from... guess I'll just "backdate" my engine until someone else has tried it... :-(
#8
www.flamultimedia.com/audioStreaming2.zip
This zip is only 200k vs 1.2M for the other one.
Stefan:
the "vorbis/codec.h" should be in lib/oggvorbis/include in this zip. Set up your project to use that directory in its incliude path.
04/17/2002 (9:43 am)
I've made a new version that no longer includes all the Ogg Vorbis source. It just uses the SDK files (LIBs, DLLs, and includes) www.flamultimedia.com/audioStreaming2.zip
This zip is only 200k vs 1.2M for the other one.
Stefan:
the "vorbis/codec.h" should be in lib/oggvorbis/include in this zip. Set up your project to use that directory in its incliude path.
#9
Have you submitted this as a resource yet?
04/17/2002 (10:17 am)
Cool, that should be much easier to deal with.Have you submitted this as a resource yet?
#10
anyhow, there seem to be some more updated files missing, because I still get the following errors:
Maybe I need the latest head to get it right?
Mine is about 4 weeks old now...
EDIT: Yep, seems to be a HEAD issue, try to figure it out... nevermind!
04/17/2002 (10:32 am)
Sorry, the missing header was my fault... should have thought of including the directory...anyhow, there seem to be some more updated files missing, because I still get the following errors:
F:\ToRK\torque\engine\audio\audioDataBlock.cc(429) : error C2039: 'filesWereDownloaded' : is not a member of 'NetConnection'
../engine\sim/netConnection.h(83) : see declaration of 'NetConnection'
F:\ToRK\torque\engine\audio\audioDataBlock.cc(429) : error C2065: 'filesWereDownloaded' : undeclared identifierAnd the declarationbool AudioProfile::preload(bool server, char errorBuffer[256]);was missing in audioDatablock.h ...
Maybe I need the latest head to get it right?
Mine is about 4 weeks old now...
EDIT: Yep, seems to be a HEAD issue, try to figure it out... nevermind!
#11
04/17/2002 (10:45 am)
All my stuff is based on the HEAD files from about a week ago. I haven't tried it on 1.1.1.
#12
Now, the engine doesn't run super smooth on my machine at the best of times, so perhaps that's what it is. What kind of impact have you been seeing? Is the decoding speed dependent on the level of compression the Ogg has?
04/17/2002 (11:02 am)
I got it in and working.. though I was surprised at the frame rate hit I got with an Ogg. I expected some, but it got as much as 50% slower at times.Now, the engine doesn't run super smooth on my machine at the best of times, so perhaps that's what it is. What kind of impact have you been seeing? Is the decoding speed dependent on the level of compression the Ogg has?
#13
04/17/2002 (11:47 am)
still doesn't work for me... now I don't get any compile errors and my exe gets build, but there is no ogg.dll built and so TGE doesn't launch and quits with an error ... anything I'm still missing? Thanks!!
#14
Stefan:
In the audioStreaming2.zip, the dlls are in the example directory.
04/17/2002 (12:01 pm)
I haven't done any profiling yet. I've tried to do some rudimentary profiling (use timeGetTime()) but the resolution is to low. I always get 1 millisecond elapsed to load a new buffer from an Ogg Stream. Is there a built in fps counter in Torque?Stefan:
In the audioStreaming2.zip, the dlls are in the example directory.
#15
As far as fps is concerned - I still got my normal framerate while playing a 4MB ogg file (126 kbps, 44kHz)... you can check the fps by typing metrics("fps") in the console...
thanks for the great work!!
04/17/2002 (12:20 pm)
... stupid me!! Thanks and sorry - now it works! Cool!!As far as fps is concerned - I still got my normal framerate while playing a 4MB ogg file (126 kbps, 44kHz)... you can check the fps by typing metrics("fps") in the console...
thanks for the great work!!
#16
is it possible to play "normal", like weapon e.t.c sounds in OV format, too? Or is it just meant for backgound music and such? Just curious.... ;-)
Great enhancement to TGE, by the way! No we can get rid of these huge WAV files for music... :-)) Thanks again for providing it!
04/17/2002 (3:33 pm)
Kurtis-is it possible to play "normal", like weapon e.t.c sounds in OV format, too? Or is it just meant for backgound music and such? Just curious.... ;-)
Great enhancement to TGE, by the way! No we can get rid of these huge WAV files for music... :-)) Thanks again for providing it!
#17
I've been meaning to test out an AudioEmitter that streams music. That would be cool :)
Another way would be to modify AudioBuffer to decode the entire Ogg Vorbis stream into the buffer. It won't be compressed anymore, but it would allow you to store non-streaming audio in Ogg Vorbis format. I'll have to look into that.
04/17/2002 (3:58 pm)
Technically, you should be able to play normal sounds too. Just set "is3D" to true on the AudioDescription. It will still stream it though. I've been meaning to test out an AudioEmitter that streams music. That would be cool :)
Another way would be to modify AudioBuffer to decode the entire Ogg Vorbis stream into the buffer. It won't be compressed anymore, but it would allow you to store non-streaming audio in Ogg Vorbis format. I'll have to look into that.
#18
04/17/2002 (7:27 pm)
I've been doing some rough profiling using the fps counter and on my machine (Athlon XP 1600+, GeForce4 4400) the Ogg Vorbis Stream adds about .5-1.2 mspf. That equates to 1-2 fps less depending on my max. Not too bad. Adjusting the number of buffers and size of buffers may affect this. Right now its set to 16 buffers of 32k each.
#19
04/17/2002 (7:50 pm)
One thing I forgot to mention in my first post - thanks for your great work! This is going to be a big deal once it's fine-tuned.
#20
04/17/2002 (10:08 pm)
Well, I've done some more speed testing this time in a Release instead of Debug build. For one, I never drop below 60 fps in Release while I was getting about 33 or so in the middle of the village in the Realm Wars map. Anyway, in the Release build I see practically NO difference in frame rate. So Simon, could you give me some numbers on how the Ogg stream affects your frame rate?
Associate Stefan Beffy Moises
udioDataBlock.cc F:\ToRK\torque\engine\audio\audioDataBlock.cc(425) : error C2509: 'preload' : member function not declared in 'AudioProfile' ../engine\audio/audioDataBlock.h(108) : see declaration of 'AudioProfile' audioFunctions.cc audioStreamSource.cc F:\ToRK\torque\engine\audio\audioStreamSource.cc(87) : error C2511: 'AudioStreamSource::AudioStreamSource' : overloaded member function 'void (const char *)' not found in 'AudioStreamSource' ../engine\audio/audioStreamSource.h(28) : see declaration of 'AudioStreamSource' F:\ToRK\torque\engine\audio\audioStreamSource.cc(94) : error C2600: 'AudioStreamSource::~AudioStreamSource' : cannot define a compiler-generated special member function (must be declared in the class first) F:\ToRK\torque\engine\audio\audioStreamSource.cc(95) : error C2065: 'bReady' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(99) : error C2039: 'clear' : is not a member of 'AudioStreamSource' ../engine\audio/audioStreamSource.h(28) : see declaration of 'AudioStreamSource' F:\ToRK\torque\engine\audio\audioStreamSource.cc(101) : error C2065: 'stream' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(102) : error C2065: 'freeStream' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(104) : error C2065: 'mHandle' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(105) : error C2065: 'mSource' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(106) : error C2065: 'mFilename' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(107) : error C2065: 'mDescription' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(108) : error C2065: 'mEnvironment' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(109) : error C2065: 'mPosition' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(109) : error C2228: left of '.set' must have class/struct/union type F:\ToRK\torque\engine\audio\audioStreamSource.cc(110) : error C2065: 'mDirection' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(110) : error C2228: left of '.set' must have class/struct/union type F:\ToRK\torque\engine\audio\audioStreamSource.cc(111) : error C2065: 'mPitch' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(112) : error C2065: 'mScore' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(113) : error C2065: 'mCullTime' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(129) : error C2065: 'bFinished' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(138) : error C2440: '=' : cannot convert from 'class Stream *' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style cast F:\ToRK\torque\engine\audio\audioStreamSource.cc(140) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(141) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(142) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(144) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(145) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(148) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(149) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(150) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(151) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(152) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(153) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(155) : error C2065: 'format' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(158) : error C2065: 'freq' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(160) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(161) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(163) : error C2065: 'DataSize' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(167) : error C2065: 'mBufferList' : undeclared identifier F:\ToRK\torque\engine\audio\audioStreamSource.cc(173) : error C2227: left of '->read' must point to class/struct/union F:\ToRK\torque\engine\audio\audioStreamSource.cc(175) : error C2109: subscript requires array or pointer type F:\ToRK\torque\engine\audio\audioStreamSource.cc(233) : error C2227: left of '->read' must point to class/struct/union audioStreamSourceFactory.cc ../engine\audio/vorbisStream.h(26) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory vorbisStream.cc F:\ToRK\torque\engine\audio\vorbisStream.cc(23) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory vorbisStreamSource.cc ../engine\audio/vorbisStream.h(26) : fatal error C1083: Cannot open include file: 'vorbis/codec.h': No such file or directory wavStreamSource.cc Error executing cl.exe. torqueDemo.exe - 44 error(s), 10 warning(s)...???
So obviously the file 'vorbis/codec.h' is missing and some other strange things are going on...
Any ideas what might be wrong? Thanks in advance!
P.S. Would be great if you could provide some info what to change in the VC project files, cause I added a lot of files to the official GG release, so I can't simply replace them... thanks!