Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / driving the voice device with Python
  RSS 2.0 ATOM  

driving the voice device with Python
Rate this thread
 
4270
 
Permlink of this thread  
avatar
  • AA74
  • Posted: 07 February 2008 08:01 AM
  • Location: Amsterdam
  • Total Posts: 3
  • Joined: 26 June 2007 08:31 PM

Hello,

Does anybody knows if it is possible to access the voice device using Python?

The only class i found in the python reference guide is FBDevice, but i didn’t get it to work;
FBDevice("test") produces an error: “This class cannot be instantiated from Python”

and, i’m not sure if it is the right class; seems to be more a generic one for all the devices

Thanks in advance
Cheers
Andrea A.



Replies: 0
avatar
  • CountZr0
  • Posted: 07 February 2008 11:14 AM

devices FBSystem().Devices

voice 
''

for device in devices:
   print 
device.Name
   
if device.Name == "Voice":
       
voice device

voice
.Online True


-jason

Replies: 0
avatar
  • AA74
  • Posted: 08 February 2008 10:30 AM

here I am again :-)

ok, now i got how to set the voice device, attach wave files etc.

then i started the procedures to plot;

everything seems ok, except from that i’m not able to stop it;
I mean, once i record and then i play i want to wait until i get to let’s say frame 60;

so i set up a while condition:

duration 60
system 
FBSystem()
scene 
system.Scene

while currentTime duration:
        
scene.Evaluate()
        
currentTimeStr system.LocalTime.GetTimeString()
        
currentTimeStr currentTimeStr.rstrip('*')
        
currentTime int(currentTimeStr)

so, before the while statement i start recording, then play and after it I stop the playerControl, in order to keep on going with the script;
it seems to work, but the voice device seems not to record anything; this may be the reason because I only get a key at first frame
once i plot on the character face

Does anybody have any idea on how to play the device wait until it stop and then plot; I think that the while solution is not really the ideal way?

Thanks!

Cheers
Andrea A.



Replies: 0
avatar
  • KxL
  • Posted: 09 February 2008 08:53 AM

I make a fast test with player start and stop. I will left to you making a tests with device - ok?

from pyfbsdk import *
import time

durationFrames 
60

FBPlayerControl
().Play()

while  
FBSystem().LocalTime.GetFrame(True) durationFrames:
    
time.sleep(0.05)

FBPlayerControl().Stop()

I hope that you will not have to make scene evaluation in while, becouse this will be totaly inefficient. Also I do not know how other MB threads are working when python interpreter are called, and script is running.



Replies: 0
avatar
  • AA74
  • Posted: 11 February 2008 08:44 AM

Hi!

I’m doing several tests and basically it seems to work;

actually i realised that the voice device was working even before;
what is not working is the plotting just straight after the “while"condition;

basically , MB plays, the device record, then i select a node and plot:

system=FBSystem()
take 
system.CurrentTake 
take
.Name clip.Name
    
options 
FBPlotOptions () 
options.ConstantKeyReducerKeepOneKey True 
options
.PlotAllTakes False 
options
.PlotOnFrame True 
options
.PlotPeriod FBTime 00010FBTimeMode.kFBTimeModeCustom15.0 
options.PlotTranslationOnRootOnly False 
options
.PreciseTimeDIscontinuities False 
options
.RotationFilterToApply FBRotationFilter.kFBRotationFilterUnroll 
options
.UseConstantKeyReducer True 

        
object 
FBFindModelByName("my_node")
object.Selected True    
take
.PlotTakeOnSelected(options.PlotPeriod)

if i run the script without plotting at the end, and plot by hand from the interface it works properly;
but if i run the last command “PlotTakeOnSelected”, it kind of flush the memory of the recorded device and i get only one key plotted;

so, i think that basically even if the interface is not refreshing, the device is recording;

Does anybody have any idea? I Hope i’m doing something wrong :-)

Cheers
Andrea,



Replies: 1
/img/forum/dark/default_avatar.png

hi, did you manage to fix this problem, I have exactly the same issue in MB 2012, and I don’t know how to fix it.
Cyril.

Author: cyrilm

Replied: 14 November 2011 01:10 AM