Add more IMBE audio processing.

This commit is contained in:
Jonathan Naylor 2019-02-05 07:58:38 +00:00
parent 8ff7bc7f64
commit 69a7c557dc
14 changed files with 594 additions and 106 deletions

View File

@ -0,0 +1,44 @@
0 78 24
1 121 24
2 163 25
3 202 28
4 248 30
5 295 27
6 340 32
7 391 32
8 440 25
9 484 32
alpha 533 25
bravo 576 31
charlie 629 26
delta 676 30
A 725 19
B 769 21
C 818 27
D 870 23
E 917 23
F 965 23
G 1014 22
H 1060 24
I 1109 18
J 1151 26
K 1207 26
L 1258 23
M 1305 21
N 1351 25
O 1401 19
P 1446 19
Q 1493 24
R 1543 23
S 1591 21
T 1644 23
U 1693 22
V 1740 19
W 1784 22
X 1831 24
Y 1883 34
Z 1943 25
linkedto 1995 40
notlinked 2088 50
linkingto 2158 44
isbusy 2268 40

View File

@ -0,0 +1,44 @@
0 82 21
1 120 15
2 160 19
3 198 22
4 236 35
5 288 24
6 329 31
7 378 27
8 422 27
9 466 24
alpha 506 32
bravo 558 27
charlie 604 38
delta 663 27
A 710 18
B 754 16
C 796 20
D 843 16
E 885 14
F 923 18
G 967 13
H 1005 19
I 1049 13
J 1087 23
K 1137 20
L 1180 20
M 1224 19
N 1268 17
O 1310 16
P 1352 15
Q 1395 17
R 1437 18
S 1480 19
T 1525 19
U 1569 18
V 1611 17
W 1655 34
X 1714 20
Y 1759 19
Z 1802 23
linkedto 1852 37
notlinked 1928 50
linkingto 1998 34
isbusy 2071 40

View File

@ -0,0 +1,44 @@
0 85 41
1 144 24
2 186 25
3 229 30
4 278 35
5 331 35
6 384 39
7 441 34
8 494 29
9 541 35
alpha 595 31
bravo 646 33
charlie 700 31
delta 753 30
A 804 24
B 850 33
C 898 23
D 933 33
E 990 34
F 1041 34
G 1093 34
H 1145 40
I 1204 30
J 1253 35
K 1307 33
L 1358 30
M 1406 28
N 1452 30
O 1500 23
P 1541 32
Q 1592 39
R 1648 23
S 1689 33
T 1742 32
U 1791 35
V 1845 33
W 1896 38
X 1953 35
Y 2007 28
Z 2060 37
linked 2124 19
notlinked 2194 44
linking 2258 31
isbusy 2350 33

View File

@ -0,0 +1,44 @@
0 89 39
1 146 34
2 202 22
3 246 31
4 294 34
5 345 46
6 409 39
7 466 37
8 521 29
9 568 35
alpha 621 26
bravo 669 34
charlie 726 34
delta 781 31
A 833 19
B 870 24
C 938 27
D 1009 24
E 1076 28
F 1148 29
G 1221 24
H 1290 31
I 1363 29
J 1432 33
K 1510 25
L 1578 22
M 1644 28
N 1715 28
O 1785 27
P 1858 24
Q 1927 25
R 1993 26
S 2063 29
T 2139 25
U 2208 25
V 2273 27
W 2344 33
X 2421 24
Y 2489 26
Z 2561 32
linked 2637 20
notlinked 2710 49
linking 2779 25
isbusy 2872 34

View File

@ -0,0 +1,44 @@
0 83 31
1 128 32
2 174 33
3 226 30
4 273 36
5 323 42
6 379 37
7 430 37
8 480 35
9 529 34
alpha 578 34
bravo 628 36
charlie 682 43
delta 742 38
A 798 26
B 836 22
C 881 22
D 923 24
E 967 17
F 1004 31
G 1053 26
H 1097 35
I 1150 20
J 1189 34
K 1246 22
L 1287 30
M 1337 30
N 1388 33
O 1439 22
P 1480 21
Q 1524 26
R 1571 32
S 1622 31
T 1675 22
U 1718 23
V 1756 28
W 1804 52
X 1876 28
Y 1925 17
Z 1961 35
linkedto 2017 64
notlinked 2133 68
linkingto 2217 66
isbusy 2364 58

