API | Description |
StartAccompany | Starts playing back the accompaniment. |
StopAccompany | Stops playing back the accompaniment. |
IsAccompanyPlayEnd | Indicates whether the accompaniment is over. |
PauseAccompany | Pauses playing back the accompaniment. |
ResumeAccompany | Resumes playing back the accompaniment. |
SetAccompanyVolume | Sets the accompaniment volume. |
GetAccompanyVolume | Obtains the accompaniment volume. |
SetAccompanyFileCurrentPlayedTimeByMs | Sets the playback progress. |
EnableAudioCaputreDevice
to enable the capturing device, and call StartAccompany
to play back the accompaniment. To capture human voices via the microphone, you should call EnableAudioSend
to enable the microphone first.ITMGAudioEffectCtrl virtual int StartAccompany(const char* filePath, bool loopBack, int loopCount, int msTime)
Parameter | Type | Description |
filePath | char* | Path of the accompaniment file. |
loopBack | bool | Indicates whether to output the accompaniment in a mixing mode. This is generally set to true , indicating that the audience can also hear the accompaniment. |
loopCount | int | The number of loops. -1 indicates an infinite loop, and 0 indicates not to play back. |
msTime | int | Delay time |
// Code for WindowsITMGContextGetInstance()->GetAudioEffectCtrl()->StartAccompany(filePath,true,-1,0);// Code for AndroidITMGContext.GetInstance(this).GetAudioEffectCtrl().StartAccompany(filePath,true,loopCount,0);// Code for iOS[[[ITMGContext GetInstance] GetAudioEffectCtrl] StartAccompany:path loopBack:isLoopBack loopCount:loopCount msTime:0];
StartAccompanyDownloading
API to start downloading and playing back the accompaniment. The accompaniment download is implemented in the code. When the download is not completed, the file path can be passed as a parameter to StartAccompanyDownloading
, which can implement download-and-play. fileSize
is the estimated full file size. When calling this API to pass in a partially downloaded file, first ensure that the file size is at least 10 KB.ITMGAudioEffectCtrl virtual int StartAccompany(const char* filePath, bool loopBack, int loopCount, int msTime, int fileSize)
OnEvent
, and the event message ITMG_MAIN_EVENT_TYPE_ACCOMPANY_FINISH will be returned.
The returned parameter data
includes “result” and “file_path”.void TMGTestScene::OnEvent(ITMG_MAIN_EVENT_TYPE eventType,const char* data){switch (eventType) {case ITMG_MAIN_EVENT_TYPE_ENTER_ROOM:{// Processbreak;}...case ITMG_MAIN_EVENT_TYPE_ACCOMPANY_FINISH:{// Processbreak;}}}
ITMGAudioEffectCtrl virtual int StopAccompany(int duckerTime)
Parameter | Type | Description |
duckerTime | int | Ducking time |
ITMGContextGetInstance()->GetAudioEffectCtrl()->StopAccompany(0);
true
is returned. If it is not, false
is returned.ITMGAudioEffectCtrl virtual bool IsAccompanyPlayEnd()
ITMGContextGetInstance()->GetAudioEffectCtrl()->IsAccompanyPlayEnd();
ITMGAudioEffectCtrl virtual int PauseAccompany()
ITMGContextGetInstance()->GetAudioEffectCtrl()->PauseAccompany();
ITMGAudioEffectCtrl virtual int ResumeAccompany()
ITMGContextGetInstance()->GetAudioEffectCtrl()->ResumeAccompany();
ITMGAudioEffectCtrl virtual int EnableAccompanyPlay(bool enable)
Parameter | Type | Description |
enable | bool | Indicates whether the audience can hear the accompaniment. |
ITMGContextGetInstance()->GetAudioEffectCtrl()->EnableAccompanyPlay(false);
ITMGAudioEffectCtrl virtual int EnableAccompanyLoopBack(bool enable)
Parameter | Type | Description |
enable | bool | Indicates whether the audience can hear the accompaniment. |
ITMGContextGetInstance()->GetAudioEffectCtrl()->EnableAccompanyLoopBack(false);
ITMGAudioEffectCtrl virtual int SetAccompanyVolume(int vol)
Parameter | Type | Description |
vol | int | Specifies the volume value. |
int vol=100;ITMGContextGetInstance()->GetAudioEffectCtrl()->SetAccompanyVolume(vol);
ITMGAudioEffectCtrl virtual int GetAccompanyVolume()
ITMGContextGetInstance()->GetAudioEffectCtrl()->GetAccompanyVolume();
GetAccompanyFileTotalTimeByMs
and GetAccompanyFileCurrentPlayedTimeByMs
. Please note that Current/Total = current loop times, and Current % Total = current loop playback position.ITMGAudioEffectCtrl virtual int GetAccompanyFileTotalTimeByMs()ITMGAudioEffectCtrl virtual int GetAccompanyFileCurrentPlayedTimeByMs()
ITMGContextGetInstance()->GetAudioEffectCtrl()->GetAccompanyFileTotalTimeByMs();ITMGContextGetInstance()->GetAudioEffectCtrl()->GetAccompanyFileCurrentPlayedTimeByMs();
ITMGAudioEffectCtrl virtual int SetAccompanyFileCurrentPlayedTimeByMs(unsigned int time)
Parameter | Type | Description |
time | int | Specifies the playback progress in milliseconds |
ITMGContextGetInstance()->GetAudioEffectCtrl()->SetAccompanyFileCurrentPlayedTimeByMs(time);
ITMGAudioEffectCtrl virtual int SetAccompanyKey(int nKey)
Parameter | Type | Description |
nKey | int | Key(s) to adjust by. Value range (recommended): -4 to 4, where 0 indicates using the original key. |
Error Message | Error Code | Description | Solution |
QAV_ERR_ACC_OPENFILE_FAILED | 4001 | Failed to open the file | Checks whether the file or its path exists, and whether you have access to the file. |
QAV_ERR_ACC_FILE_FORAMT_NOTSUPPORT | 4002 | Invalid file format | Checks whether the file format is correct. |
QAV_ERR_ACC_DECODER_FAILED | 4003 | Decoding failure | Checks whether the file format is correct. |
QAV_ERR_ACC_BAD_PARAM | 4004 | Invalid parameter | Checks whether the parameters in the code are correct. |
QAV_ERR_ACC_MEMORY_ALLOC_FAILED | 4005 | Memory allocation failed | System resources have run out. If this error persists, please submit a ticket for assistance. |
QAV_ERR_ACC_CREATE_THREAD_FAILED | 4006 | Failed to create a thread | System resources have run out. If this error persists, please submit a ticket for assistance. |
QAV_ERR_ACC_STATE_ILLIGAL | 4007 | Invalid state | This error occurs if an API is called in a state that does not allow calling. |
Was this page helpful?