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

From Reallusion Wiki!
Jump to: navigation, search
m
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 is used for the recording of audio.
+
 
The functions GetAvailableDevices() can get a list of all available audio devices. Developer can use SetInputDevice() and GetInputDevice() to set/get current recording device. <syntaxhighlight lang="Python">
+
== Description ==
 +
 
 +
This class is used for the recording of audio. In addition, this class provides functionality for selecting the audio input.
 +
 
 +
See Also: [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]], [[IC_Python_API:RLPy_RAudioRecorderCallback|RAudioRecorderCallback]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== GetAudio ( self ) ===
 +
 
 +
Get the recorded audio object. If no recording exists then return '''None'''.
 +
 
 +
==== Returns ====
 +
:Audio object - [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
recorded_audio = audio_recorder.GetAudio()     # RIAudioObject
 +
</syntaxhighlight>
 +
 
 +
=== GetAvailableDevices ( self ) ===
 +
 
 +
Get all the available devices on this audio recorder.
 +
 
 +
==== Returns ====
 +
:All available recording devices - string list
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
audio_recorder = RLPy.RAudioRecorder()
 
audio_recorder = RLPy.RAudioRecorder()
# If you want to select your recording devices.
 
 
all_device = audio_recorder.GetAvailableDevices()
 
all_device = audio_recorder.GetAvailableDevices()
audio_recorder.SetInputDevice(all_device[0])
 
audio_recorder.Start()
 
#Recording is now started
 
#...
 
audio_recorder.Stop()
 
recorded_audio = audio_recorder.GetAudio() # RIAudioObject
 
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
+
 
===GetAudio===
+
=== GetInputDevice ( self ) ===
<syntaxhighlight lang="Python">
+
 
RLPy.RAudioRecorder.GetAudio ( self )
+
Get the name of the device on this audio recorder.
 +
 
 +
==== Returns ====
 +
:Current recording device name - string
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
all_device = audio_recorder.GetInputDevice()
 
</syntaxhighlight>
 
</syntaxhighlight>
Returns the recorded audio.
+
 
====Returns====
+
=== GetTimeLimit ( self ) ===
<div style="margin-left: 2em;">RIAudioObject - RLPy.RIAudioObject
+
 
</div>
+
Get this audio recorder's time limit.  
-----
+
 
===GetAvailableDevices===
+
==== Returns ====
<syntaxhighlight lang="Python">
+
:Time limit (default: 9,000,000 milliseconds or 15 minutes) - integer
RLPy.RAudioRecorder.GetAvailableDevices ( self )
+
 
</syntaxhighlight>
+
<syntaxhighlight lang="python" line='line'>
Returns a list of audio devices.
+
audio_recorder = RLPy.RAudioRecorder()
====Returns====
+
all_device = audio_recorder.GetTimeLimit()
<div style="margin-left: 2em;">Available device name list - string
+
</div>
+
-----
+
===GetInputDevice===
+
<syntaxhighlight lang="Python">
+
RLPy.RAudioRecorder.GetInputDevice ( self )
+
</syntaxhighlight>
+
Returns current audio input device.
+
====Returns====
+
<div style="margin-left: 2em;">Current input device name - string
+
</div>
+
-----
+
===GetTimeLimit===
+
<syntaxhighlight lang="Python">
+
RLPy.RAudioRecorder.GetTimeLimit ( self )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Get current limit time of Audio Recorder.
 
====Returns====
 
<div style="margin-left: 2em;">Limit of time in millisecond. The default value is 9000000 millisecond( 15 minutes ) - int
 
</div>
 
-----
 
===RegisterCallback===
 
<syntaxhighlight lang="Python">
 
RLPy.RAudioRecorder.RegisterCallback ( self, pCallback )
 
</syntaxhighlight>
 
Register audio recorder event callback.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pCallback''' [IN] RAudioRecorderCallback - RLPy.RAudioRecorderCallback
+
=== RegisterCallback ( self ) ===
</div>
+
 
-----
+
Register an audio recorder callback.
===SetInputDevice===
+
 
<syntaxhighlight lang="Python">
+
==== Parameters ====
RLPy.RAudioRecorder.SetInputDevice ( self, strInputAudioDeviceName )
+
:'''pCallback''' [IN] Audio recorder callback - [[IC_Python_API:RLPy_RAudioRecorderCallback|RAudioRecorderCallback]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
class RLAudioRecorderCallback(RLPy.RAudioRecorderCallback):
 +
    def __init__(self):
 +
        RLPy.RAudioRecorderCallback.__init__(self)
 +
        self.time_reached = None
 +
    def OnTimeLimitReached(self):
 +
        if self.time_reached != None:
 +
            self.time_reached()
 +
    def register_time_reached(self, func):
 +
        self.time_reached = func
 +
audio_callback = RLAudioRecorderCallback()
 +
audio_recorder = RLPy.RAudioRecorder()
 +
audio_recorder.RegisterCallback(audio_callback)
 
</syntaxhighlight>
 
</syntaxhighlight>
Select your recording device.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''strInputAudioDeviceName''' [IN] Device name - string
+
=== SetInputDevice ( self, strInuptAudioDeviceName ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Set the audio recording device name designated for usage.
  
'''RLPy.RStatus.Failure''' Fail
+
==== Parameters ====
</div>
+
:'''strInputAudioDeviceName''' [IN] Name of the recording device - string
-----
+
 
===SetTimeLimit===
+
==== Return ====
<syntaxhighlight lang="Python">
+
:Success - RLPy.RStatus.Success
RLPy.RAudioRecorder.SetTimeLimit ( self, nMillisecond )
+
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
all_device = audio_recorder.GetAvailableDevices()
 +
if len(all_device) > 0:
 +
    audio_recorder.SetInputDevice(all_device[0]))
 
</syntaxhighlight>
 
</syntaxhighlight>
Limit recording time for Audio Recorder.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nMillisecond''' [IN] limit of recording time in millisecond - int
+
=== SetTimeLimit ( self, nMillisecond ) ===
</div>
+
 
-----
+
Set the audio length limitation.  When the recording time exceeds this limitation, then the recording will automatically stop.
===Start===
+
 
<syntaxhighlight lang="Python">
+
=== Parameters ===
RLPy.RAudioRecorder.Start ( self )
+
:'''nMillisecond''' [IN] The time limit in milliseconds - integer
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
audio_recorder.SetTimeLimit(5000)
 
</syntaxhighlight>
 
</syntaxhighlight>
Starts recording from the audio input device.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''RLPy.RStatus.Success''' Success
+
=== Start ( self ) ===
  
'''RLPy.RStatus.Failure''' Fail
+
Start recording audio.  If the current recording device no longer exists, then return '''RLPy.RStatus.Failure'''.
</div>
+
 
-----
+
==== Return ====
===Stop===
+
:Success - RLPy.RStatus.Success
<syntaxhighlight lang="Python">
+
:Failure - RLPy.RStatus.Failure
RLPy.RAudioRecorder.Stop ( self )
+
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
audio_recorder.Start()
 
</syntaxhighlight>
 
</syntaxhighlight>
Stop recording from the audio input device.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''RLPy.RStatus.Success''' Success
+
=== Stop ( self ) ===
  
'''RLPy.RStatus.Failure''' Fail
+
Stop recording audio.
</div>
+
 
-----
+
==== Return ====
===UnregisterCallback===
+
:Success - RLPy.RStatus.Success
<syntaxhighlight lang="Python">
+
:Failure - RLPy.RStatus.Failure
RLPy.RAudioRecorder.UnregisterCallback ( self )
+
 
 +
<syntaxhighlight lang="python" line='line'>
 +
audio_recorder = RLPy.RAudioRecorder()
 +
audio_recorder.Stop()
 
</syntaxhighlight>
 
</syntaxhighlight>
Unregister network audio recorder event callback.
 

Latest revision as of 02:21, 23 April 2020

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

Description

This class is used for the recording of audio. In addition, this class provides functionality for selecting the audio input.

See Also: RIAudioObject, RAudioRecorderCallback

Member Functions

GetAudio ( self )

Get the recorded audio object. If no recording exists then return None.

Returns

Audio object - RIAudioObject
1 audio_recorder = RLPy.RAudioRecorder()
2 recorded_audio = audio_recorder.GetAudio()      # RIAudioObject

GetAvailableDevices ( self )

Get all the available devices on this audio recorder.

Returns

All available recording devices - string list
1 audio_recorder = RLPy.RAudioRecorder()
2 all_device = audio_recorder.GetAvailableDevices()

GetInputDevice ( self )

Get the name of the device on this audio recorder.

Returns

Current recording device name - string
1 audio_recorder = RLPy.RAudioRecorder()
2 all_device = audio_recorder.GetInputDevice()

GetTimeLimit ( self )

Get this audio recorder's time limit.

Returns

Time limit (default: 9,000,000 milliseconds or 15 minutes) - integer
1 audio_recorder = RLPy.RAudioRecorder()
2 all_device = audio_recorder.GetTimeLimit()

RegisterCallback ( self )

Register an audio recorder callback.

Parameters

pCallback [IN] Audio recorder callback - RAudioRecorderCallback
 1 class RLAudioRecorderCallback(RLPy.RAudioRecorderCallback):
 2     def __init__(self):
 3         RLPy.RAudioRecorderCallback.__init__(self)
 4         self.time_reached = None
 5     def OnTimeLimitReached(self):
 6         if self.time_reached != None:
 7             self.time_reached()
 8     def register_time_reached(self, func):
 9         self.time_reached = func
10 audio_callback = RLAudioRecorderCallback()
11 audio_recorder = RLPy.RAudioRecorder()
12 audio_recorder.RegisterCallback(audio_callback)

SetInputDevice ( self, strInuptAudioDeviceName )

Set the audio recording device name designated for usage.

Parameters

strInputAudioDeviceName [IN] Name of the recording device - string

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 audio_recorder = RLPy.RAudioRecorder()
2 all_device = audio_recorder.GetAvailableDevices()
3 if len(all_device) > 0:
4     audio_recorder.SetInputDevice(all_device[0]))

SetTimeLimit ( self, nMillisecond )

Set the audio length limitation. When the recording time exceeds this limitation, then the recording will automatically stop.

Parameters

nMillisecond [IN] The time limit in milliseconds - integer
1 audio_recorder = RLPy.RAudioRecorder()
2 audio_recorder.SetTimeLimit(5000)

Start ( self )

Start recording audio. If the current recording device no longer exists, then return RLPy.RStatus.Failure.

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 audio_recorder = RLPy.RAudioRecorder()
2 audio_recorder.Start()

Stop ( self )

Stop recording audio.

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 audio_recorder = RLPy.RAudioRecorder()
2 audio_recorder.Stop()