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

Packages

package  com.tencent.liteav.audio
 

Data Structures

interface  TXAudioEffectManager.TXVoiceReverbType
 
interface  TXAudioEffectManager.TXVoiceChangerType
 
interface  TXAudioEffectManager.TXMusicPlayObserver
 
class  TXAudioEffectManager.AudioMusicParam
 
interface  TXAudioEffectManager
 

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

◆ com::tencent::liteav::audio::TXAudioEffectManager::TXVoiceReverbType

interface com::tencent::liteav::audio::TXAudioEffectManager::TXVoiceReverbType

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

Public Member Functions

 TXLiveVoiceReverbType_0 (0)
 
 TXLiveVoiceReverbType_1 (1)
 
 TXLiveVoiceReverbType_2 (2)
 
 TXLiveVoiceReverbType_3 (3)
 
 TXLiveVoiceReverbType_4 (4)
 
 TXLiveVoiceReverbType_5 (5)
 
 TXLiveVoiceReverbType_6 (6)
 
 TXLiveVoiceReverbType_7 (7)
 
 TXLiveVoiceReverbType_8 (8)
 
 TXLiveVoiceReverbType_9 (9)
 
 TXLiveVoiceReverbType_10 (10)
 
 TXLiveVoiceReverbType_11 (11)
 
 TXLiveVoiceReverbType_12 (12)
 
 TXVoiceReverbType (int value)
 
int getNativeValue ()
 

Constructor & Destructor Documentation

◆ TXVoiceReverbType()

TXVoiceReverbType ( int  value)
inline

Member Function Documentation

◆ getNativeValue()

int getNativeValue ( )
inline

◆ TXLiveVoiceReverbType_0()

TXLiveVoiceReverbType_0 ( )

◆ TXLiveVoiceReverbType_1()

TXLiveVoiceReverbType_1 ( )

< Disable

◆ TXLiveVoiceReverbType_10()

TXLiveVoiceReverbType_10 ( 10  )

< studio

◆ TXLiveVoiceReverbType_11()

TXLiveVoiceReverbType_11 ( 11  )

< melodious

◆ TXLiveVoiceReverbType_12()

TXLiveVoiceReverbType_12 ( 12  )

< phonograph

nature

◆ TXLiveVoiceReverbType_2()

TXLiveVoiceReverbType_2 ( )

< Karaoke

◆ TXLiveVoiceReverbType_3()

TXLiveVoiceReverbType_3 ( )

< Room

◆ TXLiveVoiceReverbType_4()

TXLiveVoiceReverbType_4 ( )

< Hall

◆ TXLiveVoiceReverbType_5()

TXLiveVoiceReverbType_5 ( )

< Low and deep

◆ TXLiveVoiceReverbType_6()

TXLiveVoiceReverbType_6 ( )

< Resonant

◆ TXLiveVoiceReverbType_7()

TXLiveVoiceReverbType_7 ( )

< Metal

◆ TXLiveVoiceReverbType_8()

TXLiveVoiceReverbType_8 ( )

< Husky

◆ TXLiveVoiceReverbType_9()

TXLiveVoiceReverbType_9 ( )

< ethereal

◆ com::tencent::liteav::audio::TXAudioEffectManager::TXVoiceChangerType

interface com::tencent::liteav::audio::TXAudioEffectManager::TXVoiceChangerType

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

Public Member Functions

 TXLiveVoiceChangerType_0 (0)
 
 TXLiveVoiceChangerType_1 (1)
 
 TXLiveVoiceChangerType_2 (2)
 
 TXLiveVoiceChangerType_3 (3)
 
 TXLiveVoiceChangerType_4 (4)
 
 TXLiveVoiceChangerType_5 (5)
 
 TXLiveVoiceChangerType_6 (6)
 
 TXLiveVoiceChangerType_7 (7)
 
 TXLiveVoiceChangerType_8 (8)
 
 TXLiveVoiceChangerType_9 (9)
 
 TXLiveVoiceChangerType_10 (10)
 
 TXLiveVoiceChangerType_11 (11)
 
 TXVoiceChangerType (int value)
 
int getNativeValue ()
 

Constructor & Destructor Documentation

◆ TXVoiceChangerType()

TXVoiceChangerType ( int  value)
inline

Member Function Documentation

◆ getNativeValue()

int getNativeValue ( )
inline

◆ TXLiveVoiceChangerType_0()

TXLiveVoiceChangerType_0 ( )

◆ TXLiveVoiceChangerType_1()

TXLiveVoiceChangerType_1 ( )

< Disable

◆ TXLiveVoiceChangerType_10()

TXLiveVoiceChangerType_10 ( 10  )

< Electric

◆ TXLiveVoiceChangerType_11()

TXLiveVoiceChangerType_11 ( 11  )

< Robot

Ethereal

◆ TXLiveVoiceChangerType_2()

TXLiveVoiceChangerType_2 ( )

