LiteAVSDK
Tencent Cloud TRTC SDK, is a high availability components serving tens of thousands of enterprise customers, which is committed to helping you to minimize your research and development costs.
TXAudioEffectManager

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)
 

Detailed Description

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


Data Structure Documentation

◆ TXAudioMusicParam

class TXAudioMusicParam

Background music playback information

The information, including playback ID, file path, and loop times, is passed in the startPlayMusic API.

  1. If you play the same music track multiple times, please use the same ID instead of a separate ID for each playback.
  2. If you want to play different music tracks at the same time, use different IDs for them.
  3. If you use the same ID to play a music track different from the current one, the SDK will stop the current one before playing the new one.
+ Inheritance diagram for TXAudioMusicParam:

Properties

int32_t ID
 
NSInteger loopCount
 
BOOL publish
 
BOOL isShortFile
 

Property Documentation

◆ ID

- (int32_t) ID
readwritenonatomicassign

◆ isShortFile

- (BOOL) isShortFile
readwritenonatomicassign

◆ loopCount

- (NSInteger) loopCount
readwritenonatomicassign

◆ publish

- (BOOL) publish
readwritenonatomicassign

◆ TXAudioEffectManager

class TXAudioEffectManager
+ Inheritance diagram for 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:
 

Method Documentation

◆ enableVoiceEarMonitor:()

- (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.

Attention
In-ear monitoring can be enabled only when earphones are used. Please remind anchors to use wired earphones.
Parameters
enableYES: enable; NO: disable

◆ getMusicCurrentPosInMS:()

- (NSInteger) getMusicCurrentPosInMS: (int32_t)  id

Getting the playback progress (ms) of background music

Parameters
idMusic ID
Returns
The milliseconds that have passed since playback started. -1 indicates failure to get the the playback progress.

◆ getMusicDurationInMS:()

- (NSInteger) getMusicDurationInMS: (NSString *)  path

Getting the total length (ms) of background music

Parameters
pathPath of the music file.
Returns
The length of the specified music file is returned. -1 indicates failure to get the length.

◆ NS_UNAVAILABLE()

- (instancetype) NS_UNAVAILABLE

You cannot create a TXAudioEffectManager object. You need to obtain the object using the getAudioEffectManager API of TRTCCloud or TXLivePush.

◆ pausePlayMusic:()

- (void) pausePlayMusic: (int32_t)  id

Pausing background music

Parameters
idMusic ID

◆ resumePlayMusic:()

- (void) resumePlayMusic: (int32_t)  id

Resuming background music

Parameters
idMusic ID

◆ seekMusicToPosInMS:pts:()

- (void) seekMusicToPosInMS: (int32_t)  id
pts: (NSInteger)  pts 

Setting the playback progress (ms) of background music

Attention
Do not call this API frequently as the music file may be read and written to each time the API is called, which can be time-consuming. Wait till users finish dragging the progress bar before you call this API. The progress bar controller on the UI tends to update the progress at a high frequency as users drag the progress bar. This will result in poor user experience unless you limit the frequency.
Parameters
idMusic ID
ptsUnit: millisecond

◆ setAllMusicVolume:()

- (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.

  • Local volume: the volume of music heard by anchors
  • Remote volume: the volume of music heard by audience
Parameters
volumeVolume. Value range: 0-100; default: 100
Attention
If 100 is still not loud enough for you, you can set the volume to up to 150, but there may be side effects.

◆ setMusicPitch:pitch:()

- (void) setMusicPitch: (int32_t)  id
pitch: (double)  pitch 

Adjusting the pitch of background music

Parameters
idMusic ID
pitchPitch. Value range: floating point numbers in the range of [-1, 1]; default: 0.0f

◆ setMusicPlayoutVolume:volume:()

- (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.

Parameters
idMusic ID
volumeVolume. Value range: 0-100. default: 100
Attention
If 100 is still not loud enough for you, you can set the volume to up to 150, but there may be side effects.

◆ setMusicPublishVolume:volume:()

- (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.

Parameters
idMusic ID
volumeVolume. Value range: 0-100; default: 100
Attention
If 100 is still not loud enough for you, you can set the volume to up to 150, but there may be side effects.

◆ setMusicSpeedRate:speedRate:()

- (void) setMusicSpeedRate: (int32_t)  id
speedRate: (double)  speedRate 

Changing the speed of background music

Parameters
idMusic ID
speedRateMusic speed. Value range: floating point numbers in the range of [0.5, 2]; default: 1.0f

◆ setVoiceChangerType:()

- (void) setVoiceChangerType: (TXVoiceChangeType changerType

Setting voice changing effects

This API is used to set voice changing effects. For the effects supported, please see TXVoiceChangeType.

Attention
Effects become invalid after room exit. If you want to use the same effect after you enter the room again, you need to set the effect again using this API.

◆ setVoiceEarMonitorVolume:()

- (void) setVoiceEarMonitorVolume: (NSInteger)  volume

Setting in-ear monitoring volume

This API is used to set the volume of in-ear monitoring.

Parameters
volumeVolume. Value range: 0-100; default: 100
Attention
If 100 is still not loud enough for you, you can set the volume to up to 150, but there may be side effects.

◆ setVoicePitch:()

- (void) setVoicePitch: (double)  pitch

Setting speech pitch

This API is used to set the pitch of speech.

Parameters
pitchPtich,Value range: -1.0f~1.0f; default: 0.0f。

◆ setVoiceReverbType:()

- (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.

Attention
Effects become invalid after room exit. If you want to use the same effect after you enter the room again, you need to set the effect again using this API.

◆ setVoiceVolume:()

- (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.

Parameters
volumeVolume. Value range: 0-100; default: 100
Attention
If 100 is still not loud enough for you, you can set the volume to up to 150, but there may be side effects.

◆ startPlayMusic:onStart:onProgress:onComplete:()

- (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.

Attention
  1. If you play the same music track multiple times, please use the same ID instead of a separate ID for each playback.
  2. If you want to play different music tracks at the same time, use different IDs for them.
  3. If you use the same ID to play a music track different from the current one, the SDK will stop the current one before playing the new one.
Parameters
musicParamMusic parameter
startBlockCallback of starting music
progressBlockCallback of playback progress
completeBlockCallback of ending music

◆ stopPlayMusic:()

- (void) stopPlayMusic: (int32_t)  id

Stopping background music

Parameters
idMusic ID

Typedef Documentation

◆ TXAudioMusicCompleteBlock

typedef void(^ TXAudioMusicCompleteBlock) (NSInteger errCode)

Background music ended.

◆ TXAudioMusicProgressBlock

typedef void(^ TXAudioMusicProgressBlock) (NSInteger progressMs, NSInteger durationMs)

Playback progress of background music.

◆ TXAudioMusicStartBlock

typedef void(^ TXAudioMusicStartBlock) (NSInteger errCode)

Background music started.

Enumeration Type Documentation

◆ TXVoiceChangeType

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

Enumerator
TXVoiceChangeType_0 

Disable.

TXVoiceChangeType_1 

Child.

TXVoiceChangeType_2 

Little girl.

TXVoiceChangeType_3 

Middle-aged man.

TXVoiceChangeType_4 

Metal.

TXVoiceChangeType_5 

Nasal.

TXVoiceChangeType_6 

Foreign accent.

TXVoiceChangeType_7 

Trapped beast.

TXVoiceChangeType_8 

Otaku.

TXVoiceChangeType_9 

Electric.

TXVoiceChangeType_10 

Robot.

TXVoiceChangeType_11 

Ethereal.

◆ TXVoiceReverbType

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

Enumerator
TXVoiceReverbType_0 

Disable.

TXVoiceReverbType_1 

Karaoke.

TXVoiceReverbType_2 

Room.

TXVoiceReverbType_3 

Hall.

TXVoiceReverbType_4 

Low and deep.

TXVoiceReverbType_5 

Resonant.

TXVoiceReverbType_6 

Metal.

TXVoiceReverbType_7 

Husky.

TXVoiceReverbType_8 

ethereal

TXVoiceReverbType_9 

studio

TXVoiceReverbType_10 

melodious

TXVoiceReverbType_11 

phonograph

TXVoiceReverbType_12 

nature