Data Structures | |
class | TXAudioMusicParam |
class | TXAudioEffectManager |
Definitions of enumerated values related to audio effects | |
enum | TXVoiceReverbType : NSInteger |
enum | TXVoiceChangeType : NSInteger |
Callback of playing background music | |
typedef void(^ | TXAudioMusicStartBlock) (NSInteger errCode) |
typedef void(^ | TXAudioMusicProgressBlock) (NSInteger progressMs, NSInteger durationMs) |
typedef void(^ | TXAudioMusicCompleteBlock) (NSInteger errCode) |
Tencent Cloud Audio Effect Management Module.
Module: management class for background music, short audio effects, and voice effects Description: sets background music, short audio effects, and voice effects
class TXAudioMusicParam |
Background music playback information
The information, including playback ID, file path, and loop times, is passed in the startPlayMusic API.
Properties | |
int32_t | ID |
NSInteger | loopCount |
BOOL | publish |
BOOL | isShortFile |
|
readwritenonatomicassign |
|
readwritenonatomicassign |
|
readwritenonatomicassign |
|
readwritenonatomicassign |
class TXAudioEffectManager |
Instance Methods | |
(instancetype) | - NS_UNAVAILABLE |
Voice effect APIs | |
(void) | - enableVoiceEarMonitor: |
(void) | - setVoiceEarMonitorVolume: |
(void) | - setVoiceReverbType: |
(void) | - setVoiceChangerType: |
(void) | - setVoiceVolume: |
(void) | - setVoicePitch: |
Background music APIs | |
(void) | - startPlayMusic:onStart:onProgress:onComplete: |
(void) | - stopPlayMusic: |
(void) | - pausePlayMusic: |
(void) | - resumePlayMusic: |
(void) | - setAllMusicVolume: |
(void) | - setMusicPublishVolume:volume: |
(void) | - setMusicPlayoutVolume:volume: |
(void) | - setMusicPitch:pitch: |
(void) | - setMusicSpeedRate:speedRate: |
(NSInteger) | - getMusicCurrentPosInMS: |
(NSInteger) | - getMusicDurationInMS: |
(void) | - seekMusicToPosInMS:pts: |
- (void) enableVoiceEarMonitor: | (BOOL) | enable |
Enabling in-ear monitoring
After enabling in-ear monitoring, anchors can hear in earphones their own voice captured by the mic. This is designed for singing scenarios.
In-ear monitoring cannot be enabled for Bluetooth earphones. This is because Bluetooth earphones have high latency. Please ask anchors to use wired earphones via a UI reminder. Given that not all phones deliver excellent in-ear monitoring effects, we have blocked this feature on some phones.
enable | YES: enable; NO : disable |
- (NSInteger) getMusicCurrentPosInMS: | (int32_t) | id |
Getting the playback progress (ms) of background music
id | Music ID |
- (NSInteger) getMusicDurationInMS: | (NSString *) | path |
Getting the total length (ms) of background music
path | Path of the music file. |
- (instancetype) NS_UNAVAILABLE |
You cannot create a TXAudioEffectManager
object. You need to obtain the object using the getAudioEffectManager
API of TRTCCloud
or TXLivePush
.
- (void) pausePlayMusic: | (int32_t) | id |
Pausing background music
id | Music ID |
- (void) resumePlayMusic: | (int32_t) | id |
Resuming background music
id | Music ID |
- (void) seekMusicToPosInMS: | (int32_t) | id | |
pts: | (NSInteger) | pts | |
Setting the playback progress (ms) of background music
id | Music ID |
pts | Unit: millisecond |
- (void) setAllMusicVolume: | (NSInteger) | volume |
Setting the local and remote playback volume of background music
This API is used to set the local and remote playback volume of background music.
volume | Volume. Value range: 0-100; default: 100 |
- (void) setMusicPitch: | (int32_t) | id | |
pitch: | (double) | pitch | |
Adjusting the pitch of background music
id | Music ID |
pitch | Pitch. Value range: floating point numbers in the range of [-1, 1]; default: 0.0f |
- (void) setMusicPlayoutVolume: | (int32_t) | id | |
volume: | (NSInteger) | volume | |
Setting the local playback volume of a specific music track
This API is used to control the local playback volume (the volume heard by anchors) of a specific music track.
id | Music ID |
volume | Volume. Value range: 0-100. default: 100 |
- (void) setMusicPublishVolume: | (int32_t) | id | |
volume: | (NSInteger) | volume | |
Setting the remote playback volume of a specific music track
This API is used to control the remote playback volume (the volume heard by audience) of a specific music track.
id | Music ID |
volume | Volume. Value range: 0-100; default: 100 |
- (void) setMusicSpeedRate: | (int32_t) | id | |
speedRate: | (double) | speedRate | |
Changing the speed of background music
id | Music ID |
speedRate | Music speed. Value range: floating point numbers in the range of [0.5, 2]; default: 1.0f |
- (void) setVoiceChangerType: | (TXVoiceChangeType) | changerType |
Setting voice changing effects
This API is used to set voice changing effects. For the effects supported, please see TXVoiceChangeType.
- (void) setVoiceEarMonitorVolume: | (NSInteger) | volume |
Setting in-ear monitoring volume
This API is used to set the volume of in-ear monitoring.
volume | Volume. Value range: 0-100; default: 100 |
- (void) setVoicePitch: | (double) | pitch |
Setting speech pitch
This API is used to set the pitch of speech.
pitch | Ptich,Value range: -1.0f~1.0f; default: 0.0f。 |
- (void) setVoiceReverbType: | (TXVoiceReverbType) | reverbType |
Setting voice reverb effects
This API is used to set reverb effects for human voice. For the effects supported, please see TXVoiceReverbType.
- (void) setVoiceVolume: | (NSInteger) | volume |
Setting speech volume
This API is used to set the volume of speech. It is often used together with the music volume setting API setAllMusicVolume to balance between the volume of music and speech.
volume | Volume. Value range: 0-100; default: 100 |
- (void) startPlayMusic: | (TXAudioMusicParam *) | musicParam | |
onStart: | (TXAudioMusicStartBlock _Nullable) | startBlock | |
onProgress: | (TXAudioMusicProgressBlock _Nullable) | progressBlock | |
onComplete: | (TXAudioMusicCompleteBlock _Nullable) | completeBlock | |
Starting background music
You must assign an ID to each music track so that you can start, stop, or set the volume of music tracks by ID.
musicParam | Music parameter |
startBlock | Callback of starting music |
progressBlock | Callback of playback progress |
completeBlock | Callback of ending music |
- (void) stopPlayMusic: | (int32_t) | id |
Stopping background music
id | Music ID |
typedef void(^ TXAudioMusicCompleteBlock) (NSInteger errCode) |
Background music ended.
typedef void(^ TXAudioMusicProgressBlock) (NSInteger progressMs, NSInteger durationMs) |
Playback progress of background music.
typedef void(^ TXAudioMusicStartBlock) (NSInteger errCode) |
Background music started.
enum TXVoiceChangeType : NSInteger |
Voice changing effects
Voice changing effects can be applied to human voice. Based on acoustic algorithms, they change the tone of voice. The following effects are supported currently: 0: original; 1: child; 2: little girl; 3: middle-aged man; 4: metal; 5: nasal; 6: foreign accent; 7: trapped beast; 8: otaku; 9: electric; 10: robot; 11: ethereal
enum TXVoiceReverbType : NSInteger |
Reverb effects
Reverb effects can be applied to human voice. Based on acoustic algorithms, they can mimic voice in different environments. The following effects are supported currently: 0: original; 1: karaoke; 2: room; 3: hall; 4: low and deep; 5: resonant; 6: metal; 7: husky; 8: ethereal; 9: studio; 10: melodious; 11: phonograph; 12: nature