plib playSample problem

Megaton

27-10-2007 13:34:07

Hi there.

I'm trying to use plib to play some sound effects but I ran into a problem. I can play a sound if I call playSample before I start calling update() in the main loop. If I call playSample after the first call to update(), then I don't hear any sound.

Perhaps I am doing this wrong?

Here is a modified version of the Demo_Sound.py that ships with Python Ogre 1.1. I am trying to get it to play a sound a few seconds into the main loop. But in this example I only hear the sound once, from the first call to playSample.


import ogre.addons.plib as plib
import time

sched = plib.slScheduler ( 8000 )
mixer = plib.smMixer ( "/dev/mixer" )

mixer.setMasterVolume ( 50 )
sched.setSafetyMargin ( 0.128 )

s1 = plib.slSample ( 'wheeee.ub', sched )
s2 = plib.slSample ( 'zzap.wav', sched )

s1.adjustVolume ( 10.0 )
print dir(sched)
sched.playSample ( s1 ) # Only play this once

tim = 0

while ( 1 ):
tim+=1
time.sleep ( 1 / 30 ) ## simulate 30 frames per second
sched.update ()
if tim == 300000:
print "A few seconds later, play another sound"
sched.playSample(s1)


Any help would be appreciated :)

SiWi

30-10-2007 07:06:53

I think the sound has to be played before the update(), because the update really plays the sound.

Megaton

30-10-2007 11:15:59

I'm sure that is what I'm doing :).

The problem I have is that I cannot play a second sound, as in my example. Surely I don't have to re-initialize the whole sound system for each sound I play, what if I want to play multiple sounds simultaneously?