Advertisement Jump to content
Sign in to follow this  

OpenAL problems [SOLVED]

This topic is 4917 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

EDIT: LESSON LEARNED: If you aint getting 3d sound, check that the sounds are in mono format and NOT in stereo. Took me a couple of hours to figure out! --original post-- I just got a hold of a Python binding for OpenAL. It has a very nice interface, just two classes, SoundEngine and SoundSource. The following program...
import libal

eng = libal.SoundEngine(22000)

s1 = libal.SoundSource("punch.wav")
s1.Play(True)  ### play and loop

x = 1
while 1:
	x += .0001

... does what you'd expect, namely it loops a sound, which is to the right in the beginning, but moves to the center and finally just sounds in the left speaker and becomes more and more vague. So I tried to implement a basic sound manager for my game based on that program. But, for some reason, the sounds don't change positions (and therefore always play at the same volume level). Since the program above works, I'm guessing that it is not the binding that is to blame, but something I'm doing in my code. Probably doing something in the wrong order, or something. Anyone experienced the same thing? Here is the class:
class SoundManagerOpenAL:
	def __init__(self):
		### Initialize engine
		### The parameter is currently a guess since no real
		### documentation exists
		self.soundEngine = libal.SoundEngine(22000)
		self.soundEngine.SetListenerPosition(0, 0, 0)
		self.pathToSounds = "../media/sounds/"
		self.sounds = {}

	def setListenerPosition(self, pos):
		self.soundEngine.SetListenerPosition(pos[X], pos[Y], pos[Z])

	def addSound(self, name):
		if name not in self.sounds.keys() and name is not None:
				self.sounds[name] = libal.SoundSource(self.pathToSounds + name)
				print "SM: Could not add sound", name
	def playSound(self, name, loop, pos):
		if name is not None:
			self.sounds[name].SetPosition(pos[X], pos[Y], pos[Z])
			print "SM: Can not play None-sound!"

setListenerPosition() gets called every frame, and the position argument is correct (I've checked). The pos parameter in playSound also checks out with the positions of the objects.. [Edited by - Srekel on August 7, 2005 8:20:20 AM]

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!