In instant messaging applications, You need to select the audio input source based on different application scenarios. Different application scenarios correspond to different audio working modes. Anychat platform core SDK (v2.8.6 or later) supports multiple audio operation (Collection) modes, including:
1. Speech mode (default): The microphone is automatically selected as the audio input source device. The user's voice is collected by the microphone and special audio effect processing is enabled (including echo cancellation, mute detection, noise suppression, and automatic overflow ), this mode is usually used for interactive communication, user discussion, and other occasions [parameter value: 0];
2. Singing Mode: Automatically selects the audio mixing Input Source device. The sound played by the local computer is collected, and the SDK automatically shields the sound of other users (if not shielded, the user's voice will be collected and sent back to the user, and the user will hear an echo). The SDK will automatically disable audio special effect processing. This mode is usually used to play songs to other users, instead of worrying about other users' speeches [parameter value: 1];
3. Karaoke Mode: Automatic selection of two input source devices: Stereo Sound mixing and microphone (this feature is related to hardware. Some sound cards do not support simultaneous acquisition of microphone and stereo sound mixing ), the sound played by the local computer and the voice spoken by the user will be collected, and the SDK will automatically block the voice of other users, and the SDK will automatically disable the audio special effect processing, this mode is usually used to play songs to other users and sing with a microphone without worrying about other users' speeches. [parameter value: 2];
4. Line input mode: Automatically selects the line Input Source device, audio input through the line will be collected (usually refers to the application of connecting the audio output terminals of external DV, DVD, TV, and other devices to the linein port of the Sound Card ), the SDK automatically disables audio special effect processing. This mode is usually used to play the sound of an external device to other users without having to speak on their own, for example, when broadcasting TV signals to all users in the room, you can connect the video output of the TV to a dedicated video acquisition card, and connect the voice output of the TV to the linein interface of the sound card, select "line input mode", and other users in the current room will be able to watch the real-time TV screen and sound [parameter value: 3].
The typical code for modifying the audio working mode is as follows:
1.
DWORD dwaudiomode = 1; // change to playing mode
2.
BRAC_SetSDKOption(BRAC_SO_AUDIO_CPATUREMODE,(PCHAR)&dwAudioMode,sizeof(dwAudioMode));
When the anychat platform core SDK is initialized, the "Speak mode" is automatically started. to switch to another working mode, you need to set it through the corresponding interface (refer to: 64. brac_setsdkoption), after SDK Initialization is successful, you can switch dynamically. Because the SDK automatically selects the corresponding source device during the switching process, after switching, upper-layer applications need to update the current audio collection device and the corresponding audio special effect status.
The anychat platform core SDK dynamically adjusts the playback buffer size based on different modes and network statuses to control the playback latency. For example, in the speech mode, when the network conditions are good, the average latency is <300 ms. When the network conditions are poor, the average latency is <800 ms. However, the latency varies with the network status in other non-speaking modes such as the playing mode. In general, the speech mode has a low latency, ensuring real-time performance and non-speech mode. For example, the speech mode has a slight latency, ensuring abortion.
The anychat platform core SDK automatically records the work mode selected for the last upper-layer application. After the next re-run, the work mode of the previous record is automatically enabled. If you do not want the SDK to record the previous work mode, you can disable the SDK configuration file (remove the brac_func_config_localini parameter during SDK initialization, refer to: 11. initialize the SDK: brac_initsdk)