RoomType
to 2
(recommended) or 3
for room entry.ITMGContext.GetInstance(this).Init(String.valueOf(mAppId), mUserId);// Initialize the SDKITMGContext.GetInstance(this).SetTMGDelegate(new MyDelegate());// Set the delegate class to receive various callbacks and eventsEnginePollHelper.createEnginePollHelper();// Call `Poll` periodically to trigger callbacksbyte[] authbuff = AuthBuffer.getInstance().genAuthBuffer(mAppId, mRoomId, mUserId,mAppKey);// Get the authentication informationITMGContext.GetInstance(this).EnterRoom(mRoomId, 2, authbuff);// Enter a room
TMGEngine_adv.h
header file to the same directory as the other SDK header files in your project.tmg_sdk_adv.h
and tmg_type_adv.h
and import them to the project.TMGEngine_Adv.cs
and ITMGEngine_Adv.cs
in the Unity
folder to the project to import them.StartRecord
API is used to start recording. There is a callback function for recording completion, and you need to listen for ITMG_MAIN_EVENT_TYPE_RECORD_COMPLETED
.int StartRecord(int type, String dstFile, String accMixFile, String accPlayFile)
Parameter | Type | Description |
type | int | Set this parameter to ITMG_AUDIO_RECORDING_KTV in a karaoke scenario or ITMG_AUDIO_RECORDING_SELF for an MP3 recording file. |
dstFile | String | Target file path for saving the recorded music |
accMixFile | String | Accompaniment without the original vocals, which can be mixed with voice to generate a music file. |
accPlayFile | String | Music file to be played back, which is the same file as accMixFile in normal cases. However, if the user is unfamiliar with the song, this parameter can be set to the path of the music file with the original vocals. In this case, the file with the original vocals will be played back, but the accompaniment without the original vocals will be mixed. |
//AndroidITMGAudioRecordCtrl.GetInstance().StartRecord(ITMGAudioRecordCtrl.ITMG_AUDIO_RECORDING_KTV, dstFile, accMixFile, accPlayFile);// iOS#import "GMESDK/TMGEngine_adv.h"[[ITMGAudioRecordCtrl GetInstance]StartPreview]
StopRecord
API is used to stop recording.int StopRecord()
PauseRecord
API is used to pause recording.int PauseRecord()
ResumeRecord
API is used to resume recording.int ResumeRecord()
ITMG_MAIN_EVENT_TYPE_RECORD_COMPLETED
is the callback for recording completion, which will be triggered when the accompaniment playback ends or StopRecord
is called.Parameter | Type | Description |
result | int | Recording result. 0 indicates success. For other error codes, troubleshoot as instructed in Error Codes. |
filepath | String | Target file path, which is the same as the dstFile parameter passed in through StartRecord . |
duration | String | Recording file duration in ms. |
StartRecord
API is called for recording, the music file to be played back will be set. This API can be used to set another file for playback. Generally, it is used to switch between the song with vocals and accompaniment without vocals.int SetAccompanyFile(String accPlayFile)
Parameter | Type | Description |
accPlayFile | String | Music file to be played back |
accMixFile
in ms.int GetAccompanyTotalTimeByMs()
int GetRecordTimeByMs()
int SetRecordTimeByMs(int timeMs)
Parameter | Type | Description |
timeMs | int | The time to be sought to in ms |
int GetRecordFileDurationByMs()
int StartPreview()
int StopPreview()
int PausePreview()
int ResumePreview()
int SetPreviewTimeByMs(int time)
Parameter | Type | Description |
time | int | Preview file time point in ms |
int GetPreviewTimeByMs()
ITMG_MAIN_EVENT_TYPE_RECORD_PREVIEW_COMPLETED
is the callback for preview completion, which will be triggered when the preview file playback ends or the StopPreview
API is called.Parameter | Type | Description |
result | int | Playback result. 0 indicates success. |
int MixRecordFile();
int CancelMixRecordFile();
ITMG_MAIN_EVENT_TYPE_RECORD_MIX_COMPLETED
is the callback for mix completion.Parameter | Type | Description |
result | int | Mix result. 0 indicates success. |
filepath | String | Target file path, which is the same as the dstFile parameter passed in through StartRecord . |
duration | String | Recording file duration in ms. |
int SetMixWieghts(float mic, float acc)
Parameter | Type | Description |
mic | float | Ratio of the voice volume level. Value range: 0–2. 1.0 , a value less than 1.0 , and a value greater than 1.0 indicate to keep, decrease, and increase the original volume level respectively. |
acc | float | Ratio of the accompaniment volume level. Value range: 0–2. 1.0 , a value less than 1.0 , and a value greater than 1.0 indicate to keep, decrease, and increase the original volume level respectively. |
int AdjustAudioTimeByMs(int time)
Parameter | Type | Description |
time | int | Offset of the voice against the accompaniment in ms. If the value is greater than 0 , the voice will be moved backward; if the value is less than 0 , the voice will be moved forward. |
int SetRecordKaraokeType(int type)
Parameter | Type | Description |
type | int | This type is the same as the karaoke sound effect type in voice chat. For more information, see Sound Effect in Voice Chat. |
Was this page helpful?