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

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class represents the sound object in the scene. The developer can load or save audio f...")
 
m
 
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 class represents the sound object in the scene.
+
 
The developer can load or save audio file through the method Load() or Save().
+
== Description ==
Only support WAV audio file in PCM format, can be one of the following:
+
 
8KHz mono 16bits, 11KHz mono 16bits, 22KHz mono 16bits, 44KHz mono
+
This class provides functionalities for audio objects in the scene to read and save sound files. Currently, only PCM format '''wav''' files are supported with the following channel, frequency, and bit rate configurations:
16bits, 16KHz mono 16bits, 48KHz mono 16bits, 8KHz stereo 16bits, 11KHz
+
 
stereo 16bits, 22KHz stereo 16bits, 44KHz stereo 16bits, 16KHz stereo
+
{| class="wikitable"
16bits and 48KHz mono 16bits. <syntaxhighlight lang="Python">
+
|-
# load wav file
+
|
 +
|mono 16 bits
 +
|stereo 16 bits
 +
|-
 +
|8 KHz
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
|-
 +
|11 KHz
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
|-
 +
|22 KHz
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
|-
 +
|44 KHz
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
|-
 +
|48 KHz
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
| style="text-align: center;" data-mce-style="text-align: center;"|✔
 +
|}
 +
 
 +
See Also: [[IC_Python_API:RLPy_RAudio|RAudio]], [[IC_Python_API:RLPy_RAudioRecorder|RAudioRecorder]]
 +
== Member Functions ==
 +
 
 +
=== HasData ( self ) ===
 +
 
 +
Check whether or not this audio object contains sound data.
 +
 
 +
==== Returns ====
 +
:'''True''' if this audio object contains sound data, else '''False''' - boolean
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
wav_path = "C:\\sample.wav"
 
wav_path = "C:\\sample.wav"
 
self.audio_object = RLPy.RAudio.CreateAudioObject()
 
self.audio_object = RLPy.RAudio.CreateAudioObject()
 
self.audio_object.Load(wav_path)
 
self.audio_object.Load(wav_path)
print(self.audio_object.HasData()) # True
+
print(self.audio_object.HasData()) # True
+
# save to file
+
save_path = "E:\\sample\\save.wav"
+
self.audio_object.Save(save_path)
+
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
 
===HasData===
 
<syntaxhighlight lang="Python">
 
RLPy.RIAudioObject.HasData ( self )
 
</syntaxhighlight>
 
Provides a way to determine if an element currently has any audio source.
 
====Returns====
 
<div style="margin-left: 2em;">True or Not - bool
 
</div>
 
-----
 
===Load===
 
<syntaxhighlight lang="Python">
 
RLPy.RIAudioObject.Load ( self, strPath )
 
</syntaxhighlight>
 
Load Audio Source from wave file.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''strPath''' [IN] file path - string
+
=== Load ( self, strPath ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Load a sound file onto this audio object.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also [[IC_Python_API:RLPy_RIAudioObject#Save|RLPy.RIAudioObject.Save()]]
</div>
+
 
-----
+
==== Parameters ====
===Save===
+
:'''strPath''' [IN] Audio file location - string
<syntaxhighlight lang="Python">
+
 
RLPy.RIAudioObject.Save ( self, strPath )
+
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
wav_path = "C:\\sample.wav"
 +
self.audio_object = RLPy.RAudio.CreateAudioObject()
 +
self.audio_object.Load(wav_path)
 
</syntaxhighlight>
 
</syntaxhighlight>
Save an Audio Source to wave file.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''strPath''' [IN] save file path - string
+
=== Save ( self, strPath ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Save the sound data on this audio object to a '''wav''' file.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also [[IC_Python_API:RLPy_RIAudioObject#Load|RLPy.RIAudioObject.Load()]]
</div>
+
 
 +
==== Parameters ====
 +
:'''strPath''' [IN] Location for saving the sound file - string
 +
 
 +
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
wav_path = "E:\\sample.wav"
 +
self.audio_object = RLPy.RAudio.CreateAudioObject()
 +
self.audio_object.Load(wav_path)
 +
self.audio_object.Save("E:\\sample2.wav")
 +
</syntaxhighlight>

Latest revision as of 22:07, 23 April 2020

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

Description

This class provides functionalities for audio objects in the scene to read and save sound files. Currently, only PCM format wav files are supported with the following channel, frequency, and bit rate configurations:

mono 16 bits stereo 16 bits
8 KHz
11 KHz
22 KHz
44 KHz
48 KHz

See Also: RAudio, RAudioRecorder

Member Functions

HasData ( self )

Check whether or not this audio object contains sound data.

Returns

True if this audio object contains sound data, else False - boolean
1 wav_path = "C:\\sample.wav"
2 self.audio_object = RLPy.RAudio.CreateAudioObject()
3 self.audio_object.Load(wav_path)
4 print(self.audio_object.HasData())  # True

Load ( self, strPath )

Load a sound file onto this audio object.

See Also RLPy.RIAudioObject.Save()

Parameters

strPath [IN] Audio file location - string

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 wav_path = "C:\\sample.wav"
2 self.audio_object = RLPy.RAudio.CreateAudioObject()
3 self.audio_object.Load(wav_path)

Save ( self, strPath )

Save the sound data on this audio object to a wav file.

See Also RLPy.RIAudioObject.Load()

Parameters

strPath [IN] Location for saving the sound file - string

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 wav_path = "E:\\sample.wav"
2 self.audio_object = RLPy.RAudio.CreateAudioObject()
3 self.audio_object.Load(wav_path)
4 self.audio_object.Save("E:\\sample2.wav")