苹果手机视频对讲锁版音频播放增益问题

This commit is contained in:
sky.min 2026-01-16 10:10:31 +08:00
parent a2801fe613
commit 27c9614be3
2 changed files with 41 additions and 9 deletions

View File

@ -530,8 +530,21 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
///
void _playAudioData(TalkData talkData) async {
if (state.isOpenVoice.value && state.isLoading.isFalse && state.isRecordingAudio.value == false) {
if (state.isOpenVoice.value && state.isLoading.isFalse) {
//
List<int> encodedData = G711Tool.decode(talkData.content, 0); // 0A-law
//
if (Platform.isIOS) {
if (state.isRecordingAudio.value) {
//
encodedData = _applyGain(encodedData, 1.5);
} else {
// 使
encodedData = _applyGain(encodedData, 1.2);
}
}
// PCM PcmArrayInt16
final PcmArrayInt16 fromList = PcmArrayInt16.fromList(encodedData);
FlutterPcmSound.feed(fromList);
@ -871,10 +884,14 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
//
Future<void> _onFrame(List<int> frame) async {
final applyGain = _applyGain(frame, 1.6);
// iOS使用较低增益避免影响接收端灵敏度
double gainFactor = Platform.isIOS ? 0.6 : 1.2;
//
final gainApplied = _applyGain(frame, gainFactor);
// G711数据
List<int> encodedData = G711Tool.encode(applyGain, 0); // 0A-law
List<int> encodedData = G711Tool.encode(gainApplied, 0); // 0A-law
_bufferedAudioFrames.addAll(encodedData);
//

View File

@ -203,10 +203,21 @@ class TalkViewLogic extends BaseGetXController {
///
void _playAudioData(TalkData talkData) async {
if (state.isOpenVoice.value) {
final list =
G711().decodeAndDenoise(talkData.content, true, 8000, 300, 150);
// // PCM PcmArrayInt16
final PcmArrayInt16 fromList = PcmArrayInt16.fromList(list);
List<int> processedData = G711().decodeAndDenoise(talkData.content, true, 8000, 300, 150);
//
if (Platform.isIOS) {
if (state.isRecordingAudio.value) {
//
processedData = _applyGain(processedData, 1.5);
} else {
// 使
processedData = _applyGain(processedData, 1.2);
}
}
// PCM PcmArrayInt16
final PcmArrayInt16 fromList = PcmArrayInt16.fromList(processedData);
FlutterPcmSound.feed(fromList);
if (!state.isPlaying.value) {
FlutterPcmSound.play();
@ -651,10 +662,14 @@ class TalkViewLogic extends BaseGetXController {
//
Future<void> _onFrame(List<int> frame) async {
final applyGain = _applyGain(frame, 1.6);
// iOS使用较低增益避免影响接收端灵敏度
double gainFactor = Platform.isIOS ? 0.6 : 1.2;
//
final gainApplied = _applyGain(frame, gainFactor);
// G711数据
List<int> encodedData = G711Tool.encode(applyGain, 0); // 0A-law
List<int> encodedData = G711Tool.encode(gainApplied, 0); // 0A-law
_bufferedAudioFrames.addAll(encodedData);
//