feat: APP到锁声音调优
This commit is contained in:
parent
c6dce9eb00
commit
7a7e8aa408
@ -676,8 +676,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
List<int> adjustVolume(List<int> pcmList, double volume) {
|
||||
final List<int> adjustedPcmList = [];
|
||||
for (int pcmVal in pcmList) {
|
||||
final List<int> adjustedPcmList = <int>[];
|
||||
for (final int pcmVal in pcmList) {
|
||||
// 调整音量
|
||||
int adjustedPcmVal = (pcmVal * volume).round();
|
||||
|
||||
@ -698,8 +698,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
final List<int> adjustedPcmList = adjustVolume(pcmList, 5.0);
|
||||
|
||||
// 再进行 A-law 编码
|
||||
final List<int> aLawList = [];
|
||||
for (int pcmVal in adjustedPcmList) {
|
||||
final List<int> aLawList = <int>[];
|
||||
for (final int pcmVal in adjustedPcmList) {
|
||||
final int aLawVal = linearToALaw(pcmVal);
|
||||
aLawList.add(aLawVal);
|
||||
}
|
||||
@ -707,8 +707,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
int linearToALaw(int pcmVal) {
|
||||
const int ALAW_MAX = 0x7FFF; // 32767
|
||||
const int ALAW_BIAS = 0x84; // 132
|
||||
const int alawMax = 0x7FFF; // 32767
|
||||
const int alawBias = 0x84; // 132
|
||||
|
||||
int mask;
|
||||
int seg;
|
||||
@ -723,9 +723,9 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// Add bias and clamp to ALAW_MAX
|
||||
pcmVal += ALAW_BIAS;
|
||||
if (pcmVal > ALAW_MAX) {
|
||||
pcmVal = ALAW_MAX;
|
||||
pcmVal += alawBias;
|
||||
if (pcmVal > alawMax) {
|
||||
pcmVal = alawMax;
|
||||
}
|
||||
|
||||
// Determine segment
|
||||
@ -735,7 +735,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
if (seg >= 8) {
|
||||
aLawVal = 0x7F ^ mask; // Clamp to maximum value
|
||||
} else {
|
||||
int quantized = (pcmVal >> (seg + 3)) & 0xF;
|
||||
final int quantized = (pcmVal >> (seg + 3)) & 0xF;
|
||||
aLawVal = (seg << 4) | quantized;
|
||||
aLawVal ^= 0xD5; // XOR with 0xD5 to match standard A-law table
|
||||
}
|
||||
@ -744,7 +744,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
int search(int val) {
|
||||
final List<int> table = [
|
||||
final List<int> table = <int>[
|
||||
0xFF, // Segment 0
|
||||
0x1FF, // Segment 1
|
||||
0x3FF, // Segment 2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user