The Sound Extension extends Horde3D with the capability of 3D positional audio with the help of OpenAL. It was designed to integrate as nicely as possible with Horde3D, therefore it comes with some limitations, such as the lack of streaming sound support. This means the whole audio file will be read and decoded all at once, which can be quite time consuming for larger files.
The extension currently decodes ogg vorbis and wave audio files but decoders for more formats can quite easily be implemented. See the decoder.h file for documentation on how to implement more audio decoders.
Installation Windows
To install the extension, copy the Extensions directory to the path where the Horde3D SDK resides.
If your version of Horde3D SDK is <= 1.0.0 Beta 2 you will need to apply this patch:
--- Bindings/C++/Horde3D.h Sun Sep 14 21:50:46 2008
+++ Bindings/C++/Horde3D.h Tue Dec 09 08:44:13 2008
@@ -791,11 +791,11 @@
res - handle to the resource
Returns:
type of the resource
*/
- DLL ResourceTypes::List getResourceType( ResHandle res );
+ DLL int getResourceType( ResHandle res );
/* Function: getResourceName
Returns the name of a resource.
This function returns a pointer to the name of a specified resource. If the resource handle
@@ -823,11 +823,11 @@
name - name of the resource
Returns:
handle to the resource or 0 if not found
*/
- DLL ResHandle findResource( ResourceTypes::List type, const char *name );
+ DLL ResHandle findResource( int type, const char *name );
/* Function: addResource
Adds a resource.
This function tries to add a resource of a specified type and name to the resource manager. If
@@ -842,11 +842,11 @@
flags - flags used for creating the resource
Returns:
handle to the resource to be added or 0 in case of failure
*/
- DLL ResHandle addResource( ResourceTypes::List type, const char *name, int flags );
+ DLL ResHandle addResource( int type, const char *name, int flags );
/* Function: cloneResource
Duplicates a resource.
This function duplicates a specified resource. In the cloning process a new resource with the
--- Source/Horde3DEngine/egMain.cpp Wed Sep 03 00:28:10 2008
+++ Source/Horde3DEngine/egMain.cpp Tue Dec 09 08:44:13 2008
@@ -236,11 +236,11 @@
// *********************************************************************************************
// Resource functions
// *********************************************************************************************
- DLLEXP ResourceTypes::List getResourceType( ResHandle res )
+ DLLEXP int getResourceType( ResHandle res )
{
Resource *r = Modules::resMan().resolveResHandle( res );
if( r != 0x0 ) return r->getType();
else
@@ -264,20 +264,20 @@
return &emptyString;
}
}
- DLLEXP ResHandle findResource( ResourceTypes::List type, const char *name )
+ DLLEXP ResHandle findResource( int type, const char *name )
{
Resource *res = Modules::resMan().findResource( type, safeStr( name ) );
if( res != 0x0 ) return res->getHandle();
else return 0;
}
- DLLEXP ResHandle addResource( ResourceTypes::List type, const char *name, int flags )
+ DLLEXP ResHandle addResource( int type, const char *name, int flags )
{
return Modules::resMan().addResource( type, safeStr( name ), flags, true );
}
--- Source/Horde3DEngine/egResource.cpp Wed Sep 03 00:28:10 2008
+++ Source/Horde3DEngine/egResource.cpp Tue Dec 09 08:42:30 2008
@@ -37,11 +37,11 @@
// **********************************************************************************
// Class Resource
// **********************************************************************************
-Resource::Resource( ResourceTypes::List type, const string &name, int flags )
+Resource::Resource( int type, const string &name, int flags )
{
_type = type;
_name = name;
_handle = 0;
_loaded = false;
@@ -192,11 +192,11 @@
// Initialize resource type
if( inf != 0 ) (*inf)();
}
-Resource *ResourceManager::findResource( ResourceTypes::List type, const string &name )
+Resource *ResourceManager::findResource( int type, const string &name )
{
for( uint32 i = 0; i < _resources.size(); ++i )
{
if( _resources[i] != 0x0 && _resources[i]->_type == type && _resources[i]->_name == name )
{
@@ -226,11 +226,11 @@
_resources.push_back( &resource );
return resource._handle;
}
-ResHandle ResourceManager::addResource( ResourceTypes::List type, const string &name,
+ResHandle ResourceManager::addResource( int type, const string &name,
int flags, bool userCall )
{
if( name == "" || name.find( ":" ) != string::npos )
{
Modules::log().writeDebugInfo( "Invalid name for added resource of type %i", type );
--- Source/Horde3DEngine/egResource.h Wed Sep 03 00:28:10 2008
+++ Source/Horde3DEngine/egResource.h Tue Dec 09 08:42:30 2008
@@ -65,11 +65,11 @@
class Resource
{
protected:
- ResourceTypes::List _type;
+ int _type;
string _name;
ResHandle _handle;
bool _loaded;
bool _noQuery;
int _flags;
@@ -77,11 +77,11 @@
uint32 _refCount; // Number of other objects referencing to this resource
uint32 _userRefCount; // Number of handles created by user
public:
- Resource( ResourceTypes::List type, const string &name, int flags );
+ Resource( int type, const string &name, int flags );
virtual ~Resource();
virtual Resource *clone(); // TODO: Implement this for all resource types
virtual void initDefault();
virtual void release();
@@ -96,11 +96,11 @@
virtual bool setParamstr( int param, const char *value );
virtual const void *getData( int param );
virtual bool updateData( int param, const void *data, int size );
- ResourceTypes::List &getType() { return _type; }
+ int &getType() { return _type; }
const string &getName() { return _name; }
ResHandle getHandle() { return _handle; }
bool isLoaded() { return _loaded; }
void addRef() { ++_refCount; }
void subRef() { --_refCount; }
@@ -169,12 +169,12 @@
~ResourceManager();
void registerType( int type, const string &typeString, ResTypeInitializationFunc inf,
ResTypeReleaseFunc rf, ResTypeFactoryFunc ff );
- Resource *findResource( ResourceTypes::List type, const string &name );
- ResHandle addResource( ResourceTypes::List type, const string &name, int flags, bool userCall );
+ Resource *findResource( int type, const string &name );
+ ResHandle addResource( int type, const string &name, int flags, bool userCall );
ResHandle addNonExistingResource( Resource &resource, bool userCall );
ResHandle cloneResource( ResHandle sourceRes, const string &name );
int removeResource( ResHandle handle, bool userCall );
void clear();
ResHandle queryUnloadedResource( int index );
In Visual Studio, add the extension, sample, ogg, vorbis and vorbisfile projects to the Horde3D solution. Then add the extension project to the project dependencies of the Horde3D Engine and the Horde3D Engine to the dependencies of the Sound Sample. After that, include 'Sound/Source/extension.h' in 'egExtensions.cpp' of the engine and add '#pragma comment( lib, "Extension_Sound.lib" )' to link against the sound extension (under Windows). Finally, add the following line to ExtensionManager::installExtensions to register the extension:
installExtension( Horde3DSound::getExtensionName, Horde3DSound::initExtension, Horde3DSound::releaseExtension );
The extension is then part of the Horde3D DLL and can be used with the Horde3DSound.h header file.
Using the extension
When using the extension a sound device needs to be opened for playback, then a listener node needs to be created and activated. The activated listener node will act as the ears and all 3D sound calculations will be based on that node's position and orientation. Then you can start creating sound resources, attaching them to sound nodes and start playing the nodes.
OpenAL will need to be installed to be able to run any applications using the Sound Extension.
Obtaining the extension
The extension can either be downloaded here or from the community svn.
|