fix:调整发送g711音频数据、增加回声消除、增大缓冲区、调整A律解码效果

This commit is contained in:
liyi 2025-01-17 13:58:30 +08:00
parent 911396e1f3
commit 6f76a7d5b5
5 changed files with 24 additions and 11 deletions

View File

@ -77,6 +77,9 @@ class ConfiguringWifiLogic extends BaseGetXController {
if (reply is GatewayGetStatusReply) { if (reply is GatewayGetStatusReply) {
_replyGatewayGetStatusReply(reply); _replyGatewayGetStatusReply(reply);
} }
if (reply is GatewayGetStatusReply) {
_replyStatusInfo(reply);
}
}); });
} }
@ -329,4 +332,6 @@ class ConfiguringWifiLogic extends BaseGetXController {
break; break;
} }
} }
void _replyStatusInfo(reply) {}
} }

View File

@ -1,14 +1,17 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/main/lockMian/lockList/lockList_xhj_page.dart'; import 'package:star_lock/main/lockMian/lockList/lockList_xhj_page.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_state.dart'; import 'package:star_lock/main/lockMian/lockMain/lockMain_state.dart';
import 'package:star_lock/talk/call/g711.dart';
import 'package:star_lock/talk/startChart/proto/talk_data.pb.dart'; import 'package:star_lock/talk/startChart/proto/talk_data.pb.dart';
import 'package:star_lock/talk/startChart/proto/talk_expect.pb.dart'; import 'package:star_lock/talk/startChart/proto/talk_expect.pb.dart';
import 'package:star_lock/talk/startChart/proto/talk_request.pb.dart'; import 'package:star_lock/talk/startChart/proto/talk_request.pb.dart';

View File

@ -36,6 +36,7 @@ class TalkePingOverTimeTimerManager {
StartChartManage().sendTalkHangupMessage(); StartChartManage().sendTalkHangupMessage();
talkStatus.setNotTalkPing(); talkStatus.setNotTalkPing();
talkStatus.setEnd(); talkStatus.setEnd();
Get.back();
} }
} }

View File

@ -1,5 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
@ -11,6 +13,7 @@ import 'package:flutter_screen_recording/flutter_screen_recording.dart';
import 'package:flutter_voice_processor/flutter_voice_processor.dart'; import 'package:flutter_voice_processor/flutter_voice_processor.dart';
import 'package:gallery_saver/gallery_saver.dart'; import 'package:gallery_saver/gallery_saver.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
@ -43,7 +46,8 @@ class TalkViewLogic extends BaseGetXController {
Timer? _syncTimer; // Timer? _syncTimer; //
Timer? _audioTimer; // Timer? _audioTimer; //
int _startTime = 0; // int _startTime = 0; //
int bufferSize = 50; // int bufferSize = 40; //
int audioBufferSize = 500; //
int frameIntervalMs = 45; // 4522FPS int frameIntervalMs = 45; // 4522FPS
int audioFrameIntervalMs = 20; // 4522FPS int audioFrameIntervalMs = 20; // 4522FPS
@ -85,18 +89,13 @@ class TalkViewLogic extends BaseGetXController {
void _startListenTalkData() { void _startListenTalkData() {
state.talkDataRepository.talkDataStream.listen((TalkData talkData) async { state.talkDataRepository.talkDataStream.listen((TalkData talkData) async {
final contentType = talkData.contentType; final contentType = talkData.contentType;
int currentTimestamp = DateTime.now().millisecondsSinceEpoch;
// //
switch (contentType) { switch (contentType) {
case TalkData_ContentTypeE.G711: case TalkData_ContentTypeE.G711:
if (state.audioBuffer.length >= bufferSize) { if (state.audioBuffer.length >= audioBufferSize) {
state.audioBuffer.removeAt(0); // state.audioBuffer.removeAt(0); //
// readAudioBufferSize.removeAt(0); //
} }
state.audioBuffer.add(talkData); // state.audioBuffer.add(talkData); //
// readAudioBufferSize.add(talkData.content);
break; break;
case TalkData_ContentTypeE.Image: case TalkData_ContentTypeE.Image:
if (state.videoBuffer.length >= bufferSize) { if (state.videoBuffer.length >= bufferSize) {
@ -133,8 +132,9 @@ class TalkViewLogic extends BaseGetXController {
void _playAudioData(TalkData talkData) async { void _playAudioData(TalkData talkData) async {
if (state.isOpenVoice.value) { if (state.isOpenVoice.value) {
// final list = G711().convertList(talkData.content); // final list = G711().convertList(talkData.content);
final list = G711().convertList(talkData.content); // final list = G711().convertList(talkData.content);
// final list = G711().decodeAndDenoise(talkData.content, true,8000, 300, 50); final list =
G711().decodeAndDenoise(talkData.content, true, 8000, 300, 150);
// // PCM PcmArrayInt16 // // PCM PcmArrayInt16
final PcmArrayInt16 fromList = PcmArrayInt16.fromList(list); final PcmArrayInt16 fromList = PcmArrayInt16.fromList(list);
FlutterPcmSound.feed(fromList); FlutterPcmSound.feed(fromList);
@ -445,6 +445,9 @@ class TalkViewLogic extends BaseGetXController {
state.videoBuffer.clear(); // state.videoBuffer.clear(); //
_syncTimer?.cancel(); // _syncTimer?.cancel(); //
_syncTimer = null; // _syncTimer = null; //
_audioTimer?.cancel();
_audioTimer = null; //
stopProcessingAudio(); stopProcessingAudio();
super.onClose(); super.onClose();
} }

View File

@ -84,9 +84,10 @@ class TalkViewState {
late VoiceProcessor? voiceProcessor; // late VoiceProcessor? voiceProcessor; //
final int frameLength = 320; //640 final int frameLength = 320; //640
final int sampleRate = 8000; //8000 final int sampleRate = 8000; //8000
List<List<int>> recordingAudioAllFrames = <List<int>>[]; // List<int> recordingAudioAllFrames = <int>[]; //
List<int> lockRecordingAudioAllFrames = <int>[]; //
RxInt rotateAngle = 0.obs; // RxInt rotateAngle = 0.obs; //
RxBool isLongPressing = false.obs; // RxBool isLongPressing = false.obs; //
RxBool hasAudioData = false.obs; // RxBool hasAudioData = false.obs; //
RxInt lastAudioTimestamp = 0.obs; // RxInt lastAudioTimestamp = 0.obs; //
} }