OgreAL Update: Resource Management & API Clean up


21-01-2007 17:45:38

I am going to continue the thread from the Main forum so I thought I would quote it here.
I have removed the dependency on the SceneManager!! So now you can clear the scene, switch SceneManagers, or even have the SceneManager go away totally and you can still play music and sounds uninterrupted! I have also updated the demos to reflect this change. These changes are in SVN right now as I am working toward v0.3.

The next step is to take take the first step towards resource management but managing the buffers used my Sounds. This means that soon you can make as many sounds of the same type as you like, but there will only ever be a single buffer in memory. I am not going to be able to do this for SoundStreams though. The sheer nature of streaming audio means that I will never know what part of a file in in the buffer at any given moment and I wouldn't be able to swap the buffers out freely if they were being pointed to by multiple sources.

Last night I committed code that takes the first step in managing resources but ensuring that only one copy of a sound file is ever loaded. If there is already a buffer loaded that for a particular file on disk. This way you can have a walk sound for your game and attach a copy to each player, but each copy will be pointing to the same buffer. You don't need to do anything to leverage this, it's all taken care of by the SoundManager!


21-01-2007 18:26:03

Did you do this through the Ogre resource system? You can subclass Ogre's ResourceManager and Resource class. It will save you quite a bit of work.


21-01-2007 19:00:21

That sounds pretty cool to treat sounds like other resources such as meshes, skeletons, materials, etc.



21-01-2007 22:16:07

Did you do this through the Ogre resource system? You can subclass Ogre's ResourceManager and Resource class. It will save you quite a bit of work.No, actually. When I removed the dependency on the SceneManager I had to replicate some of the things that it did so the ResourceManager wouldn't really help and since I only need to keep track of sound buffers and sources it was simple enough to just roll my own little check.


22-01-2007 17:06:45

...but if you used Ogres resource management, you could benefit from threaded background loading! Or does this complicate things a lot?


22-01-2007 17:17:56

Hmmm.... I didn't think about the threaded background loading. I'll look more into using the Ogre Resource Manager. Right now I am working on cleaning up the API, so I'll get to that, probably, next week.


23-01-2007 06:26:39

I just committed a change that modifies the way that you change the type of buffer that is used (i.e. when you have a multi-channel sound). Instead of getting the default format and then changing it to what you wanted and then changing it back you just pass in the AudioFormat as an argument to SoundManager::createSound. It cleaned up quite nicely, in fact by adding this one optional parameter to the createSound() method call I was able to remove three whole methods from the API. I knew it wasn't great when I wrote it that way, it was kind of a last minute thing, but I didn't realize it was THAT bad! ;)