Game Development Community

Alxcreatesource vs. audioprofile

by Sean H. · in Technical Issues · 09/06/2007 (10:43 am) · 0 replies

I'm having some problems getting sounds to work in my game in torque and I have a couple questions about these two ways of creating sounds. there seems to be a subtle set of rules that one must follow to get sounds to work properly in torque.

I tried creating all the sounds in my game by creating a single audiodescription object, and then using that one description with a series of calls to alxcreatesource() to create all the audio handles at main menu start up. later on when the game is started, I tried using these handles but they didn't work at all.

so I moved the code for creating the audio handles so that it's called after the server is created. in this case, one sound worked, but the game crashed when it tried to play a second sound. I suspect this is because both sounds are using the same channel.

next, I tried adding a new audio description to use a separate channel for the second sound. the sound still didn't work and for some reason, the game started crashing when I tried shutting down by calling: disconnect().

Im curious about whether or not I should be using audioprofiles instead of just alxcreatesource() to create handles or in what situations should I use each. I understand that one must use audioprofiles for 3d positioned sounds, but I dont need this kind of functionality, I just need the sounds to work in general.

Ive been successful at getting one sound to play at a time but getting multiple sounds to play dynamically seems a bit more difficult. in the stock code, a sound is played by calling a function which does the following sequence of events:

1. create a listener
2. create an audio handle using alxcreatesource()
3. play the sound using alxplay()

common sense tells me that I should be able to do steps 1 and 2 as a one-time initialization step, rather than doing this in a function every time i want a simple sound to play. ideally, I should then be able to just track the audio handles and use alxplay whenever i need something to play. but I can't seem to figure out exactly how to do this in the way torque needs it done. torque doesn't seem to care much about audio handles which are created before the game starts.

how does torque expect this to be done? at what point in code should audio handles be created? is there a difference if an audioprofile is used with preload=true?

any help or direction would be appreciated.