View File

@ -0,0 +1,44 @@
0 94 29
1 140 16
2 173 20
3 215 19
4 255 24
5 298 29
6 344 34
7 398 25
8 440 24
9 481 23
alpha 521 29
bravo 568 27
charlie 615 30
delta 666 30
A 714 21
B 753 27
C 796 34
D 848 30
E 895 23
F 936 27
G 982 27
H 1026 30
I 1075 20
J 1113 29
K 1162 22
L 1201 28
M 1248 28
N 1295 28
O 1341 23
P 1386 21
Q 1426 23
R 1466 28
S 1511 31
T 1567 21
U 1606 22
V 1646 30
W 1693 46
X 1756 31
Y 1806 21
Z 1844 14
linkedto 1858 35
notlinked 1941 46
linkingto 2008 38
isbusy 2091 47

View File

@ -0,0 +1,44 @@
0 86 33
1 136 27
2 180 30
3 231 17
4 270 38
5 328 38
6 383 31
7 431 36
8 485 33
9 535 39
alpha 591 34
bravo 644 35
charlie 701 35
delta 757 34
A 810 12
B 840 19
C 883 17
D 923 17
E 965 14
F 1001 34
G 1058 20
H 1100 32
I 1155 14
J 1192 43
K 1263 30
L 1316 34
M 1373 30
N 1426 29
O 1477 13
P 1519 15
Q 1559 16
R 1598 28
S 1649 30
T 1699 20
U 1741 12
V 1775 21
W 1819 47
X 1888 25
Y 1936 43
Z 2002 35
linkedto 2064 48
notlinked 2154 65
linkingto 2239 41
isbusy 2321 51

View File

@ -0,0 +1,44 @@
0 67 28
1 102 29
2 137 27
3 170 25
4 199 36
5 238 30
6 272 38
7 314 31
8 349 34
9 386 28
alpha 418 36
bravo 472 30
charlie 519 34
delta 569 34
A 622 23
B 665 24
C 710 24
D 758 21
E 803 28
F 856 24
G 903 32
H 955 31
I 1007 18
J 1045 30
K 1100 28
L 1152 19
M 1196 20
N 1241 17
O 1282 27
P 1332 24
Q 1378 24
R 1426 19
S 1470 31
T 1524 24
U 1572 23
V 1616 20
W 1658 40
X 1722 32
Y 1779 24
Z 1823 29
linkedto 1882 40
notlinked 1966 49
linkingto 2034 40
isbusy 2148 38

View File

@ -0,0 +1,44 @@
0 99 36
1 163 38
2 229 29
3 290 31
4 351 37
5 420 42
6 490 41
7 559 43
8 630 34
9 692 50
alpha 771 30
bravo 820 32
charlie 873 35
delta 931 34
A 987 17
B 1012 30
C 1070 25
D 1118 27
E 1169 29
F 1221 36
G 1281 30
H 1333 26
I 1383 18
J 1425 32
K 1485 23
L 1532 26
M 1581 26
N 1629 24
O 1676 18
P 1724 23
Q 1773 20
R 1817 23
S 1863 35
T 1926 25
U 1975 22
V 2021 28
W 2070 15
X 2107 31
Y 2161 39
Z 2226 12
linkedto 2263 45
notlinked 2360 51
linkingto 2433 45
isbusy 2559 59

View File

@ -0,0 +1,44 @@
0 83 35
1 138 33
2 188 32
3 240 28
4 286 41
5 345 30
6 393 43
7 451 34
8 505 35
9 555 28
alpha 603 35
bravo 660 35
charlie 716 32
delta 768 48
A 836 30
B 894 28
C 946 33
D 1005 22
E 1053 34
F 1115 20
G 1160 36
H 1223 30
I 1280 27
J 1333 35
K 1393 29
L 1453 25
M 1507 26
N 1560 20
O 1607 26
P 1657 28
Q 1714 34
R 1781 23
S 1833 30
T 1890 25
U 1943 23
V 1989 35
W 2050 47
X 2126 27
Y 2178 19
Z 2223 45
linkedto 2298 39
notlinked 2390 51
linkingto 2461 36
isbusy 2577 54

View File

