mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-02-03 09:44:24 -05:00
Implement adding Tx audio noise via "TxSNR".
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2693 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
879be2044f
commit
2deccb0362
Binary file not shown.
@ -13,7 +13,6 @@ bool btxok; //True if OK to transmit
|
||||
double outputLatency; //Latency in seconds
|
||||
float c0[2*1800*1500];
|
||||
|
||||
|
||||
WideGraph* g_pWideGraph = NULL;
|
||||
|
||||
QString rev="$Rev$";
|
||||
@ -891,6 +890,11 @@ void MainWindow::guiUpdate()
|
||||
msgBox(s);
|
||||
}
|
||||
if(!soundOutThread.isRunning()) {
|
||||
QString t=ui->tx6->text();
|
||||
double snr=t.mid(1,5).toDouble();
|
||||
if(snr>0.0 or snr < -50.0) snr=99.0;
|
||||
soundOutThread.setTxSNR(snr);
|
||||
qDebug() << t << snr;
|
||||
soundOutThread.start(QThread::HighPriority);
|
||||
}
|
||||
}
|
||||
@ -1264,6 +1268,9 @@ void MainWindow::on_tx6_editingFinished() //tx6 edited
|
||||
{
|
||||
QString t=ui->tx6->text();
|
||||
msgtype(t, ui->tx6);
|
||||
double snr=t.mid(1,5).toDouble();
|
||||
if(snr>0.0 or snr < -50.0) snr=99.0;
|
||||
soundOutThread.setTxSNR(snr);
|
||||
}
|
||||
|
||||
void MainWindow::on_dxCallEntry_textChanged(const QString &t) //dxCall changed
|
||||
|
45
soundout.cpp
45
soundout.cpp
@ -12,12 +12,13 @@ extern double outputLatency;
|
||||
|
||||
typedef struct //Parameters sent to or received from callback function
|
||||
{
|
||||
int nsps;
|
||||
int ntrperiod;
|
||||
int ntxfreq;
|
||||
bool txOK;
|
||||
bool txMute;
|
||||
bool bRestart;
|
||||
double txsnrdb;
|
||||
int nsps;
|
||||
int ntrperiod;
|
||||
int ntxfreq;
|
||||
bool txOK;
|
||||
bool txMute;
|
||||
bool bRestart;
|
||||
} paUserData;
|
||||
|
||||
//--------------------------------------------------------------- d2aCallback
|
||||
@ -35,6 +36,8 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
|
||||
static double phi=0.0;
|
||||
static double dphi;
|
||||
static double freq;
|
||||
static double snr;
|
||||
static double fac;
|
||||
static int ic=0;
|
||||
static short int i2;
|
||||
|
||||
@ -44,27 +47,29 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
|
||||
int mstr = ms % (1000*udata->ntrperiod );
|
||||
if(mstr<1000) return 0;
|
||||
ic=(mstr-1000)*12;
|
||||
// qDebug() << "Start at:" << 0.001*mstr << udata->ntxfreq;
|
||||
udata->bRestart=false;
|
||||
}
|
||||
int isym=ic/udata->nsps;
|
||||
if(isym>=85) return 0;
|
||||
freq=udata->ntxfreq + itone[isym]*baud;
|
||||
dphi=twopi*freq/12000.0;
|
||||
/*
|
||||
if(ic<10000) qDebug() << "a" << ic << udata->nsps << itone[0]
|
||||
<< itone[1] << itone[2] << itone[3] << itone[4]
|
||||
<< itone[5] << itone[6] << itone[7] << itone[8]
|
||||
<< itone[9] << itone[10] << itone[11] << itone[12]
|
||||
<< itone[13] << itone[14] << itone[15] << itone[16];
|
||||
*/
|
||||
//if(ic<10000) qDebug() << ic << isym << freq << dphi << phi << i2;
|
||||
if(udata->txsnrdb < 0.0) {
|
||||
snr=pow(10.0,0.05*(udata->txsnrdb-1.0));
|
||||
fac=3000.0;
|
||||
if(snr>1.0) fac=3000.0/snr;
|
||||
}
|
||||
|
||||
for(int i=0 ; i<framesToProcess; i++ ) {
|
||||
for(uint i=0 ; i<framesToProcess; i++ ) {
|
||||
phi += dphi;
|
||||
if(phi>twopi) phi -= twopi;
|
||||
i2=32767.0*sin(phi);
|
||||
// i2 = 500.0*(i2/32767.0 + 5.0*gran()); //Add noise (tests only!)
|
||||
if(udata->txsnrdb < 0.0) {
|
||||
int i4=fac*(gran() + i2*snr/32768.0);
|
||||
if(i4>32767) i4=32767;
|
||||
if(i4<-32767) i4=-32767;
|
||||
i2=i4;
|
||||
}
|
||||
/*
|
||||
if(udata->txMute) i2=0;
|
||||
if(!udata->txOK) i2=0;
|
||||
@ -97,6 +102,7 @@ void SoundOutThread::run()
|
||||
return;
|
||||
}
|
||||
|
||||
udata.txsnrdb=99.0;
|
||||
udata.nsps=m_nsps;
|
||||
udata.ntrperiod=m_TRperiod;
|
||||
udata.ntxfreq=m_txFreq;
|
||||
@ -127,6 +133,7 @@ void SoundOutThread::run()
|
||||
qe = quitExecution;
|
||||
if (qe) break;
|
||||
|
||||
udata.txsnrdb=m_txsnrdb;
|
||||
udata.nsps=m_nsps;
|
||||
udata.ntrperiod=m_TRperiod;
|
||||
udata.ntxfreq=m_txFreq;
|
||||
@ -154,3 +161,9 @@ void SoundOutThread::setTxFreq(int n)
|
||||
{
|
||||
m_txFreq=n;
|
||||
}
|
||||
|
||||
|
||||
void SoundOutThread::setTxSNR(double snr)
|
||||
{
|
||||
m_txsnrdb=snr;
|
||||
}
|
||||
|
@ -27,16 +27,18 @@ public:
|
||||
void setOutputDevice(qint32 n);
|
||||
void setPeriod(int ntrperiod, int nsps);
|
||||
void setTxFreq(int n);
|
||||
void setTxSNR(double snr);
|
||||
bool quitExecution; //If true, thread exits gracefully
|
||||
|
||||
// Private members
|
||||
private:
|
||||
double m_txsnrdb; //if < 0, add noise to Tx audio
|
||||
qint32 m_nDevOut; //Output device number
|
||||
bool m_txOK; //Enable Tx audio
|
||||
bool m_txMute; //Mute temporarily
|
||||
qint32 m_TRperiod; //T/R period (s)
|
||||
qint32 m_nsps; //Samples per symbol (at 12000 Hz)
|
||||
qint32 m_txFreq;
|
||||
bool m_txOK; //Enable Tx audio
|
||||
bool m_txMute; //Mute temporarily
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,9 @@ Source: "c:\Users\joe\wsjt\wsjtx_install\wsjtx.exe"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\wsjt.ico"; DestDir: "{app}"
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\afmhot.dat"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\blue.dat"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\WSJT-X_Quick_Start_Guide.pdf"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\met8.21"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\CALL3.TXT"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\wsjtx\WSJT-X_Quick_Start_Guide.pdf"; DestDir: "{app}";
|
||||
Source: "c:\Users\joe\wsjt\QtSupport\*.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist
|
||||
Source: "c:\Users\joe\wsjt\wsjtx_install\save\000000_0000.wav"; DestDir: "{app}\save";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user