Jump to content
  • Advertisement
Sign in to follow this  
Srekel

OpenAL problems [SOLVED]

This topic is 4852 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)
eng.SetListenerPosition(0,0,0)

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

x = 1
while 1:
	x += .0001
	eng.SetListenerPosition(x,0,0)



... 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 = {}

 		print "SM: SOUNDMANAGER INITIALIZED!"
 		
	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:
			try:
				self.sounds[name] = libal.SoundSource(self.pathToSounds + name)
				self.sounds[name].SetPosition(1,1,1)
			except:
				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])
			self.sounds[name].Play(loop)
		else:
			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
Advertisement
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!