< Child

◆ TXLiveVoiceChangerType_3()

TXLiveVoiceChangerType_3 ( )

< Little girl

◆ TXLiveVoiceChangerType_4()

TXLiveVoiceChangerType_4 ( )

< Middle-aged man

◆ TXLiveVoiceChangerType_5()

TXLiveVoiceChangerType_5 ( )

< Metal

◆ TXLiveVoiceChangerType_6()

TXLiveVoiceChangerType_6 ( )

< Nasal

◆ TXLiveVoiceChangerType_7()

TXLiveVoiceChangerType_7 ( )

< Foreign accent

◆ TXLiveVoiceChangerType_8()

TXLiveVoiceChangerType_8 ( )

< Trapped beast

◆ TXLiveVoiceChangerType_9()

TXLiveVoiceChangerType_9 ( )

< Otaku

◆ com::tencent::liteav::audio::TXAudioEffectManager::TXMusicPlayObserver

interface com::tencent::liteav::audio::TXAudioEffectManager::TXMusicPlayObserver

Public Member Functions

void onStart (int id, int errCode)
 
void onPlayProgress (int id, long curPtsMS, long durationMS)
 
void onComplete (int id, int errCode)
 

Member Function Documentation

◆ onComplete()

void onComplete ( int  id,
int  errCode 
)

Background music ended.

◆ onPlayProgress()

void onPlayProgress ( int  id,
long  curPtsMS,
long  durationMS 
)

Playback progress of background music.

◆ onStart()

void onStart ( int  id,
int  errCode 
)

Background music started.

◆ com::tencent::liteav::audio::TXAudioEffectManager::AudioMusicParam

class com::tencent::liteav::audio::TXAudioEffectManager::AudioMusicParam

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.
Data Fields
int id
boolean isShortFile
int loopCount

Field description:** absolute path of the music file or url.the mp3,aac,m4a,wav supported. public String path;

/****Field description:** number of times the music track is looped
Valid values: 0 or any positive integer. 0 (default) indicates that the music is played once, 1 twice, and so on.

boolean publish

◆ com::tencent::liteav::audio::TXAudioEffectManager

interface com::tencent::liteav::audio::TXAudioEffectManager

Voice effect APIs

void enableVoiceEarMonitor (boolean enable)
 
void setVoiceEarMonitorVolume (int volume)
 
void setVoiceReverbType (TXVoiceReverbType type)
 
void setVoiceChangerType (TXVoiceChangerType type)
 
void setVoiceCaptureVolume (int volume)
 
void setVoicePitch (double pitch)
 

Background music APIs

void setMusicObserver (int id, TXMusicPlayObserver observer)
 
boolean startPlayMusic (final AudioMusicParam musicParam)
 
void stopPlayMusic (int id)
 
void pausePlayMusic (int id)
 
void resumePlayMusic (int id)
 
void setAllMusicVolume (int volume)
 
void setMusicPublishVolume (int id, int volume)
 
void setMusicPlayoutVolume (int id, int volume)
 
void setMusicPitch (int id, float pitch)
 
void setMusicSpeedRate (int id, float speedRate)
 
long getMusicCurrentPosInMS (int id)
 
long getMusicDurationInMS (String path)
 
void seekMusicToPosInMS (int id, int pts)
 

Member Function Documentation

◆ enableVoiceEarMonitor()

void enableVoiceEarMonitor ( boolean  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
enabletrue: enable; false: disable

◆ getMusicCurrentPosInMS()

long getMusicCurrentPosInMS ( int  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()

long getMusicDurationInMS ( String  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.

◆ pausePlayMusic()

void pausePlayMusic ( int  id)

Pausing background music

Parameters
idMusic ID

◆ resumePlayMusic()

void resumePlayMusic ( int  id)

Resuming background music

Parameters
idMusic ID

◆ seekMusicToPosInMS()

void seekMusicToPosInMS ( int  id,
int  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 ( int  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.

◆ setMusicObserver()

void setMusicObserver ( int  id,
TXMusicPlayObserver  observer 
)

Setting the background music callback

Before playing background music, please use this API to set the music callback, which can inform you of the playback progress.

Parameters
musicIdMusic ID
observerFor more information, please see the APIs defined in ITXMusicPlayObserver.

◆ setMusicPitch()

void setMusicPitch ( int  id,
float  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()

void setMusicPlayoutVolume ( int  id,
int  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()

void setMusicPublishVolume ( int  id,
int  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()

void setMusicSpeedRate ( int  id,
float  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

◆ setVoiceCaptureVolume()

void setVoiceCaptureVolume ( int  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.

◆ setVoiceChangerType()

void setVoiceChangerType ( TXVoiceChangerType  type)

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 ( int  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  type)

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.

◆ startPlayMusic()

boolean startPlayMusic ( final AudioMusicParam  musicParam)

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 ( int  id)

Stopping background music

Parameters
idMusic ID