human: 如何处理七牛云的实时音视频QNMicrophoneAudioTrack

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Linux
>QNMicrophoneAudioTrack

#  QNMicrophoneAudioTrack

最近更新时间: 2022-07-13 23:40:34

本地音频麦克风 Track 类

Hierarchy

  * [QNTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11222/QNTrack-Linux)
    * [QNLocalTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11208/QNLocalTrack-Linux)
      * [QNLocalVideoTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11209/QNLocalVideoTrack-Linux)
        * [QNCameraVideoTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11198/QNCameraVideoTrack-Linux)
        * [QNCustomVideoTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11205/QNCustomVideoTrack-Linux)
      * [QNLocalAudioTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11207/QNLocalAudioTrack-Linux)
        * QNMicrophoneAudioTrack 
        * [QNCustomAudioTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11203/QNCustomAudioTrack-Linux)
    * [QNRemoteTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11213/QNRemoteTrack-Linux)
      * [QNRemoteVideoTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11215/QNRemoteVideoTrack-Linux)
      * [QNRemoteAudioTrack](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11212/QNRemoteAudioTrack-Linux)

Index

Core Methods

  * GetTrackID
  * GetUserID
  * GetTag
  * IsAudio
  * IsVideo
  * IsMuted
  * SetMuted
  * SetAudioFrameListener
  * SetVolume
  * GetVolumeLevel
  * CreateAudioMusicMixer
  * CreateAudioEffectMixer
  * DestroyAudioMusicMixer
  * DestroyAudioEffectMixer

Core Methods

GetTrackID

  * virtual const std::string& GetTrackID() = 0
  * 获取 TrackID

Returns string

GetUserID

  * virtual const std::string& GetUserID() = 0
  * 获取 UserID

Returns string

GetTag

  * virtual const std::string& GetTag() = 0
  * 获取 Tag

Returns string

IsAudio

  * virtual bool IsAudio() = 0
  * 是否为音频 track

Returns bool

IsVideo

  * virtual bool IsVideo() = 0
  * 是否为视频 track

Returns bool

IsMuted

  * virtual bool IsMuted() = 0
  * 是否 muted

Returns bool

SetMuted

  * virtual void SetMuted(bool muted) = 0
  * 设置是否静默该 track，静默后，SDK 将会发送静默帧数据

Parameters

    * muted: bool 

是否静默

SetAudioFrameListener

  * virtual void SetAudioFrameListener([QNAudioFrameListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11189/QNAudioFrameListener-Linux)* listener) = 0
  * 设置是音频数据监听

Parameters

    * listener: [QNAudioFrameListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11189/QNAudioFrameListener-Linux)

音频数据监听接口

SetVolume

  * virtual void SetVolume(double volume) = 0
  * 设置采集音频音量（不改变系统设备的音量）

Parameters

    * volume: double 

音量大小，[1.0-10.0], 默认为 1.0

GetVolumeLevel

  * virtual float GetVolumeLevel() = 0
  * 获取音频采集的音量

Returns float

CreateAudioMusicMixer

  * virtual [QNAudioMusicMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11989/QNAudioMusicMixer)* CreateAudioMusicMixer(const std::string& music_path, [QNAudioMusicMixerListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11990/QNAudioMusicMixerListener)* listener) = 0
  * 创建背景音乐混音控制器对象

支持本地和在线文件，支持的文件格式为：aac、mp3、mp4、ogg、opus、wav、m4a、flac

> 注意：
>
> 1\. 背景音乐混音仅支持同时混合一路背景音乐，若需要切换背景音乐，重新调用本接口创建
> [QNAudioMusicMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-
> Linux/11989/QNAudioMusicMixer) 即可
>
> 2\. 建议使用本地文件进行混音，以避免网络环境差引起的混音异常
>
> 3\.
> 若您希望在混合背景音乐的同时添加音效，可参考音效混音相关接口([QNAudioEffectMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-
> Linux/11986/QNAudioEffectMixer))

Parameters

    * music_path: String 

音频文件路径，支持本地文件和在线文件

    * listener: [QNAudioMusicMixerListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11990/QNAudioMusicMixerListener)

混音控制器监听接口

Returns
[QNAudioMusicMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-
Linux/11989/QNAudioMusicMixer)

CreateAudioEffectMixer

  * virtual [QNAudioEffectMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11986/QNAudioEffectMixer)* CreateAudioEffectMixer([QNAudioEffectMixerListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11988/QNAudioEffectMixerListener)* listener) = 0
  * 创建音效混音控制器对象

> 音效混音支持同时混合多路音效文件

Parameters

    * listener: [QNAudioEffectMixerListener](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11988/QNAudioEffectMixerListener)

音效混音控制器监听接口

Returns
[QNAudioEffectMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-
Linux/11986/QNAudioEffectMixer)

DestroyAudioMusicMixer

  * virtual void DestroyAudioMusicMixer([QNAudioMusicMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11989/QNAudioMusicMixer)* mixer) = 0
  * 销毁 [QNAudioMusicMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11989/QNAudioMusicMixer) 实例

DestroyAudioEffectMixer

  * virtual void DestroyAudioEffectMixer([QNAudioEffectMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11986/QNAudioEffectMixer)* mixer) = 0
  * 销毁 [QNAudioEffectMixer](https://developer.qiniu.com/rtc/11210/QNMicrophoneAudioTrack-Linux/11986/QNAudioEffectMixer) 实例

以上内容是否对您有帮助？