[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] 3D/2D sound?



John Eriksson wrote:
Hi,

Is there a way to control the volume of different speakers using pygame
(or a python package that can be used together with pygame)?

3D placement would be great but just to be able to set different volume
for two speakers would be sufficient.

thats panning, isnt it? The pygame channel set_volume() function allows to set the volume for each stereo channel.


http://www.pygame.org/docs/ref/mixer.html#Channel.play
http://www.pygame.org/docs/ref/mixer.html#Channel.set_volume

I think something like this should work, you need to pass the absolute path to the sound file.

import pygame
pygame.mixer.init(44100)
sound = pygame.mixer.Sound(/snds/mysnd.wav) # load it
c = pygame.mixer.find_channel() # get a free channel
c.set_volume(0.5, 0.5) # left and right chanel vol
c.play(sound)

For 3d sound you could try as well using some other sound engine like scsynth from supercollider, but thats another story ...


enrike