WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-26-2008, 02:36 PM
roman_suvorov roman_suvorov is offline
Member
 
Join Date: May 2008
Location: Kingston, ON, Canada
Posts: 25
Question Sound doesn't play from director functions

Hello, when running a sample script like this one:

Code:
import viz
viz.go()

def playSound():
	sound = viz.addAudio("quack.wav")
	sound.play()
	return
	
viz.director(playSound)
.. no sound is played and the following error message is displayed:

Code:

** ERROR: Failed to create graph builder (CoInitialize has not been called. )
** ERROR: Failed to load audio 'quack.wav'
However, this works fine:
Code:
import viz
viz.go()
sound = viz.addAudio("quack.wav")
sound.play()
.. so I figured this must have something to do with Vizard's handling of director functions. Any ideas?
Reply With Quote
  #2  
Old 07-29-2008, 09:59 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You need to add the sound object in the main thread. Once it is added you should be able to play it in other director threads.

If it is necessary for you to add the sound object in the director thread, then you can install the pywin32 library for python and use the following code:
Code:
import viz
import pythoncom
viz.go()

def playSound():

	pythoncom.CoInitialize() #Initialize COM

	sound = viz.addAudio("quack.wav")
	sound.play()

	pythoncom.CoUninitialize() #Uninitialize COM

	return
	
viz.director(playSound)
Reply With Quote
  #3  
Old 07-29-2008, 12:25 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
If it takes a while to add the sound, would there be a frame rate blip on the add?

What if you added a 3D model with this method?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #4  
Old 07-29-2008, 02:28 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
If the audio takes a while to load, then adding the file during runtime will cause a stall in the framerate. In this case, you would use the modified version of the director function I posted above. This is not the case for 3D models though, they can be added as usual in director functions. The call to pythoncom.CoInitialize() is only necessary for COM/DirectX related objects.
Reply With Quote
  #5  
Old 07-31-2008, 08:31 AM
roman_suvorov roman_suvorov is offline
Member
 
Join Date: May 2008
Location: Kingston, ON, Canada
Posts: 25
Thanks farshizzo, very helpful as usual. Works flawlessly now.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sound Looping Problem JMOwens Vizard 4 09-29-2010 09:42 PM
On click Sound Play Problems Robbos Vizard 1 02-28-2008 02:02 PM
Stuttering sound Jerry Vizard 1 06-13-2007 12:36 PM
Sound in one ear only? Jerry Vizard 1 06-29-2006 04:26 PM
sound problem alaa Vizard 7 09-02-2005 01:13 PM


All times are GMT -7. The time now is 06:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC