Difference between revisions of "IC Python API:RLPy RAudioRecorder"
From Reallusion Wiki!
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) 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}} | ||
− | == | + | {{last_modified}} |
− | This class is used for the recording of audio. | + | |
− | + | == 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() | ||
− | |||
all_device = audio_recorder.GetAvailableDevices() | all_device = audio_recorder.GetAvailableDevices() | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | |
− | === | + | === GetInputDevice ( self ) === |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RAudioRecorder. | + | 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> | ||
− | + | ||
− | === | + | === GetTimeLimit ( self ) === |
− | + | ||
− | + | Get this audio recorder's time limit. | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :Time limit (default: 9,000,000 milliseconds or 15 minutes) - integer | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | audio_recorder = RLPy.RAudioRecorder() | |
− | ====Returns==== | + | all_device = audio_recorder.GetTimeLimit() |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | <syntaxhighlight lang=" | + | |
− | RLPy.RAudioRecorder | + | |
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''pCallback''' [IN] | + | === RegisterCallback ( self ) === |
− | + | ||
− | + | Register an audio recorder callback. | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Parameters ==== |
− | RLPy. | + | :'''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> | ||
− | |||
− | |||
− | |||
− | + | === SetInputDevice ( self, strInuptAudioDeviceName ) === | |
− | + | ||
− | ==== | + | |
− | + | ||
− | + | Set the audio recording device name designated for usage. | |
− | ''' | + | ==== Parameters ==== |
− | + | :'''strInputAudioDeviceName''' [IN] Name of the recording device - string | |
− | + | ||
− | === | + | ==== Return ==== |
− | <syntaxhighlight lang=" | + | :Success - RLPy.RStatus.Success |
− | RLPy.RAudioRecorder. | + | :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> | ||
− | |||
− | |||
− | |||
− | '''nMillisecond''' [IN] | + | === SetTimeLimit ( self, nMillisecond ) === |
− | + | ||
− | + | Set the audio length limitation. When the recording time exceeds this limitation, then the recording will automatically stop. | |
− | + | ||
− | <syntaxhighlight lang=" | + | === Parameters === |
− | RLPy.RAudioRecorder. | + | :'''nMillisecond''' [IN] The time limit in milliseconds - integer |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | audio_recorder = RLPy.RAudioRecorder() | ||
+ | audio_recorder.SetTimeLimit(5000) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === Start ( self ) === | |
− | '''RLPy.RStatus.Failure''' | + | Start recording audio. If the current recording device no longer exists, then return '''RLPy.RStatus.Failure'''. |
− | + | ||
− | + | ==== Return ==== | |
− | === | + | :Success - RLPy.RStatus.Success |
− | <syntaxhighlight lang=" | + | :Failure - RLPy.RStatus.Failure |
− | RLPy.RAudioRecorder. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | audio_recorder = RLPy.RAudioRecorder() | ||
+ | audio_recorder.Start() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === Stop ( self ) === | |
− | + | Stop recording audio. | |
− | + | ||
− | + | ==== Return ==== | |
− | ==== | + | :Success - RLPy.RStatus.Success |
− | <syntaxhighlight lang=" | + | :Failure - RLPy.RStatus.Failure |
− | RLPy.RAudioRecorder ( | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | audio_recorder = RLPy.RAudioRecorder() | ||
+ | audio_recorder.Stop() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− |
Latest revision as of 01:21, 23 April 2020
Contents
- 1 Description
- 2 Member Functions
- 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()