Difference between revisions of "IC Python API:RLPy RAudio"

From Reallusion Wiki!
Jump to: navigation, search
m
m
 
Line 39: Line 39:
 
:'''kStartTime''' [IN] Start time for the imported audio - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kStartTime''' [IN] Start time for the imported audio - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
 
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
:'''kFadeIn''' [IN] fade-in in sec, default is 0 - [[IC_Python_API:RLPy_RTime|RTime]]
+
:'''kFadeIn''' [IN] fade-in in sec (default: 0) - [[IC_Python_API:RLPy_RTime|RTime]]
:'''kFadeOut''' [IN] fade-out in sec, default is 0 - [[IC_Python_API:RLPy_RTime|RTime]]
+
:'''kFadeOut''' [IN] fade-out in sec (default: 0) - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kCutLength''' [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kCutLength''' [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - [[IC_Python_API:RLPy_RTime|RTime]]
  
Line 61: Line 61:
  
 
==== Parameters ====
 
==== Parameters ====
:'''spObject''' [IN] Target object for audio load ( only [[IC_Python_API:RLPy_RIProp|RIProp]] and [[IC_Python_API:RLPy_RIAvatar|RIAvatar]]) - [[IC_Python_API:RLPy_RIObject|RIObject]]
+
:'''spObject''' [IN] Target object for audio load (only [[IC_Python_API:RLPy_RIProp|RIProp]] and [[IC_Python_API:RLPy_RIAvatar|RIAvatar]]) - [[IC_Python_API:RLPy_RIObject|RIObject]]
 
:'''pAudioObject''' [IN] The pre-existing audio scene object - [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
 
:'''pAudioObject''' [IN] The pre-existing audio scene object - [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
 
:'''kStartTime''' [IN] Start time for the imported audio - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kStartTime''' [IN] Start time for the imported audio - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
 
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
:'''kFadeIn''' [IN] fade-in in sec, default is 0 - [[IC_Python_API:RLPy_RTime|RTime]]
+
:'''kFadeIn''' [IN] fade-in in sec (default: 0) - [[IC_Python_API:RLPy_RTime|RTime]]
:'''kFadeOut''' [IN] fade-out in sec, default is 0 - [[IC_Python_API:RLPy_RTime|RTime]]
+
:'''kFadeOut''' [IN] fade-out in sec (default: 0) - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kCutLength''' [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - [[IC_Python_API:RLPy_RTime|RTime]]
 
:'''kCutLength''' [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - [[IC_Python_API:RLPy_RTime|RTime]]
  

Latest revision as of 20:32, 23 April 2020

Main article: Modules. Last modified: 04/23/2020

Description

This class provides operations for loading audio to objects in the scene or generating empty audio objects. When an audio file is loaded onto an object, it will be deployed into the object's sound track. Only RIProp and RIAvatar are supported.

See Also: RIAudioObject

Member Functions

CreateAudioObject()

Create a new empty audio object.

Returns

Audio object - RIAudioObject
1 # load audio by audio object
2 selection_list = RLPy.RScene.GetAvatars()
3 avatar = selection_list[0]
4  
5 wav_file = "C://SpecialDay.wav"
6 audio_object = RLPy.RAudio.CreateAudioObject()
7 audio_object.Load(wav_file)
8  
9 print(RLPy.RAudio.LoadAudioToObject(avatar, audio_object, RLPy.RTime(600)))

LoadAudioToObject ( args )

Loads an audio file to an existing scene object and return the duration of the audio in seconds. Upon import failure, return 0 seconds. Currently, only wav and mp3 audio formats are supported.

Parameters

spObject [IN] Target object for audio load ( only RIPropand RIAvatar) - RIObject
strAudioPath [IN] Audio file location - string
kStartTime [IN] Start time for the imported audio - RTime
nLoopCount [IN] Loop count (default: 1) - integer
kFadeIn [IN] fade-in in sec (default: 0) - RTime
kFadeOut [IN] fade-out in sec (default: 0) - RTime
kCutLength [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - RTime

Returns

Audio length in seconds. If audio import fails, return 0 - float
1 # load audio by path
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 wav_file = "C://music.mp3"
5 print(RLPy.RAudio.LoadAudioToObject(avatar, wav_file, RLPy.RTime(600)))

LoadAudioToObject ( args )

Load an existing RIAudioObject onto an existing object in the scene and return the duration of the audio in seconds. Upon load failure, return 0 seconds.

See Also: RLPy.RIAudioObject.Load()

Parameters

spObject [IN] Target object for audio load (only RIProp and RIAvatar) - RIObject
pAudioObject [IN] The pre-existing audio scene object - RIAudioObject
kStartTime [IN] Start time for the imported audio - RTime
nLoopCount [IN] Loop count (default: 1) - integer
kFadeIn [IN] fade-in in sec (default: 0) - RTime
kFadeOut [IN] fade-out in sec (default: 0) - RTime
kCutLength [IN] Used to shorten the audio length. Default value is 0 equivalent to untruncated. - RTime

Returns

Audio data length in seconds; Return 0 upon import failure - float
1 # load audio by audio object
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list [0]
4 wav_file = "C://music.wav"
5 audio_object = RLPy.RAudio.CreateAudioObject()
6 audio_object .Load(wav_file)
7 print(RLPy.RAudio.LoadAudioToObject(avatar, audio_object, RLPy.RTime(600)))