# Copyright 2011 Autodesk, Inc. All rights reserved. # Use of this software is subject to the terms of the Autodesk license agreement # provided at the time of installation or download, or which otherwise accompanies # this software in either electronic or hard copy form. # # Script description: # Demonstrate audio render to export a wav file from MotionBuilder, and various options to set. # # Topic: FBAudioRenderOptions, FBApplication().AudioRender # from pyfbsdk import * import os import tempfile gSystem = FBSystem() # Load sample audio clip to scene lAudioSampleFile = os.path.join( gSystem.ApplicationPath, "../../OpenRealitySDK/Scenes/English.wav" ) lAudio = FBAudioClip( lAudioSampleFile ) # Instance a FBAudioRenderOptions (Default input parameter values are 2 channels, 16 bits, 44100 Hz) lAudioRenderOptions = FBAudioRenderOptions() # Set the TimeSpan for the audio render to begin and end. lAudioRenderOptions.TimeSpan = gSystem.CurrentTake.LocalTimeSpan # Set Channel mode, Mono or Stereo. Stereo default. lAudioRenderOptions.ChannelMode = FBAudioChannelMode.kFBAudioChannelModeStereo # Set Bit Depth mode, 8 bits and 16 bits available, 16 bits default. lAudioRenderOptions.BitDepthMode = FBAudioBitDepthMode.kFBAudioBitDepthMode_16 #Set Rate mode, 44100 Hz default,8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000 available. lAudioRenderOptions.RateMode = FBAudioRateMode.kFBAudioRateMode_44100 # Set Output file name. If file exists, it will be overwritten; if file is currently being opened by other application, export may fail. lAudioRenderOptions.OutputFileName = os.path.join( tempfile.gettempdir(), "Output.wav" ) # Render the wave file with the options specified. if FBApplication().AudioRender(lAudioRenderOptions): print "File successfully saved to %s" % lAudioRenderOptions.OutputFileName else: print "Failed to save file: %s" % lAudioRenderOptions.OutputFileName