It’s me again. I’m having trouble playing an engine noise in my game. I have a sample that’s about 3 seconds long and I want it to play as the engine hum for each spaceship in my game. The way I’m doing it now is that I’m traversing through my list of entities in the game world and calling each entity’s update function. So, within the traversal I just added the lines to calculate each entity’s position and then play the engine hum at that position. The positional audio works but there’s a problem. Since I’m traversing through the list once every frame, the program ends up playing each sound 50+ times every second. I know that I could sort of fix it by taking the length of the sample and checking to make sure that the program loops through X number of frames before it plays that sample again but that seems like a bad way to go about doing it because then if my framerate goes too high or too low it will make the sound either play too often or not often enough. Is there a better way to do this? I know that there’s an FSOUND_LOOP_NORMAL flag that you can set when you load a sample but I wasn’t quite sure what that flag does. Will that cause a sample to play continuously until I tell it to stop and if so then how would you update the position of a looping sound each frame? Do you have to keep track of the channel # that the looping sound is played on and pass that into the Set3DAttributes function each frame? I posted some code snippets at: [url:2ih1l2tl]http://www.gam3g33k.com/codesnip.txt[/url:2ih1l2tl]
Please look over it and let me know if you have any ideas.

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.