Adding OGG support to T2D
by Mike Lilligreen · in Torque 2D Beginner · 03/30/2014 (12:48 pm) · 12 replies
Hey everyone,
As part of my steering committee duties, I make it a habit of every now and then searching the internet for Torque 2D posts and chatter. Today I found an interesting blog which shows how to add Ogg Vorbis support back into T2D MIT.
www.chadweisshaar.com/blog/2014/02/17/adding-ogg-support-to-torque-2d/
I haven't had the time to test this myself, but I thought it would be useful for the community. And if Chad reads this...thanks for sharing!
One thing to correct from the blog though - I remember Mich posting about this a long time ago, and if I remember right - Ogg was removed from T2D MIT not for licensing reasons (Ogg has a very permissive license that is comparable with MIT) but simply because it is not natively supported on iOS devices.
It's certainly an interesting topic of discussion - are people fine with WAV being the only default format supported for audio? Should audio formats like Ogg Vorbis be added back into the source with the knowledge that it is not portable to every platform that T2D now supports? (As of 3.0 we will have 6 platforms to think about - Windows, OSX, iOS, Android, Linux, Web)
As part of my steering committee duties, I make it a habit of every now and then searching the internet for Torque 2D posts and chatter. Today I found an interesting blog which shows how to add Ogg Vorbis support back into T2D MIT.
www.chadweisshaar.com/blog/2014/02/17/adding-ogg-support-to-torque-2d/
I haven't had the time to test this myself, but I thought it would be useful for the community. And if Chad reads this...thanks for sharing!
One thing to correct from the blog though - I remember Mich posting about this a long time ago, and if I remember right - Ogg was removed from T2D MIT not for licensing reasons (Ogg has a very permissive license that is comparable with MIT) but simply because it is not natively supported on iOS devices.
It's certainly an interesting topic of discussion - are people fine with WAV being the only default format supported for audio? Should audio formats like Ogg Vorbis be added back into the source with the knowledge that it is not portable to every platform that T2D now supports? (As of 3.0 we will have 6 platforms to think about - Windows, OSX, iOS, Android, Linux, Web)
About the author
#2
But I was able to find what you were referring to. Very interesting library for iOS. Here are the Github repos:
github.com/iosdevzone/IDZPrecompiledOgg
github.com/iosdevzone/IDZPrecompiledVorbis
03/30/2014 (1:09 pm)
Your links are broken Simon.But I was able to find what you were referring to. Very interesting library for iOS. Here are the Github repos:
github.com/iosdevzone/IDZPrecompiledOgg
github.com/iosdevzone/IDZPrecompiledVorbis
#3
Totally off-topic but apparently using [ url ] http://theinternet.com/[/url] redirects to the GG forums but click this text! works correctly.
Anyways, your links are better :)
03/30/2014 (1:33 pm)
Fixed them. Totally off-topic but apparently using [ url ] http://theinternet.com/[/url] redirects to the GG forums but click this text! works correctly.
Anyways, your links are better :)
#4
I was more interested in seeing if opus support would work rather than vorbis. Managed to get the audio file loaded and read by libopusfile, but the lib refuses to recognize it as a valid opus file.
03/31/2014 (1:00 am)
For anyone following along, the other thing that needs to be done is to register the ogg extension with the resource manager. At the moment the OpenALInitDriver console function does this, so it should be as simple as adding a new line for .ogg in audio/audio_ScriptBinding.ccResourceManager->registerExtension(".ogg", AudioBuffer::construct);I was more interested in seeing if opus support would work rather than vorbis. Managed to get the audio file loaded and read by libopusfile, but the lib refuses to recognize it as a valid opus file.
#5
03/31/2014 (2:01 am)
Thanks for the tip Frogger. I was also curious about opus - nice to see you are trying to get it to work. Would also be cool to see if FLAC can be added the same way.
#6
Seems to play correctly now, however freeing the Opus file object after use causes a segfault, and the initial decode causes a slight slowdown on the main thread, especially for larger files.
The quickly thrown together stuff is at github.com/camporter/Torque2D/tree/opus_support
03/31/2014 (10:19 pm)
Heh, so I managed to get it to play the opus file (I messed up what the stream callbacks are supposed to return). The audio had a few problems at first, what with it sounding demonic and clipping harshly :)Seems to play correctly now, however freeing the Opus file object after use causes a segfault, and the initial decode causes a slight slowdown on the main thread, especially for larger files.
The quickly thrown together stuff is at github.com/camporter/Torque2D/tree/opus_support
#7
04/01/2014 (9:24 am)
Nice progress! With larger audio files, regardless of their format, you're going to want to stream them from disk. I'd also look at a copy/modify of wavStreamSource. From my copy of TGB 1.8, I see there are also files named oggMixedStreamSource and vorbisStreamSource.
#8
I took a stab at adding libogg/libvorbis to the T2D solution but can't quite get it to compile.
04/02/2014 (1:28 pm)
Chad's post is a bit confusing to me but I'd like to see OGG support.I took a stab at adding libogg/libvorbis to the T2D solution but can't quite get it to compile.
#9
Necroposting to confirm the code works on linux (plays ogg). ResourceManager.cc is complaining here: github.com/GarageGames/Torque2D/blob/master/engine/source/io/resource/resourceMa...
Edit: I also tried Frogger's code. It compiled but I got an error about unsupported number of channels for the opus file. Perhaps I used a different version (latest)?
Edit #2: Frogger's code works. It accepts mono and stereo, not surround opus files.
07/20/2014 (9:51 am)
OH ROTTING THREAD, I SUMMON THEE!Necroposting to confirm the code works on linux (plays ogg). ResourceManager.cc is complaining here: github.com/GarageGames/Torque2D/blob/master/engine/source/io/resource/resourceMa...
Edit: I also tried Frogger's code. It compiled but I got an error about unsupported number of channels for the opus file. Perhaps I used a different version (latest)?
Edit #2: Frogger's code works. It accepts mono and stereo, not surround opus files.
#10
www.garagegames.com/community/blogs/view/22820
08/26/2014 (1:57 pm)
I've got Ogg working in T2D as well. For my solution I went down a different path though.www.garagegames.com/community/blogs/view/22820
#11
Here's what I've done to add libogg to T2D:
1). Added a new empty project to the T2D solution with the following structure:
2). Set the libogg project to compile as a static lib using /MT.
3). Added a path to libogg in the 'Additional Include Directories' section of the libogg project.
I've tried everything I can think of to get this working, short of changing the #include line in libogg.
Edit: Making progress! T2D is compiling again. Will followup with a changelog if/when I get this working.
10/26/2014 (11:50 am)
I'm taking another stab at adding ogg support using Chad's blog post as a starting point. Unfortunately I'm running into the same problem I did a few months ago: VS2010 errors out on #include <ogg/ogg.h> in both bitwise.c and framing.c files in the libogg source.Here's what I've done to add libogg to T2D:
1). Added a new empty project to the T2D solution with the following structure:
libogg
include
ogg.h
os_types.h
src
bitwise.c
framing.c2). Set the libogg project to compile as a static lib using /MT.
3). Added a path to libogg in the 'Additional Include Directories' section of the libogg project.
I've tried everything I can think of to get this working, short of changing the #include line in libogg.
Edit: Making progress! T2D is compiling again. Will followup with a changelog if/when I get this working.
#12
Next I'm going to take a look at TGB and see if I can get streaming audio support working again.
10/27/2014 (8:42 am)
T2D can load and play ogg files now. Unfortunately I couldn't get libogg/libvorbis working as subprojects in VS without libvorbis complaining about not being able to find <ogg/ogg.h>. I clearly missed a step somewhere. Instead, I used TGB as an example and added the libogg/libvorbis source files directly into the T2D solution. This is a bit ugly, though, as I had to modify #include lines in both libs. Next I'm going to take a look at TGB and see if I can get streaming audio support working again.
Associate Simon Love
I'm all for it, ogg takes much less space than .wav and sounds way better than .mp3.
At first I thought "Let's just add a flag. If we're on Mobile, forget OGG format and throw an error!".
But..
IOS =>
here
Android =>
here