@ -153,32 +153,13 @@
<ClInclude Include="Network.h" />
<ClInclude Include="P25Gateway.h" />
<ClInclude Include="Reflectors.h" />
<ClInclude Include="Speech.h" />
<ClInclude Include="SpeechDisconnected.h" />
<ClInclude Include="SpeechEU.h" />
<ClInclude Include="SpeechEUTAC1.h" />
<ClInclude Include="SpeechEUTAC2.h" />
<ClInclude Include="SpeechEUTAC3.h" />
<ClInclude Include="SpeechFrance.h" />
<ClInclude Include="SpeechGermany.h" />
<ClInclude Include="SpeechNA.h" />
<ClInclude Include="SpeechNATAC1.h" />
<ClInclude Include="SpeechNATAC2.h" />
<ClInclude Include="SpeechNATAC3.h" />
<ClInclude Include="SpeechPacific.h" />
<ClInclude Include="SpeechPacificTAC1.h" />
<ClInclude Include="SpeechPacificTAC2.h" />
<ClInclude Include="SpeechPacificTAC3.h" />
<ClInclude Include="SpeechWW.h" />
<ClInclude Include="SpeechWWTAC1.h" />
<ClInclude Include="SpeechWWTAC2.h" />
<ClInclude Include="SpeechWWTAC3.h" />
<ClInclude Include="StopWatch.h" />
<ClInclude Include="Thread.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="UDPSocket.h" />
<ClInclude Include="Utils.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="Voice.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Conf.cpp" />
@ -188,12 +169,12 @@
<ClCompile Include="Network.cpp" />
<ClCompile Include="P25Gateway.cpp" />
<ClCompile Include="Reflectors.cpp" />
<ClCompile Include="Speech.cpp" />
<ClCompile Include="StopWatch.cpp" />
<ClCompile Include="Thread.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="UDPSocket.cpp" />
<ClCompile Include="Utils.cpp" />
<ClCompile Include="Voice.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -29,6 +29,9 @@
<ClInclude Include="P25Gateway.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Reflectors.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StopWatch.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -47,67 +50,7 @@
<ClInclude Include="Version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Reflectors.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechEU.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechNA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechPacific.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechWW.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Speech.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechEUTAC1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechEUTAC2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechEUTAC3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechFrance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechGermany.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechNATAC1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechNATAC2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechNATAC3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechPacificTAC1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechPacificTAC2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechPacificTAC3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechWWTAC1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechWWTAC2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechWWTAC3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpeechDisconnected.h">
<ClInclude Include="Voice.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
@ -130,6 +73,9 @@
<ClCompile Include="P25Gateway.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Reflectors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StopWatch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -145,10 +91,7 @@
<ClCompile Include="Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Reflectors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Speech.cpp">
<ClCompile Include="Voice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

View File

