mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-08 00:44:39 -04:00
Changed soundin to i*2 rather than r*4.
Activated saving of WAV files. (but so far, without headers). Tx waveform now uses sinc() pulses. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2489 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
+14
-51
@@ -8,76 +8,39 @@ extern qint16 id[4*60*96000];
|
||||
|
||||
void getfile(QString fname, bool xpol, int dbDgrd)
|
||||
{
|
||||
int npts=2*52*96000;
|
||||
if(xpol) npts=2*npts;
|
||||
|
||||
// Degrade S/N by dbDgrd dB -- for tests only!!
|
||||
float dgrd=0.0;
|
||||
if(dbDgrd<0) dgrd = 23.0*sqrt(pow(10.0,-0.1*(double)dbDgrd) - 1.0);
|
||||
float fac=23.0/sqrt(dgrd*dgrd + 23.0*23.0);
|
||||
|
||||
memset(id,0,2*npts);
|
||||
char name[80];
|
||||
strcpy(name,fname.toAscii());
|
||||
FILE* fp=fopen(name,"rb");
|
||||
|
||||
int npts=30*48000;
|
||||
memset(datcom_.d2,0,2*npts);
|
||||
|
||||
if(fp != NULL) {
|
||||
// fread(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp);
|
||||
fread(id,2,npts,fp);
|
||||
int j=0;
|
||||
|
||||
if(dbDgrd<0) {
|
||||
for(int i=0; i<npts; i+=2) {
|
||||
datcom_.d4[j++]=fac*((float)id[i] + dgrd*gran());
|
||||
datcom_.d4[j++]=fac*((float)id[i+1] + dgrd*gran());
|
||||
if(!xpol) j+=2; //Skip over d4(3,x) and d4(4,x)
|
||||
}
|
||||
} else {
|
||||
for(int i=0; i<npts; i+=2) {
|
||||
datcom_.d4[j++]=(float)id[i];
|
||||
datcom_.d4[j++]=(float)id[i+1];
|
||||
if(!xpol) j+=2; //Skip over d4(3,x) and d4(4,x)
|
||||
}
|
||||
}
|
||||
// Should read WAV header first
|
||||
fread(datcom_.d2,2,npts,fp);
|
||||
fclose(fp);
|
||||
|
||||
/*
|
||||
datcom_.ndiskdat=1;
|
||||
int nfreq=(int)datcom_.fcenter;
|
||||
if(nfreq!=144 and nfreq != 432 and nfreq != 1296) datcom_.fcenter=144.125;
|
||||
int i0=fname.indexOf(".tf2");
|
||||
if(i0<0) i0=fname.indexOf(".iq");
|
||||
datcom_.nutc=0;
|
||||
if(i0>0) datcom_.nutc=100*fname.mid(i0-4,2).toInt() +
|
||||
fname.mid(i0-2,2).toInt();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void savewav(QString fname)
|
||||
{
|
||||
/*
|
||||
int npts=2*52*96000;
|
||||
if(xpol) npts=2*npts;
|
||||
|
||||
qint16* buf=(qint16*)malloc(2*npts);
|
||||
int npts=30*48000;
|
||||
// qint16* buf=(qint16*)malloc(2*npts);
|
||||
char name[80];
|
||||
strcpy(name,fname.toAscii());
|
||||
FILE* fp=fopen(name,"wb");
|
||||
|
||||
if(fp != NULL) {
|
||||
fwrite(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp);
|
||||
int j=0;
|
||||
for(int i=0; i<npts; i+=2) {
|
||||
buf[i]=(qint16)datcom_.d4[j++];
|
||||
buf[i+1]=(qint16)datcom_.d4[j++];
|
||||
if(!xpol) j+=2; //Skip over d4(3,x) and d4(4,x)
|
||||
}
|
||||
fwrite(buf,2,npts,fp);
|
||||
// Write a WAV header
|
||||
// fwrite(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp);
|
||||
|
||||
// memcpy(datcom_.d2,buf,2*npts);
|
||||
// fwrite(buf,2,npts,fp);
|
||||
fwrite(datcom_.d2,2,npts,fp);
|
||||
fclose(fp);
|
||||
}
|
||||
free(buf);
|
||||
*/
|
||||
// free(buf);
|
||||
}
|
||||
|
||||
//#define MAX_RANDOM 0x7fffffff
|
||||
|
||||
Reference in New Issue
Block a user