feat: 调整安卓声音卡顿现象
This commit is contained in:
parent
e1943d26d9
commit
35d22fd8ab
@ -81,6 +81,7 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
|
||||
// 收到来电请求时进行本地通知
|
||||
Future<void> _showTalkRequestNotification(
|
||||
{required String talkObjectName}) async {
|
||||
if (Platform.isAndroid) {
|
||||
final Map<String, dynamic> message = {
|
||||
'platform': 'all',
|
||||
'audience': 'all',
|
||||
@ -97,6 +98,7 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
|
||||
};
|
||||
|
||||
XSJPushProvider().showCustomNotification(message);
|
||||
}
|
||||
/*
|
||||
const AndroidNotificationDetails androidPlatformChannelSpecifics =
|
||||
AndroidNotificationDetails('1', 'flutter_channel',
|
||||
|
||||
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:math'; // Import the math package to use sqrt
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
|
||||
@ -576,12 +577,18 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 音频帧处理
|
||||
Future<void> _onFrame(List<int> frame) async {
|
||||
// 预处理和转码操作放到异步计算线程
|
||||
// final processedFrame = await compute(preprocessAudio, frame);
|
||||
// final list = listLinearToALaw(processedFrame);
|
||||
final List<int> processedFrame = preprocessAudio(frame);
|
||||
final List<int> list = listLinearToALaw(processedFrame);
|
||||
|
||||
final int ms = DateTime.now().millisecondsSinceEpoch -
|
||||
state.startRecordingAudioTime.value.millisecondsSinceEpoch;
|
||||
// 发送音频数据
|
||||
|
||||
// 发送音频数据到UDP
|
||||
await StartChartManage().sendTalkDataMessage(
|
||||
talkData: TalkData(
|
||||
content: list,
|
||||
@ -591,8 +598,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
);
|
||||
}
|
||||
|
||||
// 错误监听
|
||||
void _onError(VoiceProcessorException error) {
|
||||
// state.errorMessage.value = error.message!;
|
||||
AppLog.log(error.message!);
|
||||
}
|
||||
|
||||
@ -601,7 +608,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
final List<int> processedList = [];
|
||||
for (int pcmVal in pcmList) {
|
||||
// 简单的降噪示例:将小于阈值的信号置为0
|
||||
if (pcmVal.abs() < 300) {
|
||||
if (pcmVal.abs() < 200) {
|
||||
pcmVal = 0;
|
||||
}
|
||||
processedList.add(pcmVal);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user