Python Reference Guide
 
Loading...
Searching...
No Matches
Samples\Audio\AudioRendering.py
1# Copyright 2011 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5#
6# Script description:
7# Demonstrate audio render to export a wav file from MotionBuilder, and various options to set.
8#
9# Topic: FBAudioRenderOptions, FBApplication().AudioRender
10#
11from pyfbsdk import *
12import os
13import tempfile
14
15gSystem = FBSystem()
16
17# Load sample audio clip to scene
18lAudioSampleFile = os.path.join( gSystem.ApplicationPath, "../../OpenRealitySDK/Scenes/English.wav" )
19lAudio = FBAudioClip( lAudioSampleFile )
20
21# Instance a FBAudioRenderOptions (Default input parameter values are 2 channels, 16 bits, 44100 Hz)
22lAudioRenderOptions = FBAudioRenderOptions()
23
24# Set the TimeSpan for the audio render to begin and end.
25lAudioRenderOptions.TimeSpan = gSystem.CurrentTake.LocalTimeSpan
26
27# Set Channel mode, Mono or Stereo. Stereo default.
28lAudioRenderOptions.ChannelMode = FBAudioChannelMode.kFBAudioChannelModeStereo
29
30# Set Bit Depth mode, 8 bits and 16 bits available, 16 bits default.
31lAudioRenderOptions.BitDepthMode = FBAudioBitDepthMode.kFBAudioBitDepthMode_16
32
33#Set Rate mode, 44100 Hz default,8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000 available.
34lAudioRenderOptions.RateMode = FBAudioRateMode.kFBAudioRateMode_44100
35
36# Set Output file name. If file exists, it will be overwritten; if file is currently being opened by other application, export may fail.
37lAudioRenderOptions.OutputFileName = os.path.join( tempfile.gettempdir(), "Output.wav" )
38
39# Render the wave file with the options specified.
40if FBApplication().AudioRender(lAudioRenderOptions):
41 print("File successfully saved to %s" % lAudioRenderOptions.OutputFileName)
42else:
43 print("Failed to save file: %s" % lAudioRenderOptions.OutputFileName)
FBApplication is used mainly to manage files.
Definition: pyfbsdk_generated.h:801
Used to play audio clips and access their properties.
Definition: pyfbsdk_generated.h:1545
Audio Render Options structure.
Definition: pyfbsdk_generated.h:1957
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771