@ -102,6 +102,7 @@ m_timer(1000U, 1U),
m_stopWatch(),
m_sent(0U),
m_n(0x62U),
m_dstId(0U),
m_imbe(NULL),
m_voiceData(NULL),
m_voiceLength(0U),
@ -119,7 +120,7 @@ m_positions()
#endif
// Approximately 10 seconds worth
m_voiceData = new unsigned char[120U * NXDN_FRAME_LENGTH];
m_voiceData = new unsigned char[10U * 50U * IMBE_LENGTH];
}
CVoice::~CVoice()
@ -144,14 +145,14 @@ bool CVoice::open()
struct stat statStruct;
int ret = ::stat(m_imbeFile.c_str(), &statStruct);
if (ret != 0) {
LogError("Unable to stat the AMBE file - %s", m_imbeFile.c_str());
LogError("Unable to stat the IMBE file - %s", m_imbeFile.c_str());
::fclose(fpindx);
return false;
}
FILE* fpimbe = ::fopen(m_imbeFile.c_str(), "rb");
if (fpimbe == NULL) {
LogError("Unable to open the AMBE file - %s", m_imbeFile.c_str());
LogError("Unable to open the IMBE file - %s", m_imbeFile.c_str());
::fclose(fpindx);
return false;
}
@ -217,6 +218,8 @@ void CVoice::unlinked()
void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
{
m_dstId = tg;
m_voiceLength = 0U;
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
if (m_positions.count(*it) > 0U) {
@ -231,6 +234,11 @@ void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
m_voiceLength += SILENCE_LENGTH * IMBE_LENGTH;
m_voiceLength += SILENCE_LENGTH * IMBE_LENGTH;
// Round to the next highest LDU frame length
unsigned int n = (m_voiceLength / IMBE_LENGTH) % 9U;
if (n > 0U)
m_voiceLength += (9U - n) * IMBE_LENGTH;
// Fill the IMBE data with silence
unsigned int offset = 0U;
for (unsigned int i = 0U; i < (m_voiceLength / IMBE_LENGTH); i++, offset += IMBE_LENGTH)
@ -256,25 +264,140 @@ unsigned int CVoice::read(unsigned char* data)
if (m_status != VS_SENDING)
return 0U;
unsigned int count = m_stopWatch.elapsed() / P25_FRAME_TIME;
if (m_sent < count) {
unsigned int offset = m_sent * NXDN_FRAME_LENGTH;
::memcpy(data, m_voiceData + offset, NXDN_FRAME_LENGTH);
offset += NXDN_FRAME_LENGTH;
m_sent++;
if (offset >= m_voiceLength) {
m_timer.stop();
m_voiceLength = 0U;
m_status = VS_NONE;
}
return NXDN_FRAME_LENGTH;
if ((m_sent * IMBE_LENGTH) >= m_voiceLength) {
::memcpy(data, REC80, 17U);
m_timer.stop();
m_voiceLength = 0U;
m_status = VS_NONE;
return 17U;
}
return 0U;
unsigned int count = m_stopWatch.elapsed() / P25_FRAME_TIME;
unsigned int length = 0U;
if (m_sent < count) {
switch (m_n) {
case 0x62U:
::memcpy(data, REC62, 22U);
::memcpy(data + 10U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 22U;
m_n = 0x63U;
break;
case 0x63U:
::memcpy(data, REC63, 14U);
::memcpy(data + 1U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 14U;
m_n = 0x64U;
break;
case 0x64U:
::memcpy(data, REC64, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x65U;
break;
case 0x65U:
::memcpy(data, REC65, 17U);
data[1U] = (m_dstId >> 16) & 0xFFU;
data[2U] = (m_dstId >> 8) & 0xFFU;
data[3U] = (m_dstId >> 0) & 0xFFU;
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x66U;
break;
case 0x66U:
::memcpy(data, REC66, 17U);
data[1U] = (m_srcId >> 16) & 0xFFU;
data[2U] = (m_srcId >> 8) & 0xFFU;
data[3U] = (m_srcId >> 0) & 0xFFU;
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x67U;
break;
case 0x67U:
::memcpy(data, REC67, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x68U;
break;
case 0x68U:
::memcpy(data, REC68, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x69U;
break;
case 0x69U:
::memcpy(data, REC69, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x6AU;
break;
case 0x6AU:
::memcpy(data, REC6A, 16U);
::memcpy(data + 4U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 16U;
m_n = 0x6BU;
break;
case 0x6BU:
::memcpy(data, REC6B, 22U);
::memcpy(data + 10U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 22U;
m_n = 0x6CU;
break;
case 0x6CU:
::memcpy(data, REC6C, 14U);
::memcpy(data + 1U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 14U;
m_n = 0x6DU;
break;
case 0x6DU:
::memcpy(data, REC6D, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x6EU;
break;
case 0x6EU:
::memcpy(data, REC6E, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x6FU;
break;
case 0x6FU:
::memcpy(data, REC6F, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x70U;
break;
case 0x70U:
::memcpy(data, REC70, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x71U;
break;
case 0x71U:
::memcpy(data, REC71, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x72U;
break;
case 0x72U:
::memcpy(data, REC72, 17U);
::memcpy(data + 5U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 17U;
m_n = 0x73U;
break;
default:
::memcpy(data, REC73, 16U);
::memcpy(data + 4U, m_voiceData + (m_sent * IMBE_LENGTH), IMBE_LENGTH);
length = 16U;
m_n = 0x62U;
break;
}
m_sent++;
}
return length;
}
void CVoice::eof()

View File

@ -63,6 +63,7 @@ private:
CStopWatch m_stopWatch;
unsigned int m_sent;
unsigned int m_n;
unsigned int m_dstId;
unsigned char* m_imbe;
unsigned char* m_voiceData;
unsigned int m_voiceLength;