AudioEffectStore
Introduction
AudioEffectStore provides a complete set of audio effect management APIs, including voice changer effects, reverb effects, and ear monitor functionality.
Through this class, anchors can adjust their voice effects in real-time during live streaming to enhance the experience.
Important:
Use the shared singleton to get the AudioEffectStore instance. The set effects will automatically become invalid after leaving the room, and need to be set again for the next room entry.
Note:
Audio effect state updates are delivered through the state publisher. Subscribe to it to receive real-time updates about voice changer, reverb, and ear monitor states.
Warning:
Due to the very high hardware latency of Bluetooth earphones, the ear monitor feature cannot be enabled when the anchor is wearing Bluetooth earphones. Please prompt the anchor to wear wired earphones in the user interface.
Features
Voice Changer Effects:Supports multiple voice changer effects such as child, little girl, uncle, etc.
Reverb Effects:Supports multiple reverb effects such as KTV, small room, auditorium, etc.
Ear Monitor:Anchors can hear their own voice in earphones, suitable for singing scenarios
Volume Control:Supports fine-grained ear monitor volume adjustment
Subscribable Data
AudioEffectState fields are described below:
Property | Type | Description |
audioChangerType | Voice changer state. | |
audioReverbType | Reverb state. | |
isEarMonitorOpened | Bool | Ear monitor enabled. |
earMonitorVolume | Int | Ear monitor volume, range 0 - 100.
If the volume is still too low after setting it to 100, you can set the volume to a maximum of 150, but a volume exceeding 100 may cause distortion, please operate with caution. |
API List
Function | Description |
Get singleton instance. | |
Set voice changer effect. | |
Set reverb effect. | |
Enable/disable ear monitor. | |
Set ear monitor volume. | |
Reset to default state. |
Getting Instance
shared
Get singleton instance
Voice Changer Settings
setAudioChangerType
Set voice changer effect
public func setAudioChangerType(type: AudioChangerType) {fatalError("\(#function) must be overridden by subclass")}
Through this interface, you can set the voice changer effect for human voice.
Voice changer effects can be applied to human voice, and the voice is processed secondarily through acoustic algorithms to obtain a timbre different from the original sound.
Version
Supported since version 3.5.
Notes
Note:
The set effect will automatically become invalid after leaving the room. If you need the corresponding effect for the next room entry, you need to call this interface again to set it.
Parameters
Parameter | Type | Required | Description |
type | Required | Voice changer effect type. |
Reverb Settings
setAudioReverbType
Set reverb effect
public func setAudioReverbType(type: AudioReverbType) {fatalError("\(#function) must be overridden by subclass")}
Through this interface, you can set the reverb effect for human voice.
Reverb effects can be applied to human voice, and the sound is processed through acoustic algorithms to simulate the presence in various different environments.
Version
Supported since version 3.5.
Notes
Note:
The set effect will automatically become invalid after leaving the room. If you need the corresponding effect for the next room entry, you need to call this interface again to set it.
Parameters
Parameter | Type | Required | Description |
type | Required | Reverb effect type. |
Ear Monitor Settings
setVoiceEarMonitorEnable
Enable/disable ear monitor
public func setVoiceEarMonitorEnable(enable: Bool) {fatalError("\(#function) must be overridden by subclass")}
After the anchor enables ear monitor, they can hear their own voice captured by the microphone in the earphones. This effect is suitable for anchor singing application scenarios.
Version
Supported since version 3.5.
Notes
Warning:
Due to the very high hardware latency of Bluetooth earphones, this effect cannot be enabled when the anchor is wearing Bluetooth earphones. Please try to prompt the anchor to wear wired earphones in the user interface.
Parameters
Parameter | Type | Required | Description |
enable | Bool | Required | Whether to enable ear monitor. |
setVoiceEarMonitorVolume
Set ear monitor volume
public func setVoiceEarMonitorVolume(volume: Int) {fatalError("\(#function) must be overridden by subclass")}
Through this interface, you can set the volume of the sound in the ear monitor effect.
Version
Supported since version 3.5.
Notes
Note:
If the volume is still too low after setting it to 100, you can set the volume to a maximum of 150, but a volume exceeding 100 may cause distortion, please operate with caution.
Parameters
Parameter | Type | Required | Description |
volume | Int | Required | Ear monitor volume, range 0 - 100. |
Reset
reset
Reset to default state
public func reset() {fatalError("\(#function) must be overridden by subclass")}
Reset all audio effect settings to default values, including disabling voice changer effect, disabling reverb effect, disabling ear monitor, and resetting ear monitor volume.
Version
Supported since version 3.5.
Data Structures
AudioChangerType
Voice changer effect type
Enum Value | Value | Description |
none | 0 | Disable effect. |
child | 1 | Child. |
littleGirl | 2 | Little girl. |
man | 3 | Uncle. |
heavyMetal | 4 | Heavy metal. |
cold | 5 | Cold. |
foreigner | 6 | Foreign accent. |
trappedBeast | 7 | Trapped beast. |
fatso | 8 | Otaku. |
strongCurrent | 9 | Strong current. |
heavyMachinery | 10 | Heavy machinery. |
ethereal | 11 | Ethereal. |
AudioReverbType
Reverb effect type
Enum Value | Value | Description |
none | 0 | Disable effect. |
ktv | 1 | KTV. |
smallRoom | 2 | Small room. |
auditorium | 3 | Auditorium. |
deep | 4 | Deep. |
loud | 5 | Loud. |
metallic | 6 | Metallic. |
magnetic | 7 | Magnetic. |
AudioEffectState
Audio effect related state data provided by AudioEffectStore
Property | Type | Description |
audioChangerType | Voice changer state. | |
audioReverbType | Reverb state. | |
isEarMonitorOpened | Bool | Ear monitor enabled. |
earMonitorVolume | Int | Ear monitor volume, range 0 - 100.
If the volume is still too low after setting it to 100, you can set the volume to a maximum of 150, but a volume exceeding 100 may cause distortion, please operate with caution. |
Usage Example
// Get singleton instancelet store = AudioEffectStore.shared// Subscribe to state changesstore.state.subscribe { state inprint("Current voice changer: \(state.audioChangerType)")print("Current reverb: \(state.audioReverbType)")print("Ear monitor enabled: \(state.isEarMonitorOpened)")}// Set voice changer effectstore.setAudioChangerType(type: .littleGirl)// Set reverb effectstore.setAudioReverbType(type: .ktv)// Enable ear monitorstore.setVoiceEarMonitorEnable(enable: true)store.setVoiceEarMonitorVolume(volume: 80)