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

Namespaces

 liteav
 

Data Structures

class  ITXMusicPlayObserver
 
class  AudioMusicParam
 
class  ITXAudioEffectManager
 

Macros

#define __ITXAUDIOEFFECTMANAGER_H__
 

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

◆ liteav::ITXMusicPlayObserver

class liteav::ITXMusicPlayObserver

Public Member Functions

virtual ~ITXMusicPlayObserver ()
 
virtual void onStart (int id, int errCode)=0
 
virtual void onPlayProgress (int id, long curPtsMS, long durationMS)=0
 
virtual void onComplete (int id, int errCode)=0
 

Constructor & Destructor Documentation

◆ ~ITXMusicPlayObserver()

virtual ~ITXMusicPlayObserver ( )
inlinevirtual

Member Function Documentation

◆ onComplete()

virtual void onComplete ( int  id,
int  errCode 
)
pure virtual

Background music ended.

◆ onPlayProgress()

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

Playback progress of background music.

◆ onStart()

virtual void onStart ( int  id,
int  errCode 
)
pure virtual

Background music started.

◆ liteav::AudioMusicParam

class liteav::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
bool isShortFile
int loopCount

Field description:** absolute path of the music file or url.the mp3,aac,m4a,wav supported. char* 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.

bool publish

◆ liteav::ITXAudioEffectManager

class liteav::ITXAudioEffectManager

Protected Member Functions

 ITXAudioEffectManager ()
 
virtual ~ITXAudioEffectManager ()
 

Voice effect APIs

virtual void setVoiceReverbType (TXVoiceReverbType type)=0
 
virtual void setVoiceCaptureVolume (int volume)=0
 
virtual void setVoicePitch (double pitch)=0
 

Background music APIs

virtual void setMusicObserver (int musicId, ITXMusicPlayObserver *observer)=0
 
virtual void startPlayMusic (AudioMusicParam musicParam)=0
 
virtual void stopPlayMusic (int id)=0
 
virtual void pausePlayMusic (int id)=0
 
virtual void resumePlayMusic (int id)=0
 
virtual void setAllMusicVolume (int volume)=0
 
virtual void setMusicPublishVolume (int id, int volume)=0
 
virtual void setMusicPlayoutVolume (int id, int volume)=0
 
virtual void setMusicPitch (int id, float pitch)=0
 
virtual void setMusicSpeedRate (int id, float speedRate)=0
 
virtual long getMusicCurrentPosInMS (int id)=0
 
virtual long getMusicDurationInMS (char *path)=0
 
virtual void seekMusicToPosInTime (int id, int pts)=0
 

Constructor & Destructor Documentation

◆ ITXAudioEffectManager()

ITXAudioEffectManager ( )
inlineprotected

◆ ~ITXAudioEffectManager()

virtual ~ITXAudioEffectManager ( )
inlineprotectedvirtual

Member Function Documentation

◆ getMusicCurrentPosInMS()

virtual long getMusicCurrentPosInMS ( int  id)
pure virtual

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

virtual long getMusicDurationInMS ( char *  path)
pure virtual

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

virtual void pausePlayMusic ( int  id)
pure virtual

Pausing background music

Parameters
idMusic ID

◆ resumePlayMusic()

virtual void resumePlayMusic ( int  id)
pure virtual

Resuming background music

Parameters
idMusic ID

◆ seekMusicToPosInTime()

virtual void seekMusicToPosInTime ( int  id,
int  pts 
)
pure virtual

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

virtual void setAllMusicVolume ( int  volume)
pure virtual

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

virtual void setMusicObserver ( int  musicId,
ITXMusicPlayObserver observer 
)
pure virtual

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

virtual void setMusicPitch ( int  id,
float  pitch 
)
pure virtual

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

virtual void setMusicPlayoutVolume ( int  id,
int  volume 
)
pure virtual

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

virtual void setMusicPublishVolume ( int  id,
int  volume 
)
pure virtual

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

virtual void setMusicSpeedRate ( int  id,
float  speedRate 
)
pure virtual

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

virtual void setVoiceCaptureVolume ( int  volume)
pure virtual

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.

◆ setVoicePitch()

virtual void setVoicePitch ( double  pitch)
pure virtual

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

virtual void setVoiceReverbType ( TXVoiceReverbType  type)
pure virtual

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

virtual void startPlayMusic ( AudioMusicParam  musicParam)
pure virtual

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

virtual void stopPlayMusic ( int  id)
pure virtual

Stopping background music

Parameters
idMusic ID

Macro Definition Documentation

◆ __ITXAUDIOEFFECTMANAGER_H__

#define __ITXAUDIOEFFECTMANAGER_H__