Jump to content
  • Advertisement
Sign in to follow this  
TheWanderer

Comments on sound-module design choice....

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In creating the sound module of a game engine, I've asked myself whether it would be best to have the engine load sounds directly from files or to create a File Loader which returns a sound file pointer which is then sent the Sound Module. The options would be as follows: Option #1: Snd_Module->loadWav("bleep.wav"); Option #2: SNDFILE *sndf = loadWav("bleep.wav"); Snd_Module->loadSnd(sndf); While the first option seems more straightforward, I have this feeling that the loading of a file should be independent from the sound module. (Or perhaps I should just allow the module to load everything and anything?) Comments are appreciated...

Share this post


Link to post
Share on other sites
Advertisement
As long as the file loading/resource management code is well isolated into it's own little chunk, either way should be okay.

Something like this?


file_manager.read("bleep.wav");
|#include|
sound.LoadSND(bleep_pointer); resource_manager.load<wav>("bleep.wav");
|#include| |#include|
-----------------------------------------
{global} LoadSound(sound,"bleep.wav");



That way the sound module, the resource_manager, and the file_manager can focus on their own specialties. It makes them far far easier to reuse and/or change. The bottom file would be functions to tie the two together [and add logging or game specifics]. It keeps the sound module and the file loading independant while allowing them to work together.

Share this post


Link to post
Share on other sites
Most impressive, Telastyn. You both answered my question and gave me some very nice ideas on which to ponder.

The way in which the LoadSound is designed hints at further usage which could be implemented for other modules which require the loading of files. Have you designed an engine before or did you see this style of component use somewhere?

Share this post


Link to post
Share on other sites
I've written bits and pieces of an engine before, though 'design' would be generous.

I forget who made the comment, but I remember a little while ago someone responded to a question of mine [something like "why doesn't this function also delete the data?"] with "because if you have one function to delete data, and one function to do [whatever I was asking about] it's easy to put them together. If you have 1 function that does both, it's impossible to take it apart."

Which is rather straightforward. The entire unix design focus "many small apps working together" works off that basis. Unfortunately, it's hard as hell to do well in C++ without learning the genericity that templating and inheritance provides. By then people generally have plenty of bad habits.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!