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

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This is a utility class providing methods to manipulate audio files. <span style="backgroun...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This is a utility class providing methods to manipulate audio files.
+
 
<span style="background:#ffcccc">( Experimental Class )</span> <syntaxhighlight lang="Python">
+
== Description ==
# load audio by path
+
 
selection_list = RLPy.RScene.GetAvatars()
+
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 [[IC_Python_API:RLPy_RIProp|RIProp]] and [[IC_Python_API:RLPy_RIAvatar|RIAvatar]] are supported.
avatar = selection_list[0]
+
 
wav_file = "C://SpecialDay.wav"
+
See Also: [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
print(RLPy.RAudio.LoadAudioToObject(avatar, wav_file, RLPy.RTime(600)))
+
 
+
== Member Functions ==
 +
 
 +
=== CreateAudioObject() ===
 +
 
 +
Create a new empty audio object.
 +
 
 +
==== Returns ====
 +
:Audio object - [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
# load audio by audio object
 
# load audio by audio object
 
selection_list = RLPy.RScene.GetAvatars()
 
selection_list = RLPy.RScene.GetAvatars()
 
avatar = selection_list[0]
 
avatar = selection_list[0]
+
 
wav_file = "C://SpecialDay.wav"
 
wav_file = "C://SpecialDay.wav"
empty_object = RLPy.RAudio.CreateAudioObject()
+
audio_object = RLPy.RAudio.CreateAudioObject()
empty_object.Load(wav_file)
+
audio_object.Load(wav_file)
+
print(RLPy.RAudio.LoadAudioToObject(avatar, empty_object, RLPy.RTime(600)))
+
print(RLPy.RAudio.LoadAudioToObject(avatar, audio_object, RLPy.RTime(600)))
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
 
===CreateAudioObject===
 
<syntaxhighlight lang="Python">
 
RLPy.RAudio.CreateAudioObject ( )
 
</syntaxhighlight>
 
Returns the audio instance.
 
====Returns====
 
<div style="margin-left: 2em;">RIAudioObject - RLPy.RIAudioObject
 
</div>
 
-----
 
===LoadAudioToObject===
 
<syntaxhighlight lang="Python">
 
RLPy.RAudio.LoadAudioToObject ( args )
 
</syntaxhighlight>
 
Load audio to the target object and return audio length according to audio object.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''spObject''' [IN] load to which object (object can be avatar, prop) - RLPy.RIObject
+
=== LoadAudioToObject ( args ) ===
  
'''pAudioObject''' [IN] audio object store wave - RLPy.RIAudioObject
+
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.  
  
'''kStartTime''' [IN] the audio start time in the application in sec - RLPy.RTime
+
==== 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]]
 +
:'''strAudioPath''' [IN] Audio file location - string
 +
:'''kStartTime''' [IN] Start time for the imported audio - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
 +
:'''kFadeIn''' [IN] fade-in in sec (default: 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]]
  
'''nLoopCount''' [IN] audio loop count, default is 1 - int
+
==== Returns ====
 +
:Audio length in seconds. If audio import fails, return 0 - float
  
'''kFadeIn''' [IN] fade-in in sec, default is 0 - RLPy.RTime
+
<syntaxhighlight lang="python" line='line'>
 +
# load audio by path
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
wav_file = "C://music.mp3"
 +
print(RLPy.RAudio.LoadAudioToObject(avatar, wav_file, RLPy.RTime(600)))
 +
</syntaxhighlight>
  
'''kFadeOut''' [IN] fade-out in sec, default is 0 - RLPy.RTime
+
=== LoadAudioToObject ( args ) ===
  
'''kCutLength''' [IN] cut-length in sec, default is 0 - RLPy.RTime
+
Load an existing [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]] onto an existing object in the scene and return the duration of the audio in seconds.  Upon load failure, return 0 seconds.
</div>
+
 
====Returns====
+
See Also: [[IC_Python_API:RLPy_RIAudioObject#Load|RLPy.RIAudioObject.Load()]]
<div style="margin-left: 2em;">Audio length. If loaded failed return 0.0f - float
+
 
</div>
+
==== 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]]
 +
:'''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]]
 +
:'''nLoopCount''' [IN] Loop count (default: 1) - integer
 +
:'''kFadeIn''' [IN] fade-in in sec (default: 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]]
 +
 
 +
==== Returns ====
 +
:Audio data length in seconds; Return '''0''' upon import failure - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# load audio by audio object
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list [0]
 +
wav_file = "C://music.wav"
 +
audio_object = RLPy.RAudio.CreateAudioObject()
 +
audio_object .Load(wav_file)
 +
print(RLPy.RAudio.LoadAudioToObject(avatar, audio_object, RLPy.RTime(600)))
 +
</syntaxhighlight>

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)))