diff --git a/lib/refspectrum.f90 b/lib/refspectrum.f90
index 736d0efd3..8d0730df9 100644
--- a/lib/refspectrum.f90
+++ b/lib/refspectrum.f90
@@ -1,11 +1,11 @@
-subroutine refspectrum(id2,bclear,brefspec,buseref,fname)
+subroutine refspectrum(id2,id2b,kk,bclear,brefspec,buseref,fname)
 
 ! Input:
 !  id2       i*2        Raw 16-bit integer data, 12000 Hz sample rate
 !  brefspec  logical    True when accumulating a reference spectrum
 
   parameter (NFFT=6912,NH=NFFT/2,NPOLYLOW=400,NPOLYHIGH=2600)
-  integer*2 id2(NFFT)
+  integer*2 id2(NFFT),id2b(120*12000)
   logical*1 bclear,brefspec,buseref,blastuse
   
   real x0(0:NH-1)                         !Input samples
@@ -146,9 +146,11 @@ subroutine refspectrum(id2,bclear,brefspec,buseref,fname)
      cx=fil*cx
      call four2a(cx,NFFT,1,1,-1)           !c2r FFT (back to time domain)
      x1=x1s + x(0:NH-1)                    !Add previous segment's 2nd half
-     id2(1:NH)=nint(x1)
+!     id2(1:NH)=nint(x1)
+     if(kk.ge.6912) id2b(kk-6192+1:kk-6192+NH)=nint(x1)
      x1s=x(NH:NFFT-1)                      !Save the new 2nd half
   endif
   blastuse=buseref
+  
   return
 end subroutine refspectrum
diff --git a/mainwindow.cpp b/mainwindow.cpp
index b40f6b87a..85f92f536 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -124,8 +124,8 @@ extern "C" {
 
   void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2);
 
-  void refspectrum_(short int d2[], bool* bclearrefspec, bool* brefspec,
-                    bool* buseref, const char* c_fname, int len);
+  void refspectrum_(short int d2[], short int d2b[], int* k, bool* bclearrefspec,
+                    bool* brefspec, bool* buseref, const char* c_fname, int len);
 
   void freqcal_(short d2[], int* k, int* nkhz,int* noffset, int* ntol,
                 char line[], int len);
@@ -1148,7 +1148,7 @@ void MainWindow::dataSink(qint64 frames)
   }
 
   m_bUseRef=m_wideGraph->useRef();
-  refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec,
+  refspectrum_(&dec_data.d2[k-m_nsps/2],&dec_data.d2[0],&k,&m_bClearRefSpec,&m_bRefSpec,
       &m_bUseRef,c_fname,len);
   m_bClearRefSpec=false;