PDA

View Full Version : Adding Audio to CAF Animation


WaterBottle
08-29-2011, 10:28 AM
What i need to do is play audio and a animation at the same time. I would like to combined those in one .caf file. Using 3ds max how can i make the caf file have audio so if i play it in vizard? Thanks

Jeff
08-29-2011, 10:42 AM
The Cal3D .caf file format is just for animations. In Vizard, you could play audio when the animation begins and stop the audio when it's done.

WaterBottle
08-29-2011, 11:00 AM
I was thinking about doing that but every time i play an audio and a animation at the same time one waits for the other to be complete. I tried using

viz.playSound('filename')

self.VizBody.state(1)



I know there must be a better way to do this i am just new to vizard.

Thanks

Jeff
08-30-2011, 06:54 PM
You could use a task function to play audio and stop if after the action is done:
import viz
import vizact
import viztask
viz.go()

avatar = viz.addAvatar('vcc_male.cfg',pos=[0,0,5],euler=[180,0,0])
avatar.state(1)
action = vizact.animation(3)

audio = viz.addAudio('jfk.wav',loop=1)

def animationTask():

while True:
yield viztask.waitKeyDown(' ')
audio.play()
yield viztask.runAction(avatar,action)
audio.stop()

viztask.schedule(animationTask())

If the sound is attached to the avatar you could use a sequence of actions:
import viz
import vizact
viz.go()

avatar = viz.addAvatar('vcc_male.cfg',pos=[0,0,5],euler=[180,0,0])
avatar.state(1)

startSound = vizact.method.playsound('jfk.wav',viz.LOOP)
action = vizact.animation(3)
stopSound = vizact.method.playsound('jfk.wav',viz.STOP)

actionSequence = vizact.sequence(startSound,action,stopSound)

vizact.onkeydown(' ',avatar.addAction,actionSequence)