Python Reference Guide
 
Loading...
Searching...
No Matches
FBAudioIn Class Reference

Audio In class. More...

#include <pyfbsdk_generated.h>

Inheritance diagram for FBAudioIn:

Public Member Functions

 FBAudioIn ()
 Constructor.
 
FBTime GetDelay ()
 Returns the delay currently set.
 
FBAudioOut GetDestination ()
 Returns the Audio Out object currently used as the destination.
 
FBAudioFmt GetRecordingFormat ()
 Returns the recording format (i.e.
 
FBAudioFmt GetSupportedFormats ()
 Returns all the Audio In supported formats (i.e.
 
bool IsOnline ()
 Is the Audio In online?
 
bool IsReadyToRecord ()
 Is the Audio In ready to record (has it been prepared properly)?
 
bool PrepareToRecord (str pRecordingPath, FBExistingClipAction pExistingClipAction=kFBExistingClipAskUser, FBExistingFileAction pExistingFileAction=kFBExistingFileAskUser)
 Prepares the Audio In for recording (similar as checking the "Record" checkbox in the UI).
 
bool SetDelay (FBTime pDelay)
 Sets the delay to use.
 
bool SetDestination (FBAudioOut pAudioOut)
 Sets the Audio Out object to be used as the destination.
 
bool SetOnline (bool pOnline)
 Turns Audio In online or offline.
 
bool SetRecordingFormat (FBAudioFmt pAudioFormat)
 Sets the recording format (i.e.
 
bool TurnOffRecording ()
 Turns off the Audio In recording (similar as un-checking the "Record" checkbox in the UI).
 
- Public Member Functions inherited from FBComponent
 FBComponent ()
 Constructor.
 
str ClassName ()
 Get the class name.
 
 DisableObjectFlags (FBObjectFlag pFlags)
 Disable a specific Object Flags.
 
 EnableObjectFlags (FBObjectFlag pFlags)
 Enable a specific Object Flags.
 
bool FBCreate ()
 Open Reality Creation function.
 
 FBDelete ()
 Open Reality deletion function.
 
 FBDestroy ()
 Open Reality destruction function.
 
FBObjectFlag GetObjectFlags ()
 Get all Object Flags (concatenated).
 
bool GetObjectStatus (FBObjectStatus pStatus)
 Check to see if an object status is enabled.
 
FBFileReference GetOwnerFileReference (p0)
 Get the owner FileReference object.
 
 HardSelect ()
 HardSelect.
 
bool HasObjectFlags (FBObjectFlag pFlags)
 Check whether a specific object flag is enabled.
 
bool Is (int pTypeId)
 Returns true if object is of type TypeId.
 
bool ProcessNamespaceHierarchy (FBNamespaceAction pNamespaceAction, str pNamespaceName, str pReplaceTo=None, bool pAddRight=True)
 ProcessNamespaceHierarchy.
 
bool ProcessObjectNamespace (FBNamespaceAction pNamespaceAction, str pNamespaceName, str pReplaceTo=None, bool pAddRight=True)
 ProcessObjectNamespace.
 
int PropertyAdd (FBProperty pProperty)
 Add a property to the component's property manager.
 
bool PropertyAddReferenceProperty (FBProperty pReferenceProperty)
 Add a reference property to the component's property manager.
 
FBProperty PropertyCreate (str pName, FBType pType, str pDataType, bool pAnimatable, bool pIsUser=False, FBProperty pReferenceSource=None)
 Create user or dynamic property.
 
 PropertyGetModifiedList (FBArrayTemplate< FB > pPropList, FBPlugModificationFlag pModificationFlags)
 Get list of properties which have been modified since last loading.
 
 PropertyRemove (FBProperty pProperty)
 Remove a Property from the component's Property manager.
 
 SetObjectFlags (FBObjectFlag pFlags)
 SetObjectFlags.
 
 SetObjectStatus (FBObjectStatus pStatus, bool pValue)
 Enable/Disable a specific Object Status.
 

Additional Inherited Members

- Public Attributes inherited from FBComponent
FBListComponent Components
 List: List of components.

 
str LongName
 Read Write Property: Name and namespace for object.

 
str Name
 Read Write Property: Unique name of object. See sample: RemoveSuffixFromNameOfSceneElements.py.
 
FBListComponent Parents
 List: Parents.

 
FBManager PropertyList
 Read Only Property: Manages all of the properties for the component.

 
bool Selected
 Read Write Property: Selected property.

 
int TypeInfo
 Contains the Type information of the object.

 
- Public Attributes inherited from FBPlug
str ClassGroupName
 ClassGroupName of the object.

 
int TypeInfo
 TypeInfo.

 

Detailed Description

Audio In class.


Used to control Audio In objects (like a Microphone Audio Device).

# This example shows how to prepare an FBAudioIn object for recording
# by redirecting the audio to an FBAudioOut object and
# by specifying a desired audio format and target audio file
from pyfbsdk import *
# Let's see how many FBAudioIn objects are available
lAudioIns = FBSystem().AudioInputs
print "The number of Audio Inputs:", len( lAudioIns )
if len( lAudioIns ) > 0:
# Work with the first Audio In object available
lAudioIn = lAudioIns[0]
print "Audio Input Name:", lAudioIn.Name
# Let's turn it offline, if not already
if lAudioIn.IsOnline():
print "Turned offline successful?", lAudioIn.SetOnline( False )
# Let's set the first AudioOut available as the Audio In destination
# if any destination is set yet
# (Windows Only)
if lAudioIn.GetDestination() == None:
lAudioOuts = FBSystem().AudioOutputs
print "The number of Audio Outputs:", len( lAudioOuts )
if len( lAudioOuts ) > 0:
# Work with the first Audio Out object available
lAudioOut = lAudioOuts[0]
print "Audio Output Name:", lAudioOut.Name
print "Setting destination successful?", lAudioIn.SetDestination( lAudioOut )
else:
print "No available Audio Out object available for destination"
else:
print "Audio Output <", lAudioIn.GetDestination().Name, "> already set for destination"
# Let's try to record an audio file in 8-bit, 22060 hz and in stereo
# Make sure this Audio In object supports this format
lSupportedFormats = lAudioIn.GetSupportedFormats()
# This format is supported, let's set it now
lNewFormat |= FBAudioFmt_ConvertRateMode( FBAudioRateMode.kFBAudioRateMode_22050 )
lNewFormat |= FBAudioFmt_ConvertChannelMode( FBAudioChannelMode.kFBAudioChannelModeStereo )
print "Setting recording format successful?", lAudioIn.SetRecordingFormat( lNewFormat )
# Let's add a delay of 3 frames
# (Windows only)
print "Setting delay successful?", lAudioIn.SetDelay( FBTime( 0, 0, 0, 3 ) )
# Let's turn it online now
print "Turned online successful?", lAudioIn.SetOnline( True )
# Now, prepare the Audio In object for recording
# To turn it off first, if already in "Record" state
if lAudioIn.IsReadyToRecord():
print "Turned Off Recording?", lAudioIn.TurnOffRecording()
lAudioFilePath = "C:\\temp\\myRecordedAudioFile.wav"
# Note: To remove pop-ups that may occurs, if required,
# look at the optional parameters of the PrepareToRecord method
print "Preparing to record successful?", lAudioIn.PrepareToRecord( lAudioFilePath )
if lAudioIn.IsReadyToRecord():
print "You are now ready to start recording and playback!"
else:
print "Something failed while preparing to record! Tip: Do you have a C:\temp folder?"
else:
print "This format (8-bit, 22060 hz, stereo) is not supported!"
else:
print "No available Audio In object available"
Enum FBAudioBitDepthMode.
Definition: pyfbsdk_generated.h:1521
kFBAudioBitDepthMode_8
8 bits, Wave file render support.
Definition: pyfbsdk_generated.h:1523
Enum FBAudioChannelMode.
Definition: pyfbsdk_generated.h:1532
kFBAudioChannelModeStereo
2 channels, Wave file render support.
Definition: pyfbsdk_generated.h:1535
bool SetRecordingFormat(FBAudioFmt pAudioFormat)
Sets the recording format (i.e.
Enum FBAudioRateMode.
Definition: pyfbsdk_generated.h:1932
kFBAudioRateMode_22050
22050 hz, Wave file render support.
Definition: pyfbsdk_generated.h:1939
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771
FBListAudioIn AudioInputs
List: Available audio inputs.
Definition: pyfbsdk_generated.h:18828
FBListAudioOut AudioOutputs
List: Available audio outputs.
Definition: pyfbsdk_generated.h:18830
Time data structure.
Definition: pyfbsdk_generated.h:19596
Python module pyfbsk.
Definition: pyfbsdk.h:90
FBAudioFmt FBAudioFmt_ConvertRateMode(FBAudioRateMode pRateMode)
Converts an FBAudioRateMode enum value to its FBAudioFmt object equivalent.
FBAudioFmt FBAudioFmt_ConvertChannelMode(FBAudioChannelMode pChannelMode)
Converts an FBAudioChannelMode enum value to its FBAudioFmt object equivalent.
FBAudioFmt FBAudioFmt_ConvertBitDepthMode(FBAudioBitDepthMode pBitDepthMode)
Converts an FBAudioBitDepthMode enum value to its FBAudioFmt object equivalent.

Constructor & Destructor Documentation

◆ FBAudioIn()

FBAudioIn ( )

Constructor.

Member Function Documentation

◆ GetDelay()

FBTime GetDelay ( )

Returns the delay currently set.

(Windows only).

Returns
The delay currently set.

◆ GetDestination()

FBAudioOut GetDestination ( )

Returns the Audio Out object currently used as the destination.

(Windows only).

Returns
The Audio Out object currently used as the destination. Returns a NULL pointer (None in Python) if any Audio Out object is currently set.

◆ GetRecordingFormat()

FBAudioFmt GetRecordingFormat ( )

Returns the recording format (i.e.

Bit Depth, Rate and Channel(s)) currently set.

Returns
The audio format currently set for recording.

◆ GetSupportedFormats()

FBAudioFmt GetSupportedFormats ( )

Returns all the Audio In supported formats (i.e.

Bit Depths, Rates and Channels).

Returns
The Audio In supported formats.

◆ IsOnline()

bool IsOnline ( )

Is the Audio In online?

Returns
True if the Audio In is online, false if it is offline.

◆ IsReadyToRecord()

bool IsReadyToRecord ( )

Is the Audio In ready to record (has it been prepared properly)?

Returns
True if the audio is ready to record, false otherwise.

◆ PrepareToRecord()

bool PrepareToRecord ( str  pRecordingPath,
FBExistingClipAction  pExistingClipAction = kFBExistingClipAskUser,
FBExistingFileAction  pExistingFileAction = kFBExistingFileAskUser 
)

Prepares the Audio In for recording (similar as checking the "Record" checkbox in the UI).

If the Audio In is not already online, it will turn it online automatically. If the Audio In is already ready to record, it will turn it off first automatically.

Parameters
pRecordingPathThe file path for the desired output wav file. The file must have the .wav extension.
pExistingClipActionThe action to perform when the action clip associated to the recording path is already in the scene.
pExistingFileActionThe action to perform when the file associated to the recording path already exists on disk and it not empty.
Returns
True if operation is successful, false otherwise. It could fail for different reasons (e.g. the specified file is not a WAV file or is invalid, the operation is abort by the user, etc.).

◆ SetDelay()

bool SetDelay ( FBTime  pDelay)

Sets the delay to use.

The Audio In must be offline when this method is called. (Windows only).

Parameters
pDelayThe delay to use. To mimic the UI, the FBTime should refer to a frame number.
Returns
True if operation is successful, false otherwise.

◆ SetDestination()

bool SetDestination ( FBAudioOut  pAudioOut)

Sets the Audio Out object to be used as the destination.

The Audio In must be offline when this method is called. (Windows only).

Parameters
pAudioOutThe Audio Out object to be used as the destination. Use a NULL pointer (None in Python) to unset the destination.
Returns
True if operation is successful, false otherwise.

◆ SetOnline()

bool SetOnline ( bool  pOnline)

Turns Audio In online or offline.

Parameters
pOnlineTrue to turn the Audio In online, false to turn it offline.
Returns
True if operation is successful, false otherwise.

◆ SetRecordingFormat()

bool SetRecordingFormat ( FBAudioFmt  pAudioFormat)

Sets the recording format (i.e.

Bit Depth, Rate and Channel(s)) to use. The Audio In must be offline when this method is called.

Parameters
pAudioFormatThe audio format to use for recording. It must specify a unique Bit Depth, Rate and Channels.
Returns
True if operation is successful, false otherwise. It could fail for different reasons (e.g. the specified audio format is not supported, more than one Bit Depth is specified, etc.).

◆ TurnOffRecording()

bool TurnOffRecording ( )

Turns off the Audio In recording (similar as un-checking the "Record" checkbox in the UI).

Returns
True if operation is successful, false otherwise.