![]() |
|
#1
|
|||
|
|||
|
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)
Code:
** ERROR: Failed to create graph builder (CoInitialize has not been called. ) ** ERROR: Failed to load audio 'quack.wav' Code:
import viz
viz.go()
sound = viz.addAudio("quack.wav")
sound.play()
|
|
#2
|
|||
|
|||
|
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)
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
Thanks farshizzo, very helpful as usual. Works flawlessly now.
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sound Looping Problem | JMOwens | Vizard | 4 | 09-29-2010 10:42 PM |
| On click Sound Play Problems | Robbos | Vizard | 1 | 02-28-2008 03:02 PM |
| Stuttering sound | Jerry | Vizard | 1 | 06-13-2007 01:36 PM |
| Sound in one ear only? | Jerry | Vizard | 1 | 06-29-2006 05:26 PM |
| sound problem | alaa | Vizard | 7 | 09-02-2005 02:13 PM |