diff --git a/Modulator.cpp b/Modulator.cpp index 9155e5886..5775926ea 100644 --- a/Modulator.cpp +++ b/Modulator.cpp @@ -5,6 +5,7 @@ #include #include "mainwindow.h" #include "soundout.h" +#include "commons.h" #include "moc_Modulator.cpp" @@ -86,7 +87,8 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol, if(m_bFastMode) m_ic=0; m_silentFrames = 0; - // calculate number of silent frames to send + // calculate number of silent frames to send, so that audio will start at + // the nominal time "delay_ms" into the Tx sequence. if (synchronize && !m_tuning && !m_bFastMode) { m_silentFrames = m_ic + m_frameRate / (1000 / delay_ms) - (mstr * (m_frameRate / 1000)); } @@ -168,6 +170,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize) case Active: { unsigned int isym=0; +// qDebug() << "Mod A" << m_toneSpacing << m_ic; if(!m_tuning) isym=m_ic/(4.0*m_nsps); // Actual fsample=48000 bool slowCwId=((isym >= m_symbolsLength) && (icw[0] > 0)) && (!m_bFastMode); if(m_TRperiod==3) slowCwId=false; @@ -248,7 +251,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize) i0=i1-816; } - + qint16 sample; for (unsigned i = 0; i < numFrames && m_ic <= i1; ++i) { isym=0; if(!m_tuning and m_TRperiod!=3) isym=m_ic / (4.0 * m_nsps); //Actual @@ -264,7 +267,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize) m_toneFrequency0=m_frequency + itone[isym]*m_toneSpacing; } } -// qDebug() << "B" << m_bFastMode << m_ic << numFrames << isym << itone[isym] +// qDebug() << "Mod B" << m_bFastMode << m_ic << numFrames << isym << itone[isym] // << m_toneFrequency0 << m_nsps; m_dphi = m_twoPi * m_toneFrequency0 / m_frameRate; m_isym0 = isym; @@ -285,7 +288,12 @@ qint64 Modulator::readData (char * data, qint64 maxSize) if (m_ic > i0) m_amp = 0.98 * m_amp; if (m_ic > i1) m_amp = 0.0; - samples = load (postProcessSample (m_amp * qSin (m_phi)), samples); + sample=qRound(m_amp*qSin(m_phi)); + if(m_toneSpacing < 0) sample=qRound(m_amp*foxcom_.wave[m_ic]); + +// if(m_ic < 100) qDebug() << "Mod C" << m_ic << m_amp << foxcom_.wave[m_ic] << sample; + + samples = load(postProcessSample(sample), samples); ++framesGenerated; ++m_ic; } diff --git a/commons.h b/commons.h index c07ee2596..d0eef792a 100644 --- a/commons.h +++ b/commons.h @@ -79,6 +79,10 @@ extern struct { float red[4096]; } echocom_; +extern struct { + float wave[606720]; +} foxcom_; + #ifdef __cplusplus } #endif diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90 index f1971a6b5..22a4cfdb0 100644 --- a/lib/ft8/foxgen.f90 +++ b/lib/ft8/foxgen.f90 @@ -14,6 +14,7 @@ subroutine foxgen(t) real x(NFFT),y(NFFT) real*8 dt,twopi,f0,fstep,dfreq,phi,dphi complex cx(0:NH),cy(0:NH) + common/foxcom/wave equivalence (x,cx),(y,cy) call system_clock(count0,clkfreq) @@ -67,10 +68,14 @@ subroutine foxgen(t) call system_clock(count1,clkfreq) time=float(count1-count0)/float(clkfreq) !Cumulative execution time -! write(*,3001) n,k,time,msgsent -!3001 format(i1,i8,f10.6,2x,a22) + write(*,3001) n,k,i,time,msgsent +3001 format(i1,i8,i4,f10.6,2x,a22) + if(i.ge.m) exit enddo + fac=1.0/maxval(abs(wave)) + wave=fac*wave + x(1:k)=wave x(k+1:)=0. call four2a(x,nfft,1,-1,0) @@ -88,11 +93,11 @@ subroutine foxgen(t) ! sy=sy + real(cy(k))**2 + aimag(cy(k))**2 enddo freq=df*(k-nadd/2+0.5) -! write(29,1022) freq,sx,sy,db(sx)-90.0,db(sy)-90.0 -!1022 format(f10.3,2e12.3,2f10.3) + write(29,1022) freq,sx,sy,db(sx)-90.0,db(sy)-90.0 +1022 format(f10.3,2e12.3,2f10.3) if(freq.gt.3000.0) exit enddo -! flush(29) + flush(29) call system_clock(count1,clkfreq) time=float(count1-count0)/float(clkfreq) !Cumulative execution time diff --git a/mainwindow.cpp b/mainwindow.cpp index 35c3ad4ad..0b4187366 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3326,11 +3326,10 @@ void MainWindow::guiUpdate() if(m_config.bFox()) { QString t=ui->textBrowser3->toPlainText(); int len=t.length(); - qint64 ms0=QDateTime::currentMSecsSinceEpoch(); +// qint64 ms0=QDateTime::currentMSecsSinceEpoch(); foxgen_(const_cast (t.toLatin1().constData()),len); - qint64 ms=QDateTime::currentMSecsSinceEpoch(); - qDebug() << "aa" << m_Nslots << ms-ms0 << t; - +// qint64 ms=QDateTime::currentMSecsSinceEpoch(); +// qDebug() << "aa" << m_Nslots << ms-ms0 << t; } else { genft8_(message, MyGrid, &bcontest, &m_i3bit, msgsent, const_cast (ft8msgbits), const_cast (itone), 22, 6, 22); @@ -6001,6 +6000,7 @@ void MainWindow::transmit (double snr) if (m_modeTx == "FT8") { toneSpacing=12000.0/1920.0; if(m_config.x2ToneSpacing()) toneSpacing=2*12000.0/1920.0; + if(m_config.bFox()) toneSpacing=-1; Q_EMIT sendMessage (NUM_FT8_SYMBOLS, 1920.0, ui->TxFreqSpinBox->value () - m_XIT, toneSpacing, m_soundOutput, m_config.audio_output_channel (),