|
|
|
|
@ -36,6 +36,17 @@
|
|
|
|
|
#include "configure.h"
|
|
|
|
|
#include "Controller.h"
|
|
|
|
|
|
|
|
|
|
int16_t calcGainVal(float db)
|
|
|
|
|
{
|
|
|
|
|
float ratio = powf(10.0, (db/10.0));
|
|
|
|
|
|
|
|
|
|
if(db < 0){
|
|
|
|
|
ratio = (1/ratio) * (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (int16_t)roundf(ratio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern CController Controller;
|
|
|
|
|
|
|
|
|
|
CDVDevice::CDVDevice(Encoding t) : type(t), ftHandle(nullptr), buffer_depth(0), keep_running(true)
|
|
|
|
|
@ -140,7 +151,7 @@ bool CDVDevice::checkResponse(SDV_Packet &p, uint8_t response) const
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc, Edvtype dvtype)
|
|
|
|
|
bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc, Edvtype dvtype, float dbgain)
|
|
|
|
|
{
|
|
|
|
|
auto status = FT_OpenEx((PVOID)serialno.c_str(), FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);
|
|
|
|
|
if (FT_OK != status)
|
|
|
|
|
@ -149,6 +160,7 @@ bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc,
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gain = calcGainVal(dbgain);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
|
|
|
FT_Purge(ftHandle, FT_PURGE_RX | FT_PURGE_TX );
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
|
|
|
@ -593,7 +605,8 @@ void CDVDevice::FeedDevice()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SendAudio(index, packet->GetAudioSamples());
|
|
|
|
|
//SendAudio(index, packet->GetAudioSamples(), (Encoding::dstar==type) ? 4 : -4);
|
|
|
|
|
SendAudio(index, packet->GetAudioSamples(), gain);
|
|
|
|
|
}
|
|
|
|
|
buffer_depth++;
|
|
|
|
|
}
|
|
|
|
|
|