mirror of
https://github.com/ShaYmez/P25Clients.git
synced 2024-11-22 12:24:17 -05:00
Further voice work.
This commit is contained in:
parent
0f35fc4d8f
commit
c9e2f13058
@ -41,7 +41,6 @@ m_callsign(),
|
|||||||
m_rptAddress(),
|
m_rptAddress(),
|
||||||
m_rptPort(0U),
|
m_rptPort(0U),
|
||||||
m_myPort(0U),
|
m_myPort(0U),
|
||||||
m_announcements(true),
|
|
||||||
m_daemon(false),
|
m_daemon(false),
|
||||||
m_lookupName(),
|
m_lookupName(),
|
||||||
m_lookupTime(0U),
|
m_lookupTime(0U),
|
||||||
@ -115,8 +114,6 @@ bool CConf::read()
|
|||||||
m_rptPort = (unsigned int)::atoi(value);
|
m_rptPort = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "LocalPort") == 0)
|
else if (::strcmp(key, "LocalPort") == 0)
|
||||||
m_myPort = (unsigned int)::atoi(value);
|
m_myPort = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Announcements") == 0)
|
|
||||||
m_announcements = ::atoi(value) == 1;
|
|
||||||
else if (::strcmp(key, "Daemon") == 0)
|
else if (::strcmp(key, "Daemon") == 0)
|
||||||
m_daemon = ::atoi(value) == 1;
|
m_daemon = ::atoi(value) == 1;
|
||||||
} else if (section == SECTION_ID_LOOKUP) {
|
} else if (section == SECTION_ID_LOOKUP) {
|
||||||
@ -183,11 +180,6 @@ unsigned int CConf::getMyPort() const
|
|||||||
return m_myPort;
|
return m_myPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConf::getAnnouncements() const
|
|
||||||
{
|
|
||||||
return m_announcements;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CConf::getDaemon() const
|
bool CConf::getDaemon() const
|
||||||
{
|
{
|
||||||
return m_daemon;
|
return m_daemon;
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
std::string getRptAddress() const;
|
std::string getRptAddress() const;
|
||||||
unsigned int getRptPort() const;
|
unsigned int getRptPort() const;
|
||||||
unsigned int getMyPort() const;
|
unsigned int getMyPort() const;
|
||||||
bool getAnnouncements() const;
|
|
||||||
bool getDaemon() const;
|
bool getDaemon() const;
|
||||||
|
|
||||||
// The Id Lookup section
|
// The Id Lookup section
|
||||||
@ -68,7 +67,6 @@ private:
|
|||||||
std::string m_rptAddress;
|
std::string m_rptAddress;
|
||||||
unsigned int m_rptPort;
|
unsigned int m_rptPort;
|
||||||
unsigned int m_myPort;
|
unsigned int m_myPort;
|
||||||
bool m_announcements;
|
|
||||||
bool m_daemon;
|
bool m_daemon;
|
||||||
|
|
||||||
std::string m_lookupName;
|
std::string m_lookupName;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016-2019 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,7 +23,7 @@
|
|||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Speech.h"
|
#include "Voice.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
@ -47,6 +47,8 @@ const char* DEFAULT_INI_FILE = "P25Gateway.ini";
|
|||||||
const char* DEFAULT_INI_FILE = "/etc/P25Gateway.ini";
|
const char* DEFAULT_INI_FILE = "/etc/P25Gateway.ini";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const unsigned P25_VOICE_ID = 10999U;
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
@ -197,9 +199,15 @@ void CP25Gateway::run()
|
|||||||
CStopWatch stopWatch;
|
CStopWatch stopWatch;
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
CSpeech* speech = NULL;
|
CVoice* voice = NULL;
|
||||||
if (m_conf.getAnnouncements())
|
if (m_conf.getVoiceEnabled()) {
|
||||||
speech = new CSpeech(localNetwork, rptAddr, rptPort);
|
voice = new CVoice(m_conf.getVoiceDirectory(), m_conf.getVoiceLanguage(), P25_VOICE_ID);
|
||||||
|
bool ok = voice->open();
|
||||||
|
if (!ok) {
|
||||||
|
delete voice;
|
||||||
|
voice = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LogMessage("Starting P25Gateway-%s", VERSION);
|
LogMessage("Starting P25Gateway-%s", VERSION);
|
||||||
|
|
||||||
@ -292,8 +300,12 @@ void CP25Gateway::run()
|
|||||||
lostTimer.stop();
|
lostTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speech != NULL)
|
if (voice != NULL) {
|
||||||
speech->announce(dstId);
|
if (dstId == 9999U)
|
||||||
|
voice->unlinked();
|
||||||
|
else
|
||||||
|
voice->linkedTo(dstId);
|
||||||
|
}
|
||||||
|
|
||||||
currentId = dstId;
|
currentId = dstId;
|
||||||
}
|
}
|
||||||
@ -317,8 +329,8 @@ void CP25Gateway::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (buffer[0U] == 0x80U) {
|
} else if (buffer[0U] == 0x80U) {
|
||||||
if (speech != NULL)
|
if (voice != NULL)
|
||||||
speech->eof();
|
voice->eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're linked and we have a network, send it on
|
// If we're linked and we have a network, send it on
|
||||||
@ -337,13 +349,19 @@ void CP25Gateway::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (voice != NULL) {
|
||||||
|
unsigned int length = voice->read(buffer);
|
||||||
|
if (length > 0U)
|
||||||
|
localNetwork.write(buffer, length, rptAddr, rptPort);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int ms = stopWatch.elapsed();
|
unsigned int ms = stopWatch.elapsed();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
reflectors.clock(ms);
|
reflectors.clock(ms);
|
||||||
|
|
||||||
if (speech != NULL)
|
if (voice != NULL)
|
||||||
speech->clock(ms);
|
voice->clock(ms);
|
||||||
|
|
||||||
inactivityTimer.clock(ms);
|
inactivityTimer.clock(ms);
|
||||||
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
|
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
|
||||||
@ -354,8 +372,8 @@ void CP25Gateway::run()
|
|||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
||||||
|
|
||||||
if (speech != NULL)
|
if (voice != NULL)
|
||||||
speech->announce(currentId);
|
voice->unlinked();
|
||||||
currentId = 9999U;
|
currentId = 9999U;
|
||||||
|
|
||||||
pollTimer.stop();
|
pollTimer.stop();
|
||||||
@ -380,8 +398,8 @@ void CP25Gateway::run()
|
|||||||
|
|
||||||
LogMessage("Linked to reflector %u due to inactivity", currentId);
|
LogMessage("Linked to reflector %u due to inactivity", currentId);
|
||||||
|
|
||||||
if (speech != NULL)
|
if (voice != NULL)
|
||||||
speech->announce(currentId);
|
voice->linkedTo(currentId);
|
||||||
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort);
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort);
|
||||||
@ -417,7 +435,7 @@ void CP25Gateway::run()
|
|||||||
CThread::sleep(5U);
|
CThread::sleep(5U);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete speech;
|
delete voice;
|
||||||
|
|
||||||
localNetwork.close();
|
localNetwork.close();
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ Callsign=G4KLX
|
|||||||
RptAddress=127.0.0.1
|
RptAddress=127.0.0.1
|
||||||
RptPort=32010
|
RptPort=32010
|
||||||
LocalPort=42020
|
LocalPort=42020
|
||||||
Announcements=1
|
|
||||||
Daemon=1
|
Daemon=1
|
||||||
|
|
||||||
[Id Lookup]
|
[Id Lookup]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2017,2018,2019 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,8 +27,64 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
const unsigned char HEADER[] = { 0x83U, 0x01U, 0x10U, 0x00U, 0x0FU, 0x01U, 0x00U, 0x20U };
|
const unsigned char REC62[] = {
|
||||||
const unsigned char TRAILER[] = { 0x83U, 0x01U, 0x10U, 0x00U, 0x0FU, 0x08U, 0x00U, 0x20U };
|
0x62U, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x12U, 0x64U, 0x00U, 0x00U, 0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
|
||||||
|
0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
|
const unsigned char REC63[] = {
|
||||||
|
0x63U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC64[] = {
|
||||||
|
0x64U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC65[] = {
|
||||||
|
0x65U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC66[] = {
|
||||||
|
0x66U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC67[] = {
|
||||||
|
0x67U, 0xF0U, 0x9DU, 0x6AU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC68[] = {
|
||||||
|
0x68U, 0x19U, 0xD4U, 0x26U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC69[] = {
|
||||||
|
0x69U, 0xE0U, 0xEBU, 0x7BU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC6A[] = {
|
||||||
|
0x6AU, 0x00U, 0x00U, 0x02U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
|
const unsigned char REC6B[] = {
|
||||||
|
0x6BU, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x12U, 0x64U, 0x00U, 0x00U, 0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
|
||||||
|
0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
|
const unsigned char REC6C[] = {
|
||||||
|
0x6CU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC6D[] = {
|
||||||
|
0x6DU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC6E[] = {
|
||||||
|
0x6EU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC6F[] = {
|
||||||
|
0x6FU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC70[] = {
|
||||||
|
0x70U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC71[] = {
|
||||||
|
0x71U, 0xACU, 0xB8U, 0xA4U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC72[] = {
|
||||||
|
0x72U, 0x9BU, 0xDCU, 0x75U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
|
||||||
|
|
||||||
|
const unsigned char REC73[] = {
|
||||||
|
0x73U, 0x00U, 0x00U, 0x02U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
|
const unsigned char REC80[] = {
|
||||||
|
0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
const unsigned char SILENCE[] = { 0xF0U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x78U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
const unsigned char SILENCE[] = { 0xF0U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x78U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
|
||||||
|
|
||||||
@ -47,13 +103,13 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
|
|||||||
CVoice::CVoice(const std::string& directory, const std::string& language, unsigned int srcId) :
|
CVoice::CVoice(const std::string& directory, const std::string& language, unsigned int srcId) :
|
||||||
m_language(language),
|
m_language(language),
|
||||||
m_indxFile(),
|
m_indxFile(),
|
||||||
m_ambeFile(),
|
m_imbeFile(),
|
||||||
m_srcId(srcId),
|
m_srcId(srcId),
|
||||||
m_status(VS_NONE),
|
m_status(VS_NONE),
|
||||||
m_timer(1000U, 1U),
|
m_timer(1000U, 1U),
|
||||||
m_stopWatch(),
|
m_stopWatch(),
|
||||||
m_sent(0U),
|
m_sent(0U),
|
||||||
m_ambe(NULL),
|
m_imbe(NULL),
|
||||||
m_voiceData(NULL),
|
m_voiceData(NULL),
|
||||||
m_voiceLength(0U),
|
m_voiceLength(0U),
|
||||||
m_positions()
|
m_positions()
|
||||||
@ -63,10 +119,10 @@ m_positions()
|
|||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
m_indxFile = directory + "\\" + language + ".indx";
|
m_indxFile = directory + "\\" + language + ".indx";
|
||||||
m_ambeFile = directory + "\\" + language + ".nxdn";
|
m_imbeFile = directory + "\\" + language + ".p25";
|
||||||
#else
|
#else
|
||||||
m_indxFile = directory + "/" + language + ".indx";
|
m_indxFile = directory + "/" + language + ".indx";
|
||||||
m_ambeFile = directory + "/" + language + ".nxdn";
|
m_imbeFile = directory + "/" + language + ".p25";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Approximately 10 seconds worth
|
// Approximately 10 seconds worth
|
||||||
@ -80,7 +136,7 @@ CVoice::~CVoice()
|
|||||||
|
|
||||||
m_positions.clear();
|
m_positions.clear();
|
||||||
|
|
||||||
delete[] m_ambe;
|
delete[] m_imbe;
|
||||||
delete[] m_voiceData;
|
delete[] m_voiceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,23 +149,23 @@ bool CVoice::open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct stat statStruct;
|
struct stat statStruct;
|
||||||
int ret = ::stat(m_ambeFile.c_str(), &statStruct);
|
int ret = ::stat(m_imbeFile.c_str(), &statStruct);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LogError("Unable to stat the AMBE file - %s", m_ambeFile.c_str());
|
LogError("Unable to stat the AMBE file - %s", m_imbeFile.c_str());
|
||||||
::fclose(fpindx);
|
::fclose(fpindx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* fpambe = ::fopen(m_ambeFile.c_str(), "rb");
|
FILE* fpambe = ::fopen(m_imbeFile.c_str(), "rb");
|
||||||
if (fpambe == NULL) {
|
if (fpambe == NULL) {
|
||||||
LogError("Unable to open the AMBE file - %s", m_ambeFile.c_str());
|
LogError("Unable to open the AMBE file - %s", m_imbeFile.c_str());
|
||||||
::fclose(fpindx);
|
::fclose(fpindx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ambe = new unsigned char[statStruct.st_size];
|
m_imbe = new unsigned char[statStruct.st_size];
|
||||||
|
|
||||||
size_t sizeRead = ::fread(m_ambe, 1U, statStruct.st_size, fpambe);
|
size_t sizeRead = ::fread(m_imbe, 1U, statStruct.st_size, fpimbe);
|
||||||
if (sizeRead != 0U) {
|
if (sizeRead != 0U) {
|
||||||
char buffer[80U];
|
char buffer[80U];
|
||||||
while (::fgets(buffer, 80, fpindx) != NULL) {
|
while (::fgets(buffer, 80, fpindx) != NULL) {
|
||||||
@ -119,8 +175,8 @@ bool CVoice::open()
|
|||||||
|
|
||||||
if (p1 != NULL && p2 != NULL && p3 != NULL) {
|
if (p1 != NULL && p2 != NULL && p3 != NULL) {
|
||||||
std::string symbol = std::string(p1);
|
std::string symbol = std::string(p1);
|
||||||
unsigned int start = ::atoi(p2) * AMBE_LENGTH;
|
unsigned int start = ::atoi(p2) * IMBE_LENGTH;
|
||||||
unsigned int length = ::atoi(p3) * AMBE_LENGTH;
|
unsigned int length = ::atoi(p3) * IMBE_LENGTH;
|
||||||
|
|
||||||
CPositions* pos = new CPositions;
|
CPositions* pos = new CPositions;
|
||||||
pos->m_start = start;
|
pos->m_start = start;
|
||||||
@ -132,7 +188,7 @@ bool CVoice::open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
::fclose(fpindx);
|
::fclose(fpindx);
|
||||||
::fclose(fpambe);
|
::fclose(fpimbe);
|
||||||
|
|
||||||
LogInfo("Loaded the audio and index file for %s", m_language.c_str());
|
LogInfo("Loaded the audio and index file for %s", m_language.c_str());
|
||||||
|
|
||||||
@ -168,11 +224,11 @@ void CVoice::unlinked()
|
|||||||
|
|
||||||
void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
|
void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
|
||||||
{
|
{
|
||||||
unsigned int ambeLength = 0U;
|
unsigned int imbeLength = 0U;
|
||||||
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = words.begin(); it != words.end(); ++it) {
|
||||||
if (m_positions.count(*it) > 0U) {
|
if (m_positions.count(*it) > 0U) {
|
||||||
CPositions* position = m_positions.at(*it);
|
CPositions* position = m_positions.at(*it);
|
||||||
ambeLength += position->m_length;
|
imbeLength += position->m_length;
|
||||||
} else {
|
} else {
|
||||||
LogWarning("Unable to find character/phrase \"%s\" in the index", (*it).c_str());
|
LogWarning("Unable to find character/phrase \"%s\" in the index", (*it).c_str());
|
||||||
}
|
}
|
||||||
@ -183,8 +239,8 @@ void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
|
|||||||
ambeLength++;
|
ambeLength++;
|
||||||
|
|
||||||
// Add space for silence before and after the voice
|
// Add space for silence before and after the voice
|
||||||
ambeLength += SILENCE_LENGTH * AMBE_LENGTH;
|
ambeLength += SILENCE_LENGTH * IMBE_LENGTH;
|
||||||
ambeLength += SILENCE_LENGTH * AMBE_LENGTH;
|
ambeLength += SILENCE_LENGTH * IMBE_LENGTH;
|
||||||
|
|
||||||
unsigned char* ambeData = new unsigned char[ambeLength];
|
unsigned char* ambeData = new unsigned char[ambeLength];
|
||||||
|
|
||||||
@ -221,7 +277,7 @@ void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
|
|||||||
sacch[6U] = (tg >> 0) & 0xFFU;
|
sacch[6U] = (tg >> 0) & 0xFFU;
|
||||||
|
|
||||||
unsigned int n = 0U;
|
unsigned int n = 0U;
|
||||||
for (unsigned int i = 0U; i < ambeLength; i += (2U * AMBE_LENGTH)) {
|
for (unsigned int i = 0U; i < ambeLength; i += (2U * IMBE_LENGTH)) {
|
||||||
unsigned char* p = ambeData + i;
|
unsigned char* p = ambeData + i;
|
||||||
|
|
||||||
unsigned char buffer[NXDN_FRAME_LENGTH];
|
unsigned char buffer[NXDN_FRAME_LENGTH];
|
||||||
@ -243,8 +299,8 @@ void CVoice::createVoice(unsigned int tg, const std::vector<std::string>& words)
|
|||||||
|
|
||||||
CNXDNCRC::encodeCRC6(buffer + 1U, 26U);
|
CNXDNCRC::encodeCRC6(buffer + 1U, 26U);
|
||||||
|
|
||||||
::memcpy(buffer + 5U + 0U, p + 0U, AMBE_LENGTH);
|
::memcpy(buffer + 5U + 0U, p + 0U, IMBE_LENGTH);
|
||||||
::memcpy(buffer + 5U + 14U, p + 13U, AMBE_LENGTH);
|
::memcpy(buffer + 5U + 14U, p + 13U, IMBE_LENGTH);
|
||||||
|
|
||||||
n = (n + 1U) % 4U;
|
n = (n + 1U) % 4U;
|
||||||
|
|
||||||
@ -264,7 +320,7 @@ unsigned int CVoice::read(unsigned char* data)
|
|||||||
if (m_status != VS_SENDING)
|
if (m_status != VS_SENDING)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
unsigned int count = m_stopWatch.elapsed() / NXDN_FRAME_TIME;
|
unsigned int count = m_stopWatch.elapsed() / P25_FRAME_TIME;
|
||||||
|
|
||||||
if (m_sent < count) {
|
if (m_sent < count) {
|
||||||
unsigned int offset = m_sent * NXDN_FRAME_LENGTH;
|
unsigned int offset = m_sent * NXDN_FRAME_LENGTH;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2017,2018,2019 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -56,13 +56,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::string m_language;
|
std::string m_language;
|
||||||
std::string m_indxFile;
|
std::string m_indxFile;
|
||||||
std::string m_ambeFile;
|
std::string m_imbeFile;
|
||||||
unsigned int m_srcId;
|
unsigned int m_srcId;
|
||||||
VOICE_STATUS m_status;
|
VOICE_STATUS m_status;
|
||||||
CTimer m_timer;
|
CTimer m_timer;
|
||||||
CStopWatch m_stopWatch;
|
CStopWatch m_stopWatch;
|
||||||
unsigned int m_sent;
|
unsigned int m_sent;
|
||||||
unsigned char* m_ambe;
|
unsigned char* m_imbe;
|
||||||
unsigned char* m_voiceData;
|
unsigned char* m_voiceData;
|
||||||
unsigned int m_voiceLength;
|
unsigned int m_voiceLength;
|
||||||
std::unordered_map<std::string, CPositions*> m_positions;
|
std::unordered_map<std::string, CPositions*> m_positions;
|
||||||
|
Loading…
Reference in New Issue
Block a user