[hamradio-commits] [linpsk] 01/06: New upstream version 1.3.5

Iain R. Learmonth irl at moszumanska.debian.org
Tue Jul 18 16:35:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

irl pushed a commit to branch master
in repository linpsk.

commit 813206ebf63772923e21bae00a103baeb30bcb6f
Author: Iain R. Learmonth <irl at debian.org>
Date:   Tue Jul 18 15:00:52 2017 +0100

    New upstream version 1.3.5
---
 .gitignore                                        |   2 +-
 ChangeLog                                         |  14 +
 README                                            |  31 +-
 gui/addmacro.cpp                                  |   4 +-
 gui/addmacro.h                                    |   2 +-
 gui/addrxwindow.cpp                               |  18 +-
 gui/addrxwindow.h                                 |   3 +-
 gui/controlpanel.cpp                              |   4 +
 gui/controlpanel.h                                |   1 +
 gui/crxdisplay.cpp                                | 108 +--
 gui/crxdisplay.h                                  | 101 ++-
 gui/definebandlist.cpp                            | 170 ++++
 gui/{addmacro.h => definebandlist.h}              |  36 +-
 gui/definebandlist.ui                             | 241 ++++++
 gui/deletemacro.cpp                               |   6 +-
 gui/deletemacro.h                                 |   4 +-
 gui/editmacro.cpp                                 |   6 +-
 gui/editmacro.h                                   |   4 +-
 gui/generalsettings.cpp                           | 128 ++-
 gui/generalsettings.h                             |  11 +-
 gui/generalsettings.ui                            | 527 ++++++++-----
 gui/linpsk.cpp                                    | 347 +++++---
 gui/linpsk.h                                      |  22 +-
 gui/linpsk.ui                                     |  23 +-
 gui/modemenu.cpp                                  |  10 +-
 gui/modemenu.h                                    |  12 +-
 gui/qsodata.cpp                                   |  87 +-
 gui/qsodata.h                                     |   8 +
 gui/qsodata.ui                                    |  76 +-
 gui/renamemacro.cpp                               |   7 +-
 gui/renamemacro.h                                 |   5 +-
 gui/spectrumdisplay.cpp                           |  79 +-
 gui/spectrumdisplay.h                             |   3 +-
 gui/spectrumdisplay.ui                            |  19 +-
 linpsk.pro                                        |  49 +-
 src/bpskdemodulator.cpp                           |  50 +-
 src/bpskdemodulator.h                             |  17 +-
 src/bpskmodulator.cpp                             | 109 ++-
 src/bpskmodulator.h                               |  38 +-
 src/cdemodulator.cpp                              |  22 +-
 src/cdemodulator.h                                |   9 +-
 src/cmodulator.cpp                                |   2 +-
 src/cmodulator.h                                  |  20 +-
 src/constants.h                                   |  17 +-
 src/cpskdemodulator.cpp                           | 440 +++--------
 src/cpskdemodulator.h                             |  86 +-
 src/crxchannel.cpp                                |  48 +-
 src/crxchannel.h                                  |   2 +-
 src/crxwindow.cpp                                 |  40 +-
 src/crxwindow.h                                   |  10 +-
 src/csound.cpp                                    |  21 +-
 src/ctxbuffer.cpp                                 | 162 ++--
 src/firfilter.cpp                                 |  57 +-
 src/firfilter.h                                   |   4 +-
 src/frequencyselect.cpp                           |   4 +-
 src/fskmodulator.h                                |  15 +-
 src/mfskdemodulator.cpp                           |   4 +-
 src/mfskdemodulator.h                             |   2 +-
 src/mfskmodulator.cpp                             | 166 ++--
 src/parameter.cpp                                 |  15 +-
 src/parameter.h                                   |  16 +-
 src/processlogdata.cpp                            |  32 +-
 src/processlogdata.h                              |  10 +-
 src/{bpskdemodulator.cpp => psk63demodulator.cpp} |  64 +-
 src/{bpskdemodulator.h => psk63demodulator.h}     |  31 +-
 gui/addrxwindow.cpp => src/psk63modulator.cpp     |  78 +-
 gui/addrxwindow.h => src/psk63modulator.h         |  34 +-
 src/pskmodulator.cpp                              | 914 ++++++++--------------
 src/pskmodulator.h                                | 173 ++--
 src/psktable.h                                    | 120 ---
 src/qpskdemodulator.cpp                           |  47 +-
 src/qpskdemodulator.h                             |  26 +-
 src/qpskmodulator.cpp                             | 116 ++-
 src/qpskmodulator.h                               |   4 +-
 src/rigcontrol.cpp                                | 126 +++
 gui/addmacro.h => src/rigcontrol.h                |  48 +-
 src/rttydemodulator.cpp                           |   5 +-
 src/rttydemodulator.h                             |   2 +-
 src/rttymodulator.cpp                             | 792 ++++++++++---------
 src/spectrumwindow.cpp                            |  11 +-
 src/spectrumwindow.h                              |   3 +
 81 files changed, 3203 insertions(+), 2977 deletions(-)

diff --git a/.gitignore b/.gitignore
index 119ba90..fc307a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
-build
+build*
 linpsk.pro.user
diff --git a/ChangeLog b/ChangeLog
index 76c54db..3971021 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,18 @@
 LinPsk ChangeLog
+1.3.5
+Adding PSK63 mode
+Fixing wrong scaling in Spectrum display
+
+1.3.1
+Building with qt4 or qt5 depending on qmake.
+If qmake detects hamlib, LinPSK will be build with hamlib support.
+Now you can define bands and a preferred frequency to use.
+On startup the frequency and the tx-power setting is read from the tx and inserted in the qso tab.
+Changing the entry in the tab will will change the tx - settings.
+
+You have to setup the communication parameter in the general settings menu.
+
+Removing textfile input for demo mode. Only wav files are supported in the future.
 1.2.5
 Now building in build directory.
 Switching to qt5.
diff --git a/README b/README
index fc8c3e2..757e665 100644
--- a/README
+++ b/README
@@ -1,24 +1,33 @@
-Important: This version uses qt5 !!!
+Important: This versionan be build with qt4 or qt5!!!
+Which version of qt is used depends on the qmake version.
 
-To build linpsk, untar the tar archiv and switch to the linpsk directory.
+For those who use LinPSK on a PI in a headless environment:
+   Due to a bug in tightvnc build LinPSK against qt4, otherwise you'll get garbeld text in LinPSK transmit box or
+   in the qso fields !!!!
+
+To build LinPsk, untar the tar archiv and switch to the linpsk directory.
+You need fftw3.
+Now you can define a list of bands, which is used in the setup of the qso data.
+If you select a band and LinPSK is build with hamlib support your rig is tuned to the preferred frequency of this band.
+
+LinPSK is build with hamlib support, if qmake finds the hamlib library (by pkg-config).
+Additionaly you can control the Tx power by the qsodata settings, if your rig supports this feature.
+
+Band name and Tx power can be used to log with LinLogbook.
 
 run:
 mkdir -p build
 cd build
 qmake -o Makefile ../linpsk.pro
 make
+sudo make install
 
-The executable linpsk is build in the build  directory.
-
-make install 
+This will install the binary into usr/local/bin and the desktop file into /usr/share/pixmaps/ and the icon file into /usr/share/pixmaps/ .
 
-will install the binary into usr/local/bin and the desktop file into /usr/share/pixmaps/ and the icon file into /usr/share/pixmaps/ .
+As LinPSK uses the alsa sound system, you can use valid alsa devices like plughw:1 in the settings dialog
+Also using the card name can be used now. In this case LinPSK searches the cardnumber and opens
 
-LinPSK uses the alsa sound system.
-You can use valid alsa devices like plughw:1 in the settings dialog
-Also using the card name is possible. In this case LinPSK searches the cardnumber and opens
 plughw:[cardnumber]
 
-If you prefer to use LinPSK_Record and LinPSK_Play as in previous versions edit the file asoundrc in the linpsk directory appropriately and append it to .asoundrc in your homedirectory.
-If no .asoundrc exists copy the edited asoundrc to .asoundrc in your homedirectory instead of appending.
+In case of problems you can define ( more complex ) devices in your .asoundrc file. The should be named LinPSK_Record and LinPSK_Play.
 
diff --git a/gui/addmacro.cpp b/gui/addmacro.cpp
index 07cde00..fd9c6d7 100644
--- a/gui/addmacro.cpp
+++ b/gui/addmacro.cpp
@@ -25,8 +25,8 @@
 #include <QMessageBox>
 #include <QButtonGroup>
 
-AddMacro::AddMacro(QVector<Macro> *macroList,QStringList tokenList, QWidget* parent, Qt::WindowFlags fl)
-: QDialog( parent, fl ),  ui(new Ui::AddMacro)
+AddMacro::AddMacro(QVector<Macro> *macroList,QStringList tokenList, QWidget* parent)
+: QDialog( parent),  ui(new Ui::AddMacro)
 {
   ui->setupUi(this);
   ui->bG->setId(ui->lang0,0);
diff --git a/gui/addmacro.h b/gui/addmacro.h
index c82a42d..d43eccd 100644
--- a/gui/addmacro.h
+++ b/gui/addmacro.h
@@ -35,7 +35,7 @@ class AddMacro : public QDialog
   Q_OBJECT
 
 public:
-  AddMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  AddMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0);
   ~AddMacro();
 
 public slots:
diff --git a/gui/addrxwindow.cpp b/gui/addrxwindow.cpp
index 0f91fc8..e454cb0 100644
--- a/gui/addrxwindow.cpp
+++ b/gui/addrxwindow.cpp
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by volker, DL1KSV   *
- *   schroer at tux64   *
+ *   Copyright (C) 2007 - 2016 by Volker Schroer , DL1KSV                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -24,16 +23,13 @@
 
 extern Parameter settings;
 
-AddRxWindow::AddRxWindow(QWidget* parent, Qt::WindowFlags fl)
-: QDialog( parent, fl ), Ui::AddRxWindow()
+AddRxWindow::AddRxWindow(QStringList modeList, QWidget* parent)
+: QDialog( parent ), Ui::AddRxWindow()
 {
-	setupUi(this);
-RxMode->insertItem(0,"BPSK");
-RxMode->insertItem(1,"QPSK");
-RxMode->insertItem(2,"RTTY");
-RxMode->insertItem(3,"MFSK16");
-RxMode->setCurrentRow(0);
-TitleText->setText("Rx " + QString().setNum(settings.RxChannels+1));
+  setupUi(this);
+  RxMode->addItems(modeList);
+  RxMode->setCurrentRow(0);
+  TitleText->setText("Rx " + QString().setNum(settings.RxChannels+1));
 
 }
 
diff --git a/gui/addrxwindow.h b/gui/addrxwindow.h
index 051c7ab..083aa35 100644
--- a/gui/addrxwindow.h
+++ b/gui/addrxwindow.h
@@ -22,6 +22,7 @@
 #define ADDRXWINDOW_H
 
 #include <QDialog>
+#include <QStringList>
 #include "ui_addrxwindow.h"
 #include "constants.h"
 
@@ -30,7 +31,7 @@ class AddRxWindow : public QDialog, private Ui::AddRxWindow
   Q_OBJECT
 
 public:
-  AddRxWindow(QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  AddRxWindow(QStringList modeList,QWidget* parent = 0);
   ~AddRxWindow();
 Mode selectedMode();
 QString titleText();
diff --git a/gui/controlpanel.cpp b/gui/controlpanel.cpp
index 3f64656..355521f 100644
--- a/gui/controlpanel.cpp
+++ b/gui/controlpanel.cpp
@@ -96,3 +96,7 @@ QByteArray ControlPanel::spectrumSplitterState() const
 {
   return Display->spectrumSplitterState();
 }
+void ControlPanel::initQsoData()
+{
+  QSO->initQsoData();
+}
diff --git a/gui/controlpanel.h b/gui/controlpanel.h
index 718cd9d..8084127 100644
--- a/gui/controlpanel.h
+++ b/gui/controlpanel.h
@@ -27,6 +27,7 @@ public:
     void insertMacros(QVector<Macro> *macroList);
     void enableSaveData();
     void setAutoDate();
+    void initQsoData();
     void restoreSplitterStates(const QByteArray & controlState,const QByteArray & spectrumState);
     QByteArray controlSplitterState() const;
     QByteArray spectrumSplitterState() const;
diff --git a/gui/crxdisplay.cpp b/gui/crxdisplay.cpp
index 5cc94c4..704207d 100644
--- a/gui/crxdisplay.cpp
+++ b/gui/crxdisplay.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          |FILENAME|  -  description
-                             -------------------
-    begin                : |DATE|
-    copyright            : (C) |YEAR| by |AUTHOR|
-    email                : |EMAIL|
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -31,11 +23,6 @@
 #include "parameter.h"
 
 extern Parameter settings;
-/*
- *  Constructs a CRxDisplay which is a child of 'parent', with the
- *  name 'name'.'
- */
-
 
 
 CRxDisplay::CRxDisplay ( QWidget* parent )
@@ -45,8 +32,6 @@ CRxDisplay::CRxDisplay ( QWidget* parent )
 
   Sound = 0;
 
-  dec2fir = new double[DEC2_LPFIR_LENGTH];
-
   RxChannel = new CRxChannel ( 0, this );
   RxHeader->insertTab ( 0, RxChannel->getWindow(),QString("Rx 1") );
   RxFreq->setFunctionText("Narrow");
@@ -64,7 +49,7 @@ CRxDisplay::CRxDisplay ( QWidget* parent )
   Squelch->setSquelchState ( RxChannel->getSquelchState() );
 
 // Creating Variables for the fft
-  plan = fftw_plan_r2r_1d ( BUF_SIZE / 2, outbuf, output, FFTW_R2HC , FFTW_PATIENT );
+    plan = fftw_plan_r2r_1d ( BUF_SIZE , outbuf, output, FFTW_R2HC , FFTW_PATIENT );
 }
 
 /*
@@ -90,12 +75,7 @@ bool CRxDisplay::start_process_loop()
   if ( Sound == 0 )
   {
     if ( settings.DemoMode )
-    {
-      if ( settings.DemoTypeNumber == 0 )
         Sound = new WaveInput ( -1 );
-      else
-        Sound = new TextInput ( -1 );
-    }
     else
       Sound = new CSound ( settings.serial );
     if ( Sound <= NULL )
@@ -103,10 +83,6 @@ bool CRxDisplay::start_process_loop()
 
     connect ( Sound, SIGNAL ( samplesAvailable() ), this, SLOT ( process_rxdata() ) );
   }
-  m_pDec2InPtr = dec2fir;
-
-  for ( int i = 0; i < DEC2_LPFIR_LENGTH;i++ )
-    dec2fir[i] = 0.0; // fill delay buffer with zero
 
   if ( ! Sound->open_Device_read ( &errorstring ) )  //Something went wrong in Opening Input File
   {
@@ -123,46 +99,6 @@ bool CRxDisplay::start_process_loop()
   return true;
 }
 
-void CRxDisplay::ProcDec2Fir ( double *pIn, double *pOut, int BlockSize )
-{
-  /**
-  Decimate by 2 FIR filter on 'BlockSize' samples.
-  pIn == pointer to input array of double's (can be same buffer as pOut )
-  pOut == pointer to output array of double's
-  Blocksize == number of samples to process
-  This Procdeure is taken from WinPSK by Moe Wheatley
-  **/
-  int i, j;
-  double acc;
-  const double* Kptr;
-  double* Firptr;
-  double* Qptr;
-  double* Inptr;
-  Inptr = m_pDec2InPtr; //use automatic copies of member variables
-  Qptr =  dec2fir;   // for better speed.
-  j = 0;
-  for ( i = 0; i < BlockSize; i++ ) // put new samples into Queue
-  {
-    if ( --Inptr < Qptr ) //deal with wraparound
-      Inptr = Qptr + DEC2_LPFIR_LENGTH - 1;
-    *Inptr = pIn[i];
-    if ( i&1 ) //calculate MAC's every other time for decimation by 2
-    {
-      acc = 0.0;
-      Firptr = Inptr;
-      Kptr = Dec2LPCoef;
-      while ( Kptr < ( Dec2LPCoef + DEC2_LPFIR_LENGTH ) ) //do the MAC's
-      {
-        acc += ( ( *Firptr++ ) * ( *Kptr++ ) );
-        if ( Firptr >= Qptr + DEC2_LPFIR_LENGTH ) //deal with wraparound
-          Firptr = Qptr;
-      }
-      pOut[j++] = acc;  //save output sample
-    }
-  }
-  m_pDec2InPtr = Inptr;  // save position in circular delay line
-}
-
 void CRxDisplay::process_rxdata()
 
 {
@@ -171,48 +107,37 @@ void CRxDisplay::process_rxdata()
   if ( Sound->getSamples ( inbuf, BUF_SIZE ) == 0 )
     return; // No sample available, try later
   overload = false;
-  ProcDec2Fir ( inbuf, outbuf , BUF_SIZE ); // 2uS per sample
-
-
   RxFreq->setFrequency ( settings.ActChannel->getRxFrequency() );
   Squelch->setSquelchLevel ( settings.ActChannel->getSquelchValue() );
   settings.ActChannel->setThreshold ( Squelch->getThreshold() );
   settings.ActChannel->setSquelch ( Squelch->getSquelchState() );
   settings.ActChannel->setAfcMode ( RxFreq->getAfcMode() );
 
-  for ( CRxChannel * p = RxChannel;p != 0;p = p->getNextChannel() )
-  {
-    modtype=p->getModulationType();
-    if ( ( modtype != RTTY ) && ( modtype != MFSK16 ) /* RIP && (modtype != RTTY2) */ )
-    {
-
-      p->processInput ( outbuf, output );
-    }
-    else
-      p->processInput ( inbuf, output );
-  }
-  /** Update RxFreq for the active Channel **/
-  emit new_IMD ( settings.ActChannel->getIMD() );
-
-
 // Calculate FFT and start Ploting
 
-// First  look for overload
-  int N = BUF_SIZE / 2;
-  for ( int i = 0; i < N;i++ )
+    for ( int i = 0; i < BUF_SIZE;i++ )
   {
+// First  look for overload
     if ( inbuf[i] > 0.9 )
         overload = true;
 // Apply Hamming to Data
-    outbuf[i] *= ( 0.54 - 0.46 * cos ( ( i * PI2 ) / N ) );
+    outbuf[i] = inbuf[i]*( 0.54 - 0.46 * cos ( ( i * PI2 ) / BUF_SIZE ) );
   }
   fftw_execute ( plan );
 
 //Calculate power spectrum
-  for ( int i = 1;i < BUF_SIZE / 4;i++ )
-    output[i] = output[i] * output[i] + output[BUF_SIZE/2-i] * output[BUF_SIZE/2-i];
+  for ( int i = 1;i < BUF_SIZE / 2;i++ )
+//    output[i] = output[i] * output[i] + output[BUF_SIZE-i] * output[BUF_SIZE-i];
+  outbuf[i] = output[i] * output[i] + output[BUF_SIZE-i] * output[BUF_SIZE-i];
+
+  emit startPlotting ( outbuf, overload );
+  for ( CRxChannel * p = RxChannel;p != 0;p = p->getNextChannel() )
+  {
+      p->processInput ( inbuf, outbuf );
+  }
+  /** Update IMD for the active Channel **/
+  emit new_IMD ( settings.ActChannel->getIMD() );
 
-  emit startPlotting ( output, overload );
 
 
 }
@@ -270,13 +195,10 @@ void CRxDisplay::stop_process_loop()
 {
   if ( Sound != 0 )
   {
-    disconnect(Sound,0,0,0);
     Sound->stop();
     Sound->wait();
     Sound->close_Device();
-    delete Sound;
   }
-  Sound = 0 ;
 }
 void CRxDisplay::trigger()
 {
diff --git a/gui/crxdisplay.h b/gui/crxdisplay.h
index 03da03f..3087ca1 100644
--- a/gui/crxdisplay.h
+++ b/gui/crxdisplay.h
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          |FILENAME|  -  description
-                             -------------------
-    begin                : |DATE|
-    copyright            : (C) |YEAR| by |AUTHOR|
-    email                : |EMAIL|
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -34,57 +26,58 @@ class CRxDisplay : public QFrame , private Ui::CRxDisplay
 {
   Q_OBJECT
 
-  public:
-		CRxDisplay ( QWidget* parent = 0 );
-		~CRxDisplay();
-		/** Returns the pointer to the values for Calculating the Spectrum **/
-		double * FFTValues();
-		bool start_process_loop();
-		void stop_process_loop();
-		void newColor();
-        void setColorList ( QList<QColor> *c );
-        AfcMode getAfcMode();
-        void stopRecording();
-  public slots:
-		/** Starting receiving/transmitting */
-		void addRxWindow ( int Frequency, Mode Modulation, QString Heading );
-		void setRxFrequency ( double );
-        void setAfc(AfcMode mode);
-        void setAfcProperties(AfcMode mode);
+public:
+  CRxDisplay ( QWidget* parent = 0 );
+  ~CRxDisplay();
+  /** Returns the pointer to the values for Calculating the Spectrum **/
+  double * FFTValues();
+  bool start_process_loop();
+  void stop_process_loop();
+  void newColor();
+  void setColorList ( QList<QColor> *c );
+  AfcMode getAfcMode();
+  void stopRecording();
+public slots:
+  /** Starting receiving/transmitting */
+  void addRxWindow ( int Frequency, Mode Modulation, QString Heading );
+  void setRxFrequency ( double );
+  void setAfc(AfcMode mode);
+  void setAfcProperties(AfcMode mode);
 
-  protected:
+protected:
 
-  protected slots:
-		virtual void languageChange();
-		void process_rxdata();
-		void changeActiveRxWindow ( int );
-        void trigger();
-		void clearRxWindow();
-        void record(bool);
-  private:
-    QList<QColor> *Farbe;
-		/**
-		Sound is a pointer to the Input Source, may be a File with
+protected slots:
+  virtual void languageChange();
+  void process_rxdata();
+  void changeActiveRxWindow ( int );
+  void trigger();
+  void clearRxWindow();
+  void record(bool);
+private:
+  QList<QColor> *Farbe;
+  /**
+                Sound is a pointer to the Input Source, may be a File with
         Demo Samples (text or wav), or the soundcard
-		**/
-        Input *Sound;
-	/** Pointer to input Buffer **/
-	double inbuf[BUF_SIZE];
-	CRxChannel *RxChannel;
-	/** Decimation Filter to reduce samplerate */
-	void ProcDec2Fir ( double *pIn, double *pOut, int BlockSize );
-	double *dec2fir; // queue for decimation by 2 filter
-	double outbuf[BUF_SIZE];
-	double *m_pDec2InPtr;
-	double output[BUF_SIZE/2];
-	fftw_plan plan;
+                **/
+  Input *Sound;
+  /** Pointer to input Buffer **/
+  double inbuf[BUF_SIZE];
+  CRxChannel *RxChannel;
+  /** Decimation Filter to reduce samplerate */
+//  void ProcDec2Fir ( double *pIn, double *pOut, int BlockSize );
+//  double *dec2fir; // queue for decimation by 2 filter
+  double outbuf[BUF_SIZE];
+//  double *m_pDec2InPtr;
+//  double output[BUF_SIZE/2];
+  double output[BUF_SIZE];
+  fftw_plan plan;
 
-	signals:
+signals:
 
-      void startPlotting ( double *, bool );
-      void newActiveChannel();
-      void new_IMD ( float );
-      void setQsoData(QsoData,QString);
+  void startPlotting ( double *, bool );
+  void newActiveChannel();
+  void new_IMD ( float );
+  void setQsoData(QsoData,QString);
 
 };
 
diff --git a/gui/definebandlist.cpp b/gui/definebandlist.cpp
new file mode 100644
index 0000000..bc584af
--- /dev/null
+++ b/gui/definebandlist.cpp
@@ -0,0 +1,170 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "definebandlist.h"
+#include "ui_definebandlist.h"
+#include "parameter.h"
+#include <QLineEdit>
+
+extern Parameter settings;
+
+DefineBandList::DefineBandList(QWidget *parent) :
+  QDialog(parent),
+  ui(new Ui::DefineBandList)
+{
+  int rows;
+  int i,j;
+  ui->setupUi(this);
+
+  rows = settings.bandList.size();
+  for(i=0; i < rows; i++)
+  {
+   ui->bandDefinitions->insertRow(i);
+//   if(i < (rows-1))
+     ui->bandDefinitions->setItem(i,0,new QTableWidgetItem(settings.bandList.at(i).bandName));
+   for(j=1; j < 4; j++)
+     {
+       QLineEdit *line =new QLineEdit;
+       line->setAlignment(Qt::AlignRight);
+       line->setInputMask("00000000000D");
+       ui->bandDefinitions->setCellWidget(i,j,line);
+ //      if(i < (rows-1) )
+ //        {
+           if (j == 1 )
+             line->setText(QString("%1").arg(settings.bandList.at(i).bandStart));
+           else if ( j == 2 )
+              line->setText(QString("%1").arg(settings.bandList.at(i).bandEnd));
+           else line->setText(QString("%1").arg(settings.bandList.at(i).preferedFreq));
+ //        }
+
+     }
+  }
+  ui->bandDefinitions->setCurrentCell(rows-1,0);
+  ui->bandDefinitions->setFocus();
+  ui->bandDefinitions->resizeColumnsToContents();
+
+}
+
+DefineBandList::~DefineBandList()
+{
+  delete ui;
+}
+void DefineBandList::accept()
+{
+
+ QLineEdit *lE;
+
+ settings.bandList.clear();
+
+ for(int i=0; i < ui->bandDefinitions->rowCount(); i++)
+   {
+     Band b;
+     QTableWidgetItem *it=ui->bandDefinitions->item(i,0);
+     if( it != NULL)
+      b.bandName = it->text();
+     else
+      break;
+
+     lE=  (QLineEdit *) ui->bandDefinitions->cellWidget(i,1);
+     if ( lE != NULL)
+      b.bandStart= lE->text().toInt();
+     else
+       break;
+     lE = (QLineEdit *) ui->bandDefinitions->cellWidget(i,2);
+     if ( lE != NULL)
+       b.bandEnd= lE->text().toInt();
+     else
+       break;
+     lE = (QLineEdit *) ui->bandDefinitions->cellWidget(i,3);
+     if ( it != NULL)
+      b.preferedFreq= lE->text().toInt();
+     else
+       break;
+     // To do: Check if definition ist consistent
+     settings.bandList << b;
+   }
+
+ QDialog::accept();
+}
+void DefineBandList::addRow()
+{
+  int row;
+  row= ui->bandDefinitions->rowCount();
+  ui->bandDefinitions->insertRow(row);
+  for(int j=1; j < 4; j++)
+    {
+      QLineEdit *line =new QLineEdit;
+      line->setAlignment(Qt::AlignRight);
+      line->setInputMask("00000000000D");
+      ui->bandDefinitions->setCellWidget(row,j,line);
+    }
+}
+
+void DefineBandList::deleteRow()
+{
+  int row;
+  row=ui->bandDefinitions->currentRow();
+  ui->bandDefinitions->removeRow(row);
+}
+
+void DefineBandList::rowUp()
+{
+  QTableWidgetItem *it;
+  QLineEdit *line1;
+  QLineEdit *line0;
+  int row;
+  row=ui->bandDefinitions->currentRow();
+  if(row == 0)
+    return;
+  it=ui->bandDefinitions->takeItem(row-1,0);
+  ui->bandDefinitions->setItem(row-1,0,ui->bandDefinitions->takeItem(row,0));
+  ui->bandDefinitions->setItem(row,0,it);
+  for (int i=1; i < 4; i++)
+    {
+      line1 = (QLineEdit *)ui->bandDefinitions->cellWidget(row-1,i);
+      line0 = (QLineEdit *)ui->bandDefinitions->cellWidget(row,i);
+      QString s = line1->text();
+      line1->setText(line0->text());
+      line0->setText(s);
+
+    }
+}
+
+void DefineBandList::rowDown()
+{
+  QTableWidgetItem *it;
+  QLineEdit *line1;
+  QLineEdit *line0;
+  int row;
+  row=ui->bandDefinitions->currentRow();
+  if(row >=(ui->bandDefinitions->rowCount()-1) )
+    return;
+  it=ui->bandDefinitions->takeItem(row+1,0);
+  ui->bandDefinitions->setItem(row+1,0,ui->bandDefinitions->takeItem(row,0));
+  ui->bandDefinitions->setItem(row,0,it);
+  for (int i=1; i < 4; i++)
+    {
+      line1 = (QLineEdit *)ui->bandDefinitions->cellWidget(row+1,i);
+      line0 = (QLineEdit *)ui->bandDefinitions->cellWidget(row,i);
+      QString s = line1->text();
+      line1->setText(line0->text());
+      line0->setText(s);
+
+    }
+}
diff --git a/gui/addmacro.h b/gui/definebandlist.h
similarity index 77%
copy from gui/addmacro.h
copy to gui/definebandlist.h
index c82a42d..6717e29 100644
--- a/gui/addmacro.h
+++ b/gui/definebandlist.h
@@ -17,39 +17,31 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef ADDMACRO_H
-#define ADDMACRO_H
+#ifndef DEFINEBANDLIST_H
+#define DEFINEBANDLIST_H
 
 #include <QDialog>
-#include <QString>
-#include <QModelIndex>
-
-#include "constants.h"
 
 namespace Ui {
-  class AddMacro;
+  class DefineBandList;
 }
 
-class AddMacro : public QDialog
+class DefineBandList : public QDialog
 {
   Q_OBJECT
 
 public:
-  AddMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
-  ~AddMacro();
-
-public slots:
-
-protected:
+  explicit DefineBandList(QWidget *parent = 0);
+  ~DefineBandList();
 
-protected slots:
-  virtual void  accept();
-  void insertKeyword(QModelIndex);
 private:
-  Ui::AddMacro *ui;
-  QVector<Macro> *mL;
-
+  Ui::DefineBandList *ui;
+public slots:
+  virtual void accept();
+  void addRow();
+  void deleteRow();
+  void rowUp();
+  void rowDown();
 };
 
-#endif
-
+#endif // DEFINEBANDLIST_H
diff --git a/gui/definebandlist.ui b/gui/definebandlist.ui
new file mode 100644
index 0000000..764df43
--- /dev/null
+++ b/gui/definebandlist.ui
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DefineBandList</class>
+ <widget class="QDialog" name="DefineBandList">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>675</width>
+    <height>296</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Define Bands</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="4" column="1">
+    <widget class="QPushButton" name="deleteButton">
+     <property name="text">
+      <string>Delete row</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="1" column="3">
+    <widget class="QPushButton" name="upButton">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="toolTip">
+      <string>To select row click Band name</string>
+     </property>
+     <property name="text">
+      <string>Row up</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <widget class="QPushButton" name="addButton">
+     <property name="text">
+      <string>Add row</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" rowspan="4" colspan="3">
+    <widget class="QTableWidget" name="bandDefinitions">
+     <property name="selectionMode">
+      <enum>QAbstractItemView::SingleSelection</enum>
+     </property>
+     <property name="selectionBehavior">
+      <enum>QAbstractItemView::SelectItems</enum>
+     </property>
+     <property name="sortingEnabled">
+      <bool>true</bool>
+     </property>
+     <property name="rowCount">
+      <number>0</number>
+     </property>
+     <attribute name="horizontalHeaderCascadingSectionResizes">
+      <bool>false</bool>
+     </attribute>
+     <attribute name="horizontalHeaderMinimumSectionSize">
+      <number>100</number>
+     </attribute>
+     <attribute name="horizontalHeaderStretchLastSection">
+      <bool>true</bool>
+     </attribute>
+     <attribute name="verticalHeaderVisible">
+      <bool>false</bool>
+     </attribute>
+     <column>
+      <property name="text">
+       <string>Band Name</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Startfrequency</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Endfrequency</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Preferred frequency</string>
+      </property>
+      <property name="toolTip">
+       <string>Set Frequency to switch to</string>
+      </property>
+      <property name="textAlignment">
+       <set>AlignCenter</set>
+      </property>
+     </column>
+    </widget>
+   </item>
+   <item row="2" column="3">
+    <widget class="QPushButton" name="downButton">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="toolTip">
+      <string>To select row click Band name</string>
+     </property>
+     <property name="text">
+      <string>Row down</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>addButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>addRow()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>48</x>
+     <y>234</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>308</x>
+     <y>129</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>deleteButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>deleteRow()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>134</x>
+     <y>234</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>308</x>
+     <y>129</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>upButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>rowUp()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>568</x>
+     <y>162</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>308</x>
+     <y>129</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>downButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DefineBandList</receiver>
+   <slot>rowDown()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>568</x>
+     <y>193</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>308</x>
+     <y>129</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>addRow()</slot>
+  <slot>deleteRow()</slot>
+  <slot>rowUp()</slot>
+  <slot>rowDown()</slot>
+ </slots>
+</ui>
diff --git a/gui/deletemacro.cpp b/gui/deletemacro.cpp
index 3880f84..bbb884f 100644
--- a/gui/deletemacro.cpp
+++ b/gui/deletemacro.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *   Copyright (C) 2012 - 2016 by Volker Schroer, DL1KSV                   *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -21,8 +21,8 @@
 #include "ui_deletemacro.h"
 
 #include "readonlystringlistmodel.h"
-DeleteMacro::DeleteMacro (QVector<Macro> *macroList, QWidget* parent, Qt::WindowFlags fl )
-                : QDialog ( parent, fl ),  ui(new Ui::DeleteMacro)
+DeleteMacro::DeleteMacro (QVector<Macro> *macroList, QWidget* parent)
+                : QDialog ( parent),  ui(new Ui::DeleteMacro)
 {
   ui->setupUi ( this );
   mL = macroList;
diff --git a/gui/deletemacro.h b/gui/deletemacro.h
index af6e032..437feb3 100644
--- a/gui/deletemacro.h
+++ b/gui/deletemacro.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *   Copyright (C) 2012 - 2016 by Volker Schroer, DL1KSV                   *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -33,7 +33,7 @@ class DeleteMacro : public QDialog
   Q_OBJECT
 
 public:
-  DeleteMacro(QVector<Macro> *macroList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  DeleteMacro(QVector<Macro> *macroList,QWidget* parent = 0 );
   ~DeleteMacro();
 
 public slots:
diff --git a/gui/editmacro.cpp b/gui/editmacro.cpp
index e302de1..cdf2fb0 100644
--- a/gui/editmacro.cpp
+++ b/gui/editmacro.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *   Copyright (C) 2012 - 2016  by Volker Schroer, DL1KSV                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -23,8 +23,8 @@
 #include "readonlystringlistmodel.h"
 #include <QMessageBox>
 
-EditMacro::EditMacro(QVector<Macro> *macroList,QStringList tokenList, QWidget* parent, Qt::WindowFlags fl)
-  : QDialog( parent, fl ), ui(new Ui::EditMacro)
+EditMacro::EditMacro(QVector<Macro> *macroList,QStringList tokenList, QWidget* parent)
+  : QDialog( parent ), ui(new Ui::EditMacro)
 {
   ui->setupUi(this);
   mL=macroList;
diff --git a/gui/editmacro.h b/gui/editmacro.h
index 3a68af9..530f5da 100644
--- a/gui/editmacro.h
+++ b/gui/editmacro.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *   Copyright (C) 2012 - 2016 by Volker Schroer, DL1KSV                   *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -36,7 +36,7 @@ class EditMacro : public QDialog
   Q_OBJECT
 
 public:
-  EditMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  EditMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0 );
   ~EditMacro();
 
 
diff --git a/gui/generalsettings.cpp b/gui/generalsettings.cpp
index caeef1d..0060efb 100644
--- a/gui/generalsettings.cpp
+++ b/gui/generalsettings.cpp
@@ -25,24 +25,29 @@
 #include <QButtonGroup>
 #include "readonlystringlistmodel.h"
 #include <QModelIndex>
+#include <QTextStream>
+
+#ifdef WITH_HAMLIB
+#include <hamlib/rig.h>
+#endif
 
 extern Parameter settings;
 GeneralSettings::GeneralSettings ( QWidget* parent, Qt::WindowFlags fl )
   : QDialog ( parent, fl ), Ui::GeneralSettings()
 {
   setupUi ( this );
+#ifndef WITH_HAMLIB
+  Rignumber->hide();
+  modelNr->hide();
+  commParams->hide();
+  Rigdevice->hide();
+  rigControl->hide();
+#endif
   QString DirectoryName;
   QDir dir;
   QString s;
+  int index;
   LocalSettings = settings;
-  FileFormat = new QButtonGroup ( FileFormatLayout );
-  FileFormat->setExclusive ( true );
-  FileFormat->addButton ( Wav, 0 );
-  FileFormat->addButton ( Text, 1 );
-  if ( LocalSettings.DemoTypeNumber == 0 )
-    Wav->setChecked ( true );
-  else
-    Text->setChecked ( true );
   Callsign->setText ( LocalSettings.callsign );
   myLocator->setText ( LocalSettings.myLocator );
   UTC->setValue ( LocalSettings.timeoffset );
@@ -57,15 +62,13 @@ GeneralSettings::GeneralSettings ( QWidget* parent, Qt::WindowFlags fl )
   myLocator->setText ( LocalSettings.myLocator );
   Demomode->setChecked ( LocalSettings.DemoMode );
   connect ( Demomode, SIGNAL ( clicked ( bool ) ), this, SLOT ( selectDemomode ( bool ) ) );
-  connect ( AvailableDevices, SIGNAL ( clicked ( const QModelIndex & ) ), this, SLOT ( setPTTDevice ( const QModelIndex & ) ) );
 
   if ( Demomode->isChecked() )
     selectDemomode(true);
   else
     selectDemomode(false);
 
-  //PTT
-  SelectedDevice->setText ( LocalSettings.SerialDevice );
+  //PTT and Rig
   // First look in the /dev Directory
   DirectoryName = "/dev/";
 
@@ -77,32 +80,59 @@ GeneralSettings::GeneralSettings ( QWidget* parent, Qt::WindowFlags fl )
 
   for ( int kk = 0; kk < Files.size(); kk++ )
     Files.replace ( kk, DirectoryName + Files.at ( kk ) );
-  ReadOnlyStringListModel *m = new ReadOnlyStringListModel ( this );
-  m->setStringList ( Files );
-  AvailableDevices->setModel ( m );
-  AvailableDevices->show();
+  // PTT
+  pttDevice->addItem(QLatin1String("None"));
+  pttDevice->addItems(Files);
+  index=pttDevice->findText(LocalSettings.SerialDevice);
+  if(index > 0)
+    pttDevice->setCurrentIndex(index);
+  else
+    pttDevice->setCurrentIndex(0);
+  // Rig
+  rigControl->addItem(QLatin1String("None"));
+  rigControl->addItems(Files);
+  index=rigControl->findText(LocalSettings.rigDevice);
+  if(index > 0)
+    rigControl->setCurrentIndex(index);
+  else
+    rigControl->setCurrentIndex(0);
   // Sound Devices
-  soundInputDeviceName->setText(LocalSettings.InputDeviceName);
-  soundOutputDeviceName->setText(LocalSettings.OutputDeviceName);
+  QStringList cards=getSoundCards();
+  soundInputDeviceName->addItems(cards);
+  soundInputDeviceName->addItem(QLatin1String("LinPSK_Record"));
+  index=soundInputDeviceName->findText(LocalSettings.InputDeviceName);
+  if(index >=0)
+    soundInputDeviceName->setCurrentIndex(index);
+  soundOutputDeviceName->addItems(cards);
+  soundOutputDeviceName->addItem(QLatin1String("LinPSK_Play"));
+  index=soundOutputDeviceName->findText(LocalSettings.OutputDeviceName);
+  if(index >= 0)
+    soundOutputDeviceName->setCurrentIndex(index);
   //Logging
   Directory->setText ( LocalSettings.Directory );
   QsoFile->setText ( LocalSettings.QSOFileName );
   fileLog->setChecked ( LocalSettings.fileLog );
-  connect(fileLog,SIGNAL(clicked(bool)),this,SLOT(selectFileLogging(bool)));
   Directory->setDisabled ( !LocalSettings.fileLog );
   QsoFile->setDisabled ( !LocalSettings.fileLog );
   LinLog->setChecked ( LocalSettings.LinLog );
-  connect(LinLog,SIGNAL(clicked(bool)),this,SLOT(selectLinLogLogging(bool)));
   Port->setDisabled ( !LocalSettings.LinLog );
   Host->setDisabled ( !LocalSettings.LinLog );
 
+  // Rig number
+  modelNr->setText(QString("%1").arg(LocalSettings.rigModelNumber));
+
+
+
+  // Rig- Serial
+  handShake->setCurrentIndex(LocalSettings.handshake);
+  baudRate->setCurrentIndex(baudRate->findText(QString("%1").arg(LocalSettings.baudrate),Qt::MatchExactly));
+
 }
 
 
 GeneralSettings::~GeneralSettings()
 {}
 
-/*$SPECIALIZATION$*/
 
 
 Parameter GeneralSettings::getSettings()
@@ -112,21 +142,21 @@ Parameter GeneralSettings::getSettings()
   if ( Demomode->isChecked() )
     {
       LocalSettings.DemoMode = true;
-      LocalSettings.DemoTypeNumber = FileFormat->checkedId();
       LocalSettings.inputFilename = "";
     }
   else
     {
       LocalSettings.DemoMode = false;
-      LocalSettings.InputDeviceName=soundInputDeviceName->text();
-      LocalSettings.OutputDeviceName=soundOutputDeviceName->text();
+      LocalSettings.InputDeviceName=soundInputDeviceName->currentText();
+      LocalSettings.OutputDeviceName=soundOutputDeviceName->currentText();
     }
 
   LocalSettings.timeoffset = UTC->value();
   LocalSettings.slashed0 = SlashedZero->isChecked();
   LocalSettings.autoCrLf = autoCrLf->isChecked();
   LocalSettings.autoDate=autoDate->isChecked();
-  LocalSettings.SerialDevice = SelectedDevice->text();
+  LocalSettings.SerialDevice = pttDevice->currentText();
+  LocalSettings.rigDevice=rigControl->currentText();
   LocalSettings.fileLog = fileLog->isChecked();
   if ( LocalSettings.fileLog )
     {
@@ -141,31 +171,25 @@ Parameter GeneralSettings::getSettings()
       LocalSettings.Port = Port->value();
     }
   LocalSettings.dateFormat=dateFormat->currentText();
+  // Rig parameter
+#ifdef WITH_HAMLIB
+  LocalSettings.rigModelNumber=modelNr->text().toInt();
+  LocalSettings.baudrate=baudRate->currentText().toInt();
+  LocalSettings.handshake=static_cast<serial_handshake_e>(handShake->currentIndex());
+#else
+  LocalSettings.rigModelNumber=0;
+#endif
   return LocalSettings;
 }
 
 void GeneralSettings::selectDemomode ( bool mode )
 {
   if ( mode )
-    {
-      FileFormatLayout->show();
-      SoundDeviceBox->hide();
-    }
+    SoundDeviceBox->hide();
   else
-    {
-      FileFormatLayout->hide();
-      SoundDeviceBox->show();
-    }
+    SoundDeviceBox->show();
 }
 
-void GeneralSettings::setPTTDevice ( const QModelIndex &index )
-{
-  QString s = index.data().toString();
-
-  SelectedDevice->clear();
-  SelectedDevice->setText ( s );
-  LocalSettings.SerialDevice = s;
-}
 
 void GeneralSettings::selectFileLogging ( bool b)
 {
@@ -185,3 +209,27 @@ void GeneralSettings::setComplexFormat(bool b)
 {
   LocalSettings.complexFormat=b;
 }
+QStringList GeneralSettings::getSoundCards()
+{
+  QString line;
+  QFile cards( "/proc/asound/cards" );
+  QStringList cardList;
+  int pos;
+  cardList << "None";
+  if (!cards.open(QIODevice::ReadOnly | QIODevice::Text))
+          return cardList;
+
+  QTextStream in(&cards);
+  cardList.clear();
+  do {
+      line = in.readLine();
+      pos=line.indexOf(QLatin1String(": "));
+      if(pos > 0)
+        cardList << line.mid(pos+1);
+  } while (!in.atEnd());
+  if(cardList.isEmpty())
+    cardList << "None";
+  cards.close();
+  return cardList;
+  }
+
diff --git a/gui/generalsettings.h b/gui/generalsettings.h
index be1081c..cf97bfd 100644
--- a/gui/generalsettings.h
+++ b/gui/generalsettings.h
@@ -22,10 +22,13 @@
 #define GENERALSETTINGS_H
 
 #include <QDialog>
+#include <QStringList>
 #include "ui_generalsettings.h"
 class Parameter;
 class QButtonGroup;
 class QModelIndex;
+class QMenu;
+
 class GeneralSettings : public QDialog, private Ui::GeneralSettings
 {
   Q_OBJECT
@@ -36,19 +39,21 @@ public:
 Parameter getSettings();
 
 public slots:
-  /*$PUBLIC_SLOTS$*/
 
 protected:
 QButtonGroup *FileFormat;
-  /*$PROTECTED_FUNCTIONS$*/
 Parameter LocalSettings;
+
+QMenu * selectionMenu;
 protected slots:
 void selectDemomode(bool);
-void setPTTDevice(const QModelIndex &);
+
 void selectFileLogging(bool);
 void selectLinLogLogging(bool);
 void setSampleRate(QString s);
 void setComplexFormat(bool);
+QStringList getSoundCards();
+
 };
 
 #endif
diff --git a/gui/generalsettings.ui b/gui/generalsettings.ui
index de0ba0d..4ce3c60 100644
--- a/gui/generalsettings.ui
+++ b/gui/generalsettings.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>650</width>
-    <height>383</height>
+    <width>787</width>
+    <height>428</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -37,7 +37,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2">
+  <layout class="QGridLayout" name="gridLayout_4">
    <item row="0" column="0">
     <widget class="QLabel" name="CallsignL">
      <property name="frameShape">
@@ -54,10 +54,10 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="2">
+   <item row="0" column="1">
     <widget class="QLineEdit" name="Callsign"/>
    </item>
-   <item row="0" column="3">
+   <item row="0" column="2">
     <widget class="QLabel" name="UTCL">
      <property name="text">
       <string>Time Offset to UTC</string>
@@ -67,7 +67,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="4">
+   <item row="0" column="3">
     <widget class="QSpinBox" name="UTC">
      <property name="minimum">
       <number>-12</number>
@@ -77,7 +77,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="5">
+   <item row="0" column="4">
     <spacer name="horizontalSpacer_6">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -97,17 +97,17 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="1" colspan="2">
+   <item row="1" column="1">
     <widget class="QLineEdit" name="myLocator"/>
    </item>
-   <item row="1" column="3">
+   <item row="1" column="2">
     <widget class="QLabel" name="label_6">
      <property name="text">
       <string>Date Format</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="4">
+   <item row="1" column="3">
     <widget class="QComboBox" name="dateFormat">
      <property name="whatsThis">
       <string>describes the format displaying the date within qsodata </string>
@@ -124,7 +124,7 @@
      </item>
     </widget>
    </item>
-   <item row="1" column="5">
+   <item row="1" column="4">
     <spacer name="horizontalSpacer_7">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -137,7 +137,39 @@
      </property>
     </spacer>
    </item>
-   <item row="2" column="0" colspan="3">
+   <item row="2" column="0" colspan="2">
+    <spacer name="horizontalSpacer_5">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>283</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="2">
+    <widget class="QRadioButton" name="autoDate">
+     <property name="minimumSize">
+      <size>
+       <width>150</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="text">
+      <string>Set Date qso saving</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+     <property name="autoExclusive">
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="3">
     <widget class="QRadioButton" name="SlashedZero">
      <property name="font">
       <font/>
@@ -150,7 +182,7 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="3">
+   <item row="2" column="4">
     <widget class="QRadioButton" name="autoCrLf">
      <property name="enabled">
       <bool>true</bool>
@@ -160,33 +192,106 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="3">
-    <spacer name="horizontalSpacer_4">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>129</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="3" column="4" colspan="2">
-    <spacer name="horizontalSpacer_5">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
+   <item row="3" column="0" colspan="2">
+    <widget class="QGroupBox" name="commParams">
+     <property name="title">
+      <string>Rig Comm Parameter</string>
      </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>283</width>
-       <height>20</height>
-      </size>
+     <property name="alignment">
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
      </property>
-    </spacer>
+     <layout class="QGridLayout" name="gridLayout_5">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_14">
+        <property name="text">
+         <string>Baudrate</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QComboBox" name="baudRate">
+        <property name="toolTip">
+         <string>Select Baudrate</string>
+        </property>
+        <property name="currentIndex">
+         <number>3</number>
+        </property>
+        <item>
+         <property name="text">
+          <string>1200</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>2400</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>4800</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>9600</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>19200</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>38400</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>57600</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_15">
+        <property name="text">
+         <string>Handshake</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QComboBox" name="handShake">
+        <property name="toolTip">
+         <string>Select Handshake</string>
+        </property>
+        <property name="currentIndex">
+         <number>1</number>
+        </property>
+        <property name="maxVisibleItems">
+         <number>3</number>
+        </property>
+        <item>
+         <property name="text">
+          <string>None</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Hardware</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>XonXoff</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+     </layout>
+    </widget>
    </item>
-   <item row="4" column="0" colspan="2">
+   <item row="3" column="2">
     <widget class="QFrame" name="frame">
      <property name="frameShape">
       <enum>QFrame::StyledPanel</enum>
@@ -202,82 +307,10 @@
         </property>
        </widget>
       </item>
-      <item>
-       <widget class="QGroupBox" name="FileFormatLayout">
-        <property name="title">
-         <string>Fileformat</string>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout">
-         <item>
-          <widget class="QRadioButton" name="Wav">
-           <property name="text">
-            <string>Wav</string>
-           </property>
-           <property name="checked">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QRadioButton" name="Text">
-           <property name="text">
-            <string>Text</string>
-           </property>
-           <property name="checked">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="6" column="0" colspan="2">
-    <widget class="QPushButton" name="buttonOk">
-     <property name="minimumSize">
-      <size>
-       <width>80</width>
-       <height>20</height>
-      </size>
-     </property>
-     <property name="font">
-      <font/>
-     </property>
-     <property name="focusPolicy">
-      <enum>Qt::ClickFocus</enum>
-     </property>
-     <property name="text">
-      <string>&Ok</string>
-     </property>
-     <property name="shortcut">
-      <string>Alt+O</string>
-     </property>
-     <property name="autoDefault">
-      <bool>false</bool>
-     </property>
-     <property name="default">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="2" colspan="2">
-    <widget class="QGroupBox" name="groupBox_2">
-     <property name="title">
-      <string>PTT Device</string>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_5">
-      <item>
-       <widget class="QListView" name="AvailableDevices"/>
-      </item>
-      <item>
-       <widget class="QLineEdit" name="SelectedDevice"/>
-      </item>
      </layout>
     </widget>
    </item>
-   <item row="4" column="4" rowspan="2" colspan="2">
+   <item row="3" column="3" rowspan="2" colspan="2">
     <widget class="QGroupBox" name="groupBox_3">
      <property name="title">
       <string>Logging</string>
@@ -388,19 +421,69 @@
      </layout>
     </widget>
    </item>
-   <item row="5" column="0" colspan="4">
+   <item row="4" column="0" rowspan="2" colspan="2">
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Rig Devices</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_5">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QLabel" name="Rignumber">
+          <property name="text">
+           <string>Rig number</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLineEdit" name="modelNr">
+          <property name="toolTip">
+           <string>Set Rig number as defined in hamlib</string>
+          </property>
+          <property name="inputMask">
+           <string extracomment="Modelnumber from hamlib">0999</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QGridLayout" name="gridLayout_2">
+        <item row="0" column="0">
+         <widget class="QLabel" name="label_9">
+          <property name="text">
+           <string>PTT device</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="Rigdevice">
+          <property name="text">
+           <string>Rig device</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QComboBox" name="pttDevice"/>
+        </item>
+        <item row="1" column="1">
+         <widget class="QComboBox" name="rigControl"/>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="5" column="3" colspan="2">
     <widget class="QGroupBox" name="SoundDeviceBox">
      <property name="title">
       <string>Sound Device</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
-      <item row="1" column="1">
-       <widget class="QLineEdit" name="soundOutputDeviceName">
-        <property name="text">
-         <string>LinPSK_Play</string>
-        </property>
-       </widget>
-      </item>
       <item row="0" column="0">
        <widget class="QLabel" name="label_7">
         <property name="text">
@@ -408,13 +491,6 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1">
-       <widget class="QLineEdit" name="soundInputDeviceName">
-        <property name="text">
-         <string>LinPSK_Record</string>
-        </property>
-       </widget>
-      </item>
       <item row="1" column="0">
        <widget class="QLabel" name="label_8">
         <property name="text">
@@ -422,54 +498,79 @@
         </property>
        </widget>
       </item>
+      <item row="0" column="1">
+       <widget class="QComboBox" name="soundInputDeviceName"/>
+      </item>
+      <item row="1" column="1">
+       <widget class="QComboBox" name="soundOutputDeviceName"/>
+      </item>
      </layout>
     </widget>
    </item>
-   <item row="6" column="4" colspan="2">
-    <spacer name="horizontalSpacer_3">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>115</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
+   <item row="6" column="0" colspan="2">
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QPushButton" name="buttonOk">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>20</height>
+        </size>
+       </property>
+       <property name="font">
+        <font/>
+       </property>
+       <property name="focusPolicy">
+        <enum>Qt::ClickFocus</enum>
+       </property>
+       <property name="text">
+        <string>&Ok</string>
+       </property>
+       <property name="shortcut">
+        <string>Alt+O</string>
+       </property>
+       <property name="autoDefault">
+        <bool>false</bool>
+       </property>
+       <property name="default">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="buttonCancel">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>20</height>
+        </size>
+       </property>
+       <property name="font">
+        <font/>
+       </property>
+       <property name="focusPolicy">
+        <enum>Qt::ClickFocus</enum>
+       </property>
+       <property name="text">
+        <string>&Cancel</string>
+       </property>
+       <property name="shortcut">
+        <string/>
+       </property>
+       <property name="autoDefault">
+        <bool>false</bool>
+       </property>
+       <property name="default">
+        <bool>false</bool>
+       </property>
+       <property name="flat">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
    <item row="6" column="2">
-    <widget class="QPushButton" name="buttonCancel">
-     <property name="minimumSize">
-      <size>
-       <width>80</width>
-       <height>20</height>
-      </size>
-     </property>
-     <property name="font">
-      <font/>
-     </property>
-     <property name="focusPolicy">
-      <enum>Qt::ClickFocus</enum>
-     </property>
-     <property name="text">
-      <string>&Cancel</string>
-     </property>
-     <property name="shortcut">
-      <string/>
-     </property>
-     <property name="autoDefault">
-      <bool>false</bool>
-     </property>
-     <property name="default">
-      <bool>false</bool>
-     </property>
-     <property name="flat">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="3">
     <spacer name="horizontalSpacer_8">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -482,57 +583,27 @@
      </property>
     </spacer>
    </item>
-   <item row="2" column="4" colspan="2">
-    <spacer name="horizontalSpacer_2">
+   <item row="6" column="3" colspan="2">
+    <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
-       <width>115</width>
+       <width>358</width>
        <height>20</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="2" column="3">
-    <widget class="QRadioButton" name="autoDate">
-     <property name="minimumSize">
-      <size>
-       <width>150</width>
-       <height>0</height>
-      </size>
-     </property>
-     <property name="text">
-      <string>Set Date qso saving</string>
-     </property>
-     <property name="checked">
-      <bool>true</bool>
-     </property>
-     <property name="autoExclusive">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
  <tabstops>
   <tabstop>Callsign</tabstop>
-  <tabstop>myLocator</tabstop>
   <tabstop>UTC</tabstop>
-  <tabstop>dateFormat</tabstop>
-  <tabstop>SlashedZero</tabstop>
-  <tabstop>autoDate</tabstop>
-  <tabstop>autoCrLf</tabstop>
   <tabstop>Demomode</tabstop>
-  <tabstop>Wav</tabstop>
-  <tabstop>Text</tabstop>
-  <tabstop>AvailableDevices</tabstop>
-  <tabstop>SelectedDevice</tabstop>
-  <tabstop>soundInputDeviceName</tabstop>
-  <tabstop>soundOutputDeviceName</tabstop>
   <tabstop>fileLog</tabstop>
   <tabstop>Directory</tabstop>
   <tabstop>QsoFile</tabstop>
@@ -577,8 +648,60 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>Demomode</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>GeneralSettings</receiver>
+   <slot>selectDemomode(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>324</x>
+     <y>115</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>393</x>
+     <y>213</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>LinLog</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>GeneralSettings</receiver>
+   <slot>selectLinLogLogging(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>683</x>
+     <y>154</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>393</x>
+     <y>213</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>fileLog</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>GeneralSettings</receiver>
+   <slot>selectFileLogging(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>511</x>
+     <y>154</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>393</x>
+     <y>213</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
-  <slot>setSampleRate(QString)</slot>
+  <slot>selectDemomode(bool)</slot>
+  <slot>setControlDevice(QModelIndex)</slot>
+  <slot>selectLinLogLogging(bool)</slot>
+  <slot>selectFileLogging(bool)</slot>
+  <slot>setRigNumber()</slot>
  </slots>
 </ui>
diff --git a/gui/linpsk.cpp b/gui/linpsk.cpp
index e0bafef..5c8ff80 100644
--- a/gui/linpsk.cpp
+++ b/gui/linpsk.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          |FILENAME|  -  description
-                             -------------------
-    begin                : |DATE|
-    copyright            : (C) |YEAR| by |AUTHOR|
-    email                : |EMAIL|
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -17,19 +9,20 @@
 
 #include "linpsk.h"
 
-
+#include "addrxwindow.h"
+#include "bpskmodulator.h"
 #include "controlpanel.h"
 #include "crxdisplay.h"
 #include "ctxdisplay.h"
 
 #include "parameter.h"
-#include "addrxwindow.h"
+
 #include "spectrumdisplay.h"
 #include "frequencyselect.h"
 #include "cledbutton.h"
 #include "rttymodulator.h"
 #include "pskmodulator.h"
-#include "bpskmodulator.h"
+#include "psk63modulator.h"
 #include "qpskmodulator.h"
 #include "mfskmodulator.h"
 #include "ctxbuffer.h"
@@ -48,6 +41,11 @@
 #include "deletemacro.h"
 #include "renamemacro.h"
 #include "color.h"
+#include "definebandlist.h"
+#ifdef WITH_HAMLIB
+#include "rigcontrol.h"
+#endif
+#include <unistd.h>
 
 
 #include <QtGui>
@@ -57,7 +55,7 @@
 #include <QFontDialog>
 #include <QColorDialog>
 
-#define VERSION "1.2.5"
+#define VERSION "1.3.5"
 
 
 #define ProgramName "LinPSK "
@@ -68,12 +66,17 @@ extern Parameter settings;
  *  name 'name' and widget flags set to 'f'.
  *
  */
-LinPSK::LinPSK ( QWidget* parent, Qt::WindowFlags fl )
-  : QMainWindow ( parent, fl ), Ui::LinPSK()
+LinPSK::LinPSK ( QWidget* parent)
+  : QMainWindow ( parent), Ui::LinPSK()
 {
   Sound = 0;
   Modulator = 0;
   inAction=false;
+  // Content of modeList must correspond to enum Mode in constants.h
+  modeList << "BPSK31" << "BPSK63" << "QPSK" << "RTTY" << "MFSK16"   ;
+#ifdef WITH_HAMLIB
+  settings.rig =new RigControl();
+#endif
   /** To avoid multipe Macro clicking **/
   blockMacros=false;
   /************************************/
@@ -81,6 +84,8 @@ LinPSK::LinPSK ( QWidget* parent, Qt::WindowFlags fl )
 
   setupUi(this);
   read_config();
+  apply_settings();
+
   /** Fixme: handle font change: fontChange() **/
 
   if ( settings.ApplicationFont == 0 )
@@ -108,7 +113,53 @@ LinPSK::LinPSK ( QWidget* parent, Qt::WindowFlags fl )
   msg = new QLabel ( );
   statusbar->addPermanentWidget ( msg, 2 );
   msg->setText ( tr ( "Ready" ) );
+#ifdef WITH_HAMLIB
+  rigInfo =new QLabel();
+  statusbar->addPermanentWidget(rigInfo,1);
+  if((settings.rigModelNumber > 0) && settings.rigDevice != "None")
+    {
+     int rc=-settings.rig->connectRig();
+     if(rc != RIG_OK)
+       {
+         switch(rc) {
+           case RIG_EINVAL :
+             QMessageBox::warning(0,"Invalid parameter",QLatin1String("Probably unknown rig"));
+             rigInfo->setText("Rig: None");
+             break;
+           case RIG_ETIMEOUT:
+           default:
+             if(rc != RIG_ETIMEOUT)
+               QMessageBox::warning(0,"Connection time out",QLatin1String(rigerror(rc)));
+             if(QMessageBox::question ( 0,"Connection time out" , tr ( "Could not connect to rig\nTry again ?" ),
+                                        QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes)
+               {
+                 rc=-settings.rig->connectRig();
+                 if( rc != RIG_OK)
+                   {
+                     QMessageBox::warning(0,"Connection time out",QLatin1String(rigerror(rc)));
+                     rigInfo->setText("Rig: None");
+                   }
+                 else
+                   rigInfo->setText(QLatin1String("Rig: ")+settings.rig->getModelName());
+               }
+             else
+              rigInfo->setText("Rig: None");
+             break;
+
+        }
+
+       }
+     else
+       {
+         rigInfo->setText(QLatin1String("Rig: ")+settings.rig->getModelName());
+       }
+     if( rc == RIG_OK)
+       {
 
+       }
+    }
+#endif
+  Control->initQsoData();
 // IMD
   IMD = new QLabel ( statusbar );
   statusbar -> addPermanentWidget ( IMD, 1 );
@@ -136,10 +187,10 @@ LinPSK::LinPSK ( QWidget* parent, Qt::WindowFlags fl )
 
   Control->setColorList ( &WindowColors );
   languageChange();
-
 // signals and slots connections
 //========== Macro Processing ======================================
-  tokenList << "@CALLSIGN@" << "@DATE@" << "@Replace by filename@" << "@RX@" << "@THEIRCALL@" << "@THEIRNAME@" << "@TIMELOCAL@" << "@TIMEUTC@" << "@TX@" << "@RSTGIVEN@" << "@RSTRCVD@";
+  tokenList << "@CALLSIGN@" << "@DATE@" << "@Replace by filename@" << "@RX@" << "@THEIRCALL@" << "@THEIRNAME@";
+  tokenList << "@TIMELOCAL@" << "@TIMEUTC@" << "@TX@" << "@RSTGIVEN@" << "@RSTRCVD@" <<"@TXPWR@";
   Control->insertMacros( &macroList );
   connect ( this, SIGNAL ( StartRx() ), this, SLOT ( startRx() ) );
   connect ( this, SIGNAL ( StartTx() ), this, SLOT ( startTx() ) );
@@ -147,10 +198,7 @@ LinPSK::LinPSK ( QWidget* parent, Qt::WindowFlags fl )
 //===================================================================
 
   TxBuffer = new CTxBuffer();
-
-  apply_settings();
   TxDisplay->txWindow->setTxBuffer ( TxBuffer );
-
 }
 
 /*
@@ -213,7 +261,7 @@ void LinPSK::fileOpen()
 {
   QString fileName;
 
-  fileName = QFileDialog::getOpenFileName ( 0, tr ( "Open Demofile" ), "", settings.DemoModeFileType[settings.DemoTypeNumber] );
+  fileName = QFileDialog::getOpenFileName ( 0, tr ( "Open Demofile" ), "", "*.wav" );
   if ( !fileName.isEmpty() )
     settings.inputFilename = fileName;
 }
@@ -248,7 +296,7 @@ void LinPSK::helpAboutQt()
 
 void LinPSK::addRxWindow()
 {
-  AddRxWindow *Channel = new AddRxWindow();
+  AddRxWindow *Channel = new AddRxWindow(modeList);
   if ( Channel->exec() != 0 )
   {
     AfcMode modus;
@@ -308,33 +356,9 @@ void LinPSK::startRx()
   }
   if ( RxDisplay->start_process_loop() )
   {
-    QString Info;
     TxDisplay->TxFunctions->setStatus ( OFF );
     if ( settings.ActChannel != 0 )
-      switch ( settings.ActChannel->getModulationType() )
-      {
-        case QPSK:
-          Info = "QPSK";
-          break;
-
-        case BPSK:
-          Info = "BPSK";
-          break;
-
-        case RTTY:
-          Info = "RTTY";
-          break;
-
-        case MFSK16:
-          Info = "MFSK16";
-          break;
-
-
-        default:
-          Info = "undefined";
-      }
-
-    msg->setText ( tr ( "Receiving " ) + Info );
+      msg->setText ( tr ( "Receiving " ) + modeList[settings.ActChannel->getModulationType()] );
   }
   else
     TxDisplay->TxFunctions->setStatus ( UNDEF );
@@ -348,7 +372,6 @@ void LinPSK::startTx()
 {
   Mode ModulationType;
   QString errorstring;
-  QString Info;
   double Frequency;
 
   RxDisplay->stop_process_loop();
@@ -366,37 +389,32 @@ void LinPSK::startTx()
   {
     case QPSK:
       Modulator = new QPskModulator ( 11025, Frequency, TxBuffer );
-      Info = "QPSK";
       break;
-    case BPSK:
-      Modulator = new BPSKModulator ( 11025, Frequency, TxBuffer );
-      Info = "BPSK";
+    case BPSK31:
+      Modulator = new BpskModulator ( 11025, Frequency, TxBuffer );
+      break;
+    case BPSK63:
+      Modulator = new Psk63Modulator ( 11025, Frequency, TxBuffer );
       break;
 
     case RTTY:
       Modulator = new RTTYModulator ( 11025, Frequency, TxBuffer );
       if ( settings.ActChannel->getParameter ( Extra ) != 0 )
         Modulator->setParameter ( Extra, settings.ActChannel->getParameter ( Extra ) );
-      Info = "RTTY";
       break;
     case MFSK16:
       Modulator = new MFSKModulator ( 11025, Frequency, TxBuffer );
-      Info = "MFSK16";
       break;
 
-    default:
-      Modulator = new BPSKModulator ( 11025, Frequency, TxBuffer );
-      Info = "BPSK";
-      break;
+/**    default:
+      Modulator = new BpskModulator ( 11025, Frequency, TxBuffer );
+      break; */
   }
   if ( Sound <= NULL ) // Only create Sound Device once for output
   {
     if ( settings.DemoMode )
     {
-      if ( settings.DemoTypeNumber == 0 )
-        Sound = new WaveInput ( -1 );
-      else
-        Sound = new TextInput ( -1 );
+      Sound = new WaveInput ( -1 );
       msg->setText ( tr ( "Transmitting (Demo)" ) );
     }
     else
@@ -420,7 +438,7 @@ void LinPSK::startTx()
 
   connect ( Modulator, SIGNAL ( charSend ( char ) ), settings.ActChannel, SLOT ( updateRx ( char ) ) );
   TxDisplay->TxFunctions->setStatus ( ON );
-  msg->setText ( tr ( "Transmitting " ) + Info );
+  msg->setText ( tr ( "Transmitting " ) + modeList[ModulationType] );
   TxDisplay->txWindow->setFocus();
   settings.Status = TxDisplay->TxFunctions->getstatus();
   Control->present(false);
@@ -465,7 +483,35 @@ void LinPSK::generalSettings()
 {
   GeneralSettings *LocalSettings = new GeneralSettings ( this );
   if ( LocalSettings->exec() != 0 )
-    settings = LocalSettings->getSettings();
+    {
+      settings = LocalSettings->getSettings();
+#ifdef WITH_HAMLIB
+      int modelNr = settings.rigModelNumber;
+      if( (modelNr >0) && ((modelNr != settings.rigModelNumber) || !settings.rig->isConnected()) ) //Rig has changed
+        {
+          settings.rig->disconnectRig();
+          int rc = -settings.rig->connectRig();
+          if(rc != RIG_OK)
+            {
+              switch(rc) {
+                case RIG_ETIMEOUT:
+                  QMessageBox::warning(0,"Connection time out",QLatin1String("Could not connect to rig"));
+                  break;
+                case RIG_EINVAL :
+                  QMessageBox::warning(0,"Invalid parameter",QLatin1String("Probably unknown rig.\nTrying to keep previous one"));
+                  break;
+                default:
+                  QMessageBox::warning(0,"Connection time out",QLatin1String("Unknown reason"));
+                  break;
+
+             }
+              settings.rigModelNumber=modelNr; // Reconnect here ?
+              if(settings.rig->connectRig() != RIG_OK)
+                return;
+            }
+        }
+#endif
+    }
   apply_settings();
 }
 void LinPSK::chooseColor()
@@ -507,6 +553,7 @@ void LinPSK::stopTx()
   if ( Sound != 0 )
   {
     Sound->PTT ( false );
+    Sound->wait();
     Sound->close_Device();
   }
   delete Modulator;
@@ -516,46 +563,23 @@ void LinPSK::stopTx()
 
 void LinPSK::apply_settings()
 {
-  selectPTTDevice();
+  checkControlDevices();
   Control->enableSaveData();
   Control->setAutoDate();
+  actionOpen_Demo_File->setEnabled(settings.DemoMode);
 }
 void LinPSK::setChannelParams()
 {
   Control->setPhasePointer ( settings.ActChannel->getPhasePointer() );
   Control->newChannel();
   if ( settings.ActChannel != 0 )
-  {
-    QString Info;
-    switch ( settings.ActChannel->getModulationType() )
-    {
-
-      case QPSK:
-        Info = "QPSK";
-        break;
-
-      case BPSK:
-        Info = "BPSK";
-        break;
-
-      case RTTY:
-        Info = "RTTY";
-        break;
-
-      case MFSK16:
-        Info = "MFSK16";
-        break;
-      default:
-        Info = "undefined";
-    }
+        msg->setText ( tr ( "Receiving " ) + modeList[settings.ActChannel->getModulationType()] );
     RxDisplay->setAfcProperties( settings.ActChannel->AfcProperties() );
-    msg->setText ( tr ( "Receiving " ) + Info );
-  }
 }
 void LinPSK::setRxMode()
 {
-  QString Info;
-  ModeMenu Menu ;
+
+  ModeMenu Menu(modeList) ;
   ExtraParameter *Param;
   ExtraParameter parameter;
 
@@ -567,34 +591,12 @@ void LinPSK::setRxMode()
     Mode rxmode = ( Mode ) Menu.selectedMode();
     settings.ActChannel->setMode ( rxmode );
     RxDisplay->setAfcProperties( settings.ActChannel->AfcProperties() );
-    RxDisplay->setAfc ( settings.ActChannel->getAfcMode() );
+//    RxDisplay->setAfc ( settings.ActChannel->getAfcMode() );
     Control->setPhasePointer ( settings.ActChannel->getPhasePointer() );
     parameter= Menu.getParameter();
     settings.ActChannel->setParameter ( Extra, &parameter );
+    msg->setText ( tr ( "Receiving " ) + modeList[rxmode] );
   }
-  if ( settings.ActChannel != 0 )
-    switch ( settings.ActChannel->getModulationType() )
-    {
-      case QPSK:
-        Info = "QPSK";
-        break;
-
-      case BPSK:
-        Info = "BPSK";
-        break;
-
-      case RTTY:
-        Info = "RTTY";
-        break;
-
-      case MFSK16:
-        Info = "MFSK16";
-        break;
-      default:
-        Info = "undefined";
-    }
-
-  msg->setText ( tr ( "Receiving " ) + Info );
 }
 
 void LinPSK::save_config()
@@ -614,12 +616,9 @@ void LinPSK::save_config()
   config.endGroup();
   /** DemoMode **/
   config.setValue ( "DemoMode", settings.DemoMode );
-  config.setValue ( "DemoTypeNumber", settings.DemoTypeNumber );
 //Operating
   config.setValue ( "Callsign", settings.callsign );
   config.setValue ( "MyLocator", settings.myLocator );
-
-  config.setValue ( "PTTDevice", settings.SerialDevice );
 //Logging
   config.setValue ( "Directory", settings.Directory );
   config.setValue ( "QSoFileName", settings.QSOFileName );
@@ -664,6 +663,30 @@ void LinPSK::save_config()
      }
      config.endArray();
    }
+  // Bandlist
+   size=settings.bandList.size();
+   if(size >0)
+     {
+       config.beginWriteArray ("Bandlist");
+       for(i=0;i < size;i++)
+         {
+           config.setArrayIndex ( i );
+           config.setValue ( "Bandname", settings.bandList.at( i ).bandName );
+           config.setValue ( "Bandstart", settings.bandList.at(i).bandStart );
+           config.setValue ( "Bandend", settings.bandList.at(i).bandEnd );
+           config.setValue ( "PreferedFrequency",settings.bandList.at(i).preferedFreq);
+
+         }
+       config.endArray();
+     }
+   // Rig parameter for use with hamlib
+     config.beginGroup ( "Rigparameter" );
+     config.setValue ( "PTTDevice", settings.SerialDevice );
+     config.setValue( "RIGDevice", settings.rigDevice);
+     config.setValue("Modelnr",settings.rigModelNumber);
+     config.setValue("BaudRate",settings.baudrate);
+     config.setValue("Handshake",settings.handshake);
+     config.endGroup();
 
   // SoundDevices
    config .beginGroup("SoundDevices");
@@ -788,6 +811,13 @@ void LinPSK::executeMacro ( int id )
                            macro.replace ( indexvon, tokenList.at(10).length(),settings.QslData->HisRST );
 
                           }
+                          else
+                            if( Token == tokenList.at(11) )  // TXPWR
+                            {
+                             QString pwr;
+                             pwr.setNum(settings.pwr);
+                             macro.replace ( indexvon, tokenList.at(11).length(),pwr);
+                            }
                           else  // Must be File
                           {
                             macro.remove ( indexvon, Token.length() );
@@ -911,12 +941,10 @@ void LinPSK::read_config()
   config.endGroup();
   /** DemoMode **/
   settings.DemoMode = config.value ( "DemoMode" ).toBool();
-  settings.DemoTypeNumber = config.value ( "DemoTypeNumber" ).toInt();
 //Operating
   settings.callsign = config.value ( "Callsign" ).toString();
   settings.myLocator = config.value ( "MyLocator" ).toString();
 
-  settings.SerialDevice = config.value ( "PTTDevice" ).toString();
 //Logging
   settings.Directory = config.value ( "Directory", QDir::homePath() ).toString();
 
@@ -964,13 +992,47 @@ void LinPSK::read_config()
         }
     }
     config.endArray();
+// Bandlist
+    size = config.beginReadArray ("Bandlist");
 
+    if(size >0)
+      {
+        Band band;
+        for(i=0;i < size;i++)
+          {
+            config.setArrayIndex ( i );
+            band.bandName = config.value ( "Bandname" ).toString();
+            band.bandStart = config.value ( "Bandstart",1).toInt();
+            band.bandEnd = config.value ( "Bandend",1).toInt();
+            band.preferedFreq = config.value ( "PreferedFrequency",1).toInt();
+            settings.bandList.append(band);
+          }
+      }
+     else
+      {
+        Band none;
+        none.bandName   = "--";
+        none.bandStart  = 0;
+        none.bandEnd    = 60000000;
+        none.preferedFreq=0;
+        settings.bandList.append(none);
+      }
+     config.endArray();
 
  if ( ( HeighttoSet > 0 ) && ( WidthtoSet > 0 ) )
     resize ( WidthtoSet, HeighttoSet );
  if ( ( X >= 0 ) && ( Y >= 0 ) )
     move ( X, Y );
  // SoundDevices
+ // Rig parameter for use with hamlib
+   config.beginGroup ( "Rigparameter" );
+   settings.SerialDevice = config.value ( "PTTDevice" ).toString();
+   settings.rigDevice = config.value( "RIGDevice").toString();
+   settings.rigModelNumber = config.value("Modelnr",0).toInt();
+   settings.baudrate = config.value("BaudRate",9600).toInt();
+   settings.handshake= config.value("Handshake",1).toInt();
+   config.endGroup();
+
   config .beginGroup("SoundDevices");
   settings.InputDeviceName=config.value("InputDeviceName","LinPSK_Record").toString();
   settings.sampleRate=config.value("sampleRate",11025).toInt();
@@ -978,21 +1040,47 @@ void LinPSK::read_config()
   settings.complexFormat=config.value("ComplexFormat").toBool();
   config.endGroup();
 }
-void LinPSK::selectPTTDevice()
+void LinPSK::checkControlDevices()
 {
+  int  err = 0;
   settings.serial = -1;
+  int flags = TIOCM_RTS | TIOCM_DTR;
+
   if ( settings.SerialDevice != "None" )
   {
-    int flags = TIOCM_RTS | TIOCM_DTR;
-    settings.serial = open ( settings.SerialDevice.toLatin1().data(), O_EXCL | O_WRONLY );
+    settings.serial = open( settings.SerialDevice.toLatin1().data(), O_EXCL | O_WRONLY );
     if ( settings.serial > 0 )
-      ioctl ( settings.serial, TIOCMBIC, &flags );
-    else
+      err=ioctl ( settings.serial, TIOCMBIC, &flags );
+    if( (settings.serial <0) || (err < 0 ))
     {
-      QMessageBox::critical ( 0, "LinPsk", "Unable to open Device " + settings.SerialDevice+"\nCheck permission of device" );
+      QMessageBox::critical ( 0, "LinPsk", "Unable to open PTT device " + settings.SerialDevice+"\nCheck if device is available or permission of device" );
       settings.SerialDevice = "None"; //Their seems to be a wrong Value in the ConfigFile
+      settings.serial=-1;
     }
    }
+#ifdef WITH_HAMLIB
+
+  if( (settings.SerialDevice != "None") && (settings.SerialDevice == settings.rigDevice))
+    {
+      QMessageBox::critical ( 0, "LinPsk", "PTT device and device to control the rig must be different\nPlease change configuration" );
+      settings.SerialDevice = "None";
+      settings.rigDevice="None";
+      return;
+    }
+  if ( settings.rigDevice != "None")
+  {
+    int fd = open( settings.rigDevice.toLatin1().data(), O_EXCL | O_WRONLY );
+    if ( fd > 0 )
+      err=ioctl ( fd, TIOCMBIC, &flags );
+    if( (fd <0) || (err < 0 ))
+    {
+      QMessageBox::critical ( 0, "LinPsk", "Unable to open serial port to control  rig" + settings.rigDevice+"\nCheck if device is available or permission of device" );
+      settings.rigDevice = "None"; //Their seems to be a wrong Value in the ConfigFile
+    }
+    if(fd >0)
+      ::close(fd);
+   }
+#endif      
 }
 
 
@@ -1030,3 +1118,10 @@ void LinPSK::unblockMacros()
 {
  blockMacros=false;
 }
+void LinPSK::defineBandlist()
+{
+  DefineBandList *dF = new DefineBandList();
+  if (dF->exec() != 0 )
+    Control->initQsoData();
+  delete dF;
+}
diff --git a/gui/linpsk.h b/gui/linpsk.h
index 50fe2b7..8d6ef50 100644
--- a/gui/linpsk.h
+++ b/gui/linpsk.h
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          |FILENAME|  -  description
-                             -------------------
-    begin                : |DATE|
-    copyright            : (C) |YEAR| by |AUTHOR|
-    email                : |EMAIL|
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -42,7 +34,7 @@ class LinPSK : public QMainWindow, private Ui::LinPSK
     Q_OBJECT
 
 public:
-    LinPSK( QWidget* parent = 0,Qt::WindowFlags fl = 0);
+    LinPSK( QWidget* parent = 0);
     ~LinPSK();
 
 
@@ -91,6 +83,8 @@ protected slots:
   void actdeactMacros();
   /** Font Settings **/
   void FontSetup();
+  /** Define Bandlist **/
+  void defineBandlist();
   /** Save Settings **/
   void saveSettings();
   /** Closing this window **/
@@ -118,10 +112,10 @@ unsigned int Txcount;
 Input *Sound;
 /** To show messages in Statusbar */
 QLabel *msg;
-/** TxTimer **/
-///QTimer *TxTimer;
-
-void selectPTTDevice();
+#ifdef WITH_HAMLIB
+QLabel *rigInfo;
+#endif
+void checkControlDevices();
 
 /** To show date and time **/
 QLabel *datum;
@@ -133,6 +127,8 @@ QList<QColor> WindowColors;
 /** Macros **/
 QVector<Macro> macroList;
 QStringList tokenList;
+/** Digital modes */
+QStringList modeList;
 
 signals:
 void StartRx();
diff --git a/gui/linpsk.ui b/gui/linpsk.ui
index 2ce748c..6c074c4 100644
--- a/gui/linpsk.ui
+++ b/gui/linpsk.ui
@@ -163,6 +163,8 @@
     <addaction name="actionFont_settings"/>
     <addaction name="actionColor_settings"/>
     <addaction name="separator"/>
+    <addaction name="actionDefine_Bandlist"/>
+    <addaction name="separator"/>
     <addaction name="actionSave_settings"/>
    </widget>
    <widget class="QMenu" name="menuRxParams">
@@ -262,9 +264,9 @@
     <string>Activate/ deactivate Macro</string>
    </property>
   </action>
-  <action name="actionRestore_default_font">
+  <action name="actionDefine_Bandlist">
    <property name="text">
-    <string>Restore default font</string>
+    <string>Define Bandlist</string>
    </property>
   </action>
  </widget>
@@ -679,6 +681,22 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionDefine_Bandlist</sender>
+   <signal>triggered()</signal>
+   <receiver>LinPSK</receiver>
+   <slot>defineBandlist()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>320</x>
+     <y>239</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>fileOpen()</slot>
@@ -703,5 +721,6 @@
   <slot>startTx()</slot>
   <slot>actdeactMacros()</slot>
   <slot>stopTx()</slot>
+  <slot>defineBandlist()</slot>
  </slots>
 </ui>
diff --git a/gui/modemenu.cpp b/gui/modemenu.cpp
index 4ed4d13..dd0814c 100644
--- a/gui/modemenu.cpp
+++ b/gui/modemenu.cpp
@@ -23,17 +23,15 @@
 #include "parameter.h"
 #include "crxchannel.h"
 
+
 extern Parameter settings;
 
-ModeMenu::ModeMenu(QWidget* parent, Qt::WindowFlags fl)
+ModeMenu::ModeMenu(QStringList modeList, QWidget* parent, Qt::WindowFlags fl)
 : QDialog( parent, fl ), Ui::ModeMenu()
 {
-	setupUi(this);
-RxMode->insertItem(0,"BPSK");
-RxMode->insertItem(1,"QPSK");
-RxMode->insertItem(2,"RTTY");
-RxMode->insertItem(3,"MFSK16");
+  setupUi(this);
 
+RxMode->addItems(modeList);
 RxMode->setCurrentRow(settings.ActChannel->getModulationType() );
 connect(RxMode,SIGNAL(itemSelectionChanged ()),this,SLOT(changeView()));
 Stopbits=new QButtonGroup(this);
diff --git a/gui/modemenu.h b/gui/modemenu.h
index 47e0b9d..a4ab94a 100644
--- a/gui/modemenu.h
+++ b/gui/modemenu.h
@@ -22,6 +22,7 @@
 #define MODEMENU_H
 
 #include <QDialog>
+#include <QStringList>
 #include "ui_modemenu.h"
 #include "constants.h"
 
@@ -32,12 +33,12 @@ class ModeMenu : public QDialog, private Ui::ModeMenu
   Q_OBJECT
 
 public:
-  ModeMenu(QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  ModeMenu(QStringList modeList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
   ~ModeMenu();
-  /*$PUBLIC_FUNCTIONS$*/
-void setParameter(ExtraParameter Param);
-ExtraParameter getParameter();
-Mode selectedMode();
+  void setParameter(ExtraParameter Param);
+  ExtraParameter getParameter();
+  Mode selectedMode();
+
 public slots:
   /*$PUBLIC_SLOTS$*/
 
@@ -45,6 +46,7 @@ protected:
 
 QButtonGroup *Stopbits;
 QButtonGroup *Parity;
+QStringList modeList;
 protected slots:
 
 void changeView();
diff --git a/gui/qsodata.cpp b/gui/qsodata.cpp
index 121f1c5..bd7b442 100644
--- a/gui/qsodata.cpp
+++ b/gui/qsodata.cpp
@@ -24,6 +24,9 @@
 #include "crxchannel.h"
 #include "processlogdata.h"
 #include "constants.h"
+#ifdef WITH_HAMLIB
+#include "rigcontrol.h"
+#endif
 
 #include <QDateTime>
 #include <QFile>
@@ -38,6 +41,7 @@ extern Parameter settings;
 QSOData::QSOData ( QWidget* parent )
     : QGroupBox ( parent ), Ui::QSOData()
 {
+  int i;
   setupUi ( this );
   QRegExp rx ( "^[A-R][A-R][0-9][0-9][A-X][A-X]$" );
   validator = new QRegExpValidator ( rx, this );
@@ -51,7 +55,6 @@ QSOData::QSOData ( QWidget* parent )
     OpName->setText ( settings.QslData->OpName );
     Qth->setText ( settings.QslData->Qth );
     Loc->setText ( settings.QslData->Locator );
-    QsoFrequency->setCurrentIndex( settings.QslData->QsoFrequency );
     HisRST->setText ( settings.QslData->HisRST );
     MyRST->setText ( settings.QslData->MyRST );
     dokName->setText(settings.QslData->dokName);
@@ -61,6 +64,7 @@ QSOData::QSOData ( QWidget* parent )
   connect ( Clear, SIGNAL ( clicked() ), this, SLOT ( clear() ) );
   connect ( Qth, SIGNAL ( editingFinished () ), this, SLOT ( QTHchanged() ) );
   connect ( QsoFrequency, SIGNAL ( activated (int) ), this, SLOT ( frequencyChanged(int) ) );
+  connect ( txPwr,SIGNAL( valueChanged(int) ), this ,SLOT( pwrChanged(int) ) );
   connect ( MyRST, SIGNAL ( editingFinished () ), this, SLOT ( MyRSTchanged() ) );
   connect ( OpName, SIGNAL ( editingFinished () ), this, SLOT ( Namechanged() ) );
   connect ( Save, SIGNAL ( clicked() ), this, SLOT ( save() ) );
@@ -73,6 +77,13 @@ QSOData::QSOData ( QWidget* parent )
   connect ( RemoteCallsign, SIGNAL ( editingFinished ( ) ), this, SLOT ( sendRequest() ) );
   connect ( logBookCommunication, SIGNAL ( unabletoConnect() ), this , SLOT ( stopTrial() ) );
   connect ( logBookCommunication, SIGNAL ( answerAvailable() ), this, SLOT ( copyAnswer() ) );
+  //====== Control the rig ================================== //
+  for(i=0; i< settings.bandList.size(); i++)
+    QsoFrequency->addItem(settings.bandList.at(i).bandName);
+//  QsoFrequency->setCurrentIndex(findBand());
+
+//  txPwr->setValue(rigControl->get_pwr());
+
 }
 
 QSOData::~QSOData()
@@ -94,7 +105,11 @@ void QSOData::clear()
   settings.QslData->Qth = Qth->text();
   Loc->setText ( "" );
   settings.QslData->Locator = Loc->text();
-//QsoFrequency->setText ( "" );
+  QsoFrequency->setCurrentIndex(findBand());
+#ifdef WITH_HAMLIB
+  settings.pwr=settings.rig->get_pwr();
+  txPwr->setValue(settings.pwr);
+#endif
   settings.QslData->Locator = Loc->text();
   HisRST->setText ( "" );
   settings.QslData->HisRST = HisRST->text();
@@ -155,7 +170,10 @@ void QSOData::Locatorchanged()
 
 void QSOData::frequencyChanged(int index)
 {
-  settings.QslData->QsoFrequency = index;
+#ifdef WITH_HAMLIB
+  settings.rig->set_frequency(settings.bandList.at(index).preferedFreq);
+#endif
+  settings.QsoFrequency = index;
 }
 
 void QSOData::HisRSTchanged()
@@ -242,6 +260,11 @@ void QSOData::save()
     s = QString ( "<BAND:%1>%2\n" ).arg ( QsoFrequency->currentText().length() ).arg ( QsoFrequency->currentText() );
     saveString.append ( s );
   }
+  // TxPwr
+  int pwr=txPwr->value();
+  s.setNum(pwr);
+  s = QString ("<TX_PWR:%1>%2\n").arg(s.length()).arg(s);
+  saveString.append(s);
   if ( QsoDate->text() == "" )
   {
     s = QString ( "<QSO_DATE:8:d>%1\n" ).arg ( QDateTime::currentDateTime().toString ( "yyyyMMdd" ) );
@@ -275,10 +298,14 @@ void QSOData::save()
     switch ( settings.ActChannel->getModulationType() )
     {
       case QPSK:
-      case BPSK:
+        s.append( "6>QPSK31");
+        break;
+      case BPSK31:
         s.append ( "5>PSK31\n" );
         break;
-
+      case BPSK63:
+        s.append ( "5>PSK63\n" );
+        break;
       case RTTY:
         s.append ( "4>RTTY\n" );
         break;
@@ -335,7 +362,12 @@ void QSOData::save()
     saveString.append("N\n");
     saveString.append ( "<eor>\n" );
     if ( !logBookCommunication->isRunning() )
-      logBookCommunication->start();
+      {
+	logBookCommunication->start();
+#if QT_VERSION >= 0x050000
+        QThread::usleep(2000);
+#endif
+      }
 #ifndef QT_NO_DEBUG
     qDebug ( "Written to Logbook\n%s", qPrintable ( saveString ) );
 #endif
@@ -412,8 +444,6 @@ void QSOData::newChannel()
     Qth->setText ( settings.QslData->Qth );
     Loc->setText ( settings.QslData->Locator );
     Locatorchanged(); // Check Locator and set Color
-//    QsoFrequency->setCurrentIndex ( settings.QslData->QsoFrequency );
-    settings.QslData->QsoFrequency=QsoFrequency->currentIndex();
     HisRST->setText ( settings.QslData->HisRST );
     MyRST->setText ( settings.QslData->MyRST );
     QsoDate->setDate ( settings.QslData->QsoDate );
@@ -449,8 +479,14 @@ void QSOData::sendRequest()
   results[4] = continent;
   results[5] = worked;
   if ( !logBookCommunication->isRunning() )
-    logBookCommunication->start();
-  logBookCommunication->requestCallSign ( results, RemoteCallsign->text().toUpper() );
+    {
+      logBookCommunication->start();
+#if QT_VERSION >= 0x050000
+      QThread::usleep(2000);
+#endif
+    }
+  logBookCommunication->requestCallsign ( results, RemoteCallsign->text().toUpper() );
+
 }
 void QSOData::stopTrial()
 {
@@ -482,3 +518,34 @@ void QSOData::setAutoDate()
       QsoTime->show();
     }
 }
+void QSOData::pwrChanged(int p)
+{
+#ifdef WITH_HAMLIB
+  settings.rig->set_pwr(p);
+#endif
+  settings.pwr=p;
+}
+int QSOData::findBand()
+{
+#ifdef WITH_HAMLIB
+  int freq = settings.rig->get_frequency();
+  for(int i=0; i < settings.bandList.size();i++)
+    {
+      if( (settings.bandList.at(i).bandStart <= freq) && (settings.bandList.at(i).bandEnd >= freq))
+          return i;
+    }
+#endif
+  return settings.bandList.size()-1;
+}
+void QSOData::initQsoData()
+{
+  QsoFrequency->clear();
+  for(int i=0; i< settings.bandList.size(); i++)
+    QsoFrequency->addItem(settings.bandList.at(i).bandName);
+  QsoFrequency->setCurrentIndex(findBand());
+#ifdef WITH_HAMLIB
+  settings.pwr=settings.rig->get_pwr();
+#endif
+  txPwr->setValue(settings.pwr);
+
+}
diff --git a/gui/qsodata.h b/gui/qsodata.h
index 3fd35f3..9add4fd 100644
--- a/gui/qsodata.h
+++ b/gui/qsodata.h
@@ -28,6 +28,8 @@
 class QChar;
 class ProcessLogData;
 class QValidator;
+class RigControl;
+
 class QSOData : public QGroupBox, private Ui::QSOData
 {
   Q_OBJECT
@@ -42,6 +44,7 @@ public:
   ~QSOData();
   void enableSaveData();
   void setAutoDate();
+  void initQsoData();
 
 public slots:
   /*$PUBLIC_SLOTS$*/
@@ -62,7 +65,9 @@ public slots:
 
   void setQsoData(QsoData,QString);
   void newChannel();
+  void pwrChanged(int);
 
+signals:
 
 protected:
   coordinates loc2coordinates ( const QChar *l );
@@ -75,6 +80,9 @@ private:
   ProcessLogData *logBookCommunication;
   bool connectionError;
   QValidator *validator;
+
+  int findBand();
+
 };
 
 #endif
diff --git a/gui/qsodata.ui b/gui/qsodata.ui
index e648fb6..b661993 100644
--- a/gui/qsodata.ui
+++ b/gui/qsodata.ui
@@ -2185,58 +2185,34 @@
           <bool>false</bool>
          </property>
          <property name="currentIndex">
+          <number>-1</number>
+         </property>
+        </widget>
+       </item>
+       <item row="9" column="5">
+        <widget class="QLabel" name="label_5">
+         <property name="text">
+          <string>Power (Watt)</string>
+         </property>
+        </widget>
+       </item>
+       <item row="9" column="6">
+        <widget class="QSpinBox" name="txPwr">
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+         <property name="minimum">
+          <number>1</number>
+         </property>
+         <property name="maximum">
+          <number>100</number>
+         </property>
+         <property name="singleStep">
+          <number>5</number>
+         </property>
+         <property name="value">
           <number>5</number>
          </property>
-         <item>
-          <property name="text">
-           <string/>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>80m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>60m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>40m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>30m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>20m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>17m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>15m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>12m</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>10m</string>
-          </property>
-         </item>
         </widget>
        </item>
       </layout>
diff --git a/gui/renamemacro.cpp b/gui/renamemacro.cpp
index bf243b2..a80ed3a 100644
--- a/gui/renamemacro.cpp
+++ b/gui/renamemacro.cpp
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by volker, DL1KSV   *
- *   schroer at tux64   *
+ *   Copyright (C) 2007 - 2016 by Volker Schroer, DL1KSV                   *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -23,8 +22,8 @@
 #include "readonlystringlistmodel.h"
 #include <QMessageBox>
 
-RenameMacro::RenameMacro(QVector<Macro> *macroList,QWidget* parent, Qt::WindowFlags fl)
-  : QDialog( parent, fl ), ui(new Ui:: RenameMacro())
+RenameMacro::RenameMacro(QVector<Macro> *macroList,QWidget* parent)
+  : QDialog( parent), ui(new Ui:: RenameMacro())
 {
   ui->setupUi(this);
   mL = macroList;
diff --git a/gui/renamemacro.h b/gui/renamemacro.h
index f7b6346..af46ea3 100644
--- a/gui/renamemacro.h
+++ b/gui/renamemacro.h
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by volker, DL1KSV   *
- *   schroer at tux64   *
+ *   Copyright (C) 2007  -2016 by Volker Schroer, DL1KSV                   *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -36,7 +35,7 @@ class RenameMacro : public QDialog
   Q_OBJECT
 
 public:
-  RenameMacro(QVector<Macro> *macroList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
+  RenameMacro(QVector<Macro> *macroList,QWidget* parent = 0 );
   ~RenameMacro();
   int getMacroNumber();
 
diff --git a/gui/spectrumdisplay.cpp b/gui/spectrumdisplay.cpp
index 7398be6..e061359 100644
--- a/gui/spectrumdisplay.cpp
+++ b/gui/spectrumdisplay.cpp
@@ -29,12 +29,15 @@ extern Parameter settings;
 SpectrumDisplay::SpectrumDisplay ( QWidget* parent ) : QFrame ( parent ), Ui::SpectrumDisplay()
 {
   setupUi(this);
+  spectrumWindow->setDisplayRange(MinFreq->value(),MaxFreq->value());
   inputdata = 0;
   for(int i=0; i< fftsize;i++)
     smoothedfft[i]=0.;
   displayWidth=spectrumWindow->width()-2*spectrumWindow->frameWidth();
   connect(spectrumWindow,SIGNAL(frequencyChanged(double)),this ,SIGNAL(FrequencyChanged(double)));
   connect(waterfallWindow,SIGNAL(frequencyChanged(double)),this ,SIGNAL(FrequencyChanged(double)));
+  oldMinfreq=MinFreq->value();
+  oldMaxfreq=MaxFreq->value();
 }
 
 /*
@@ -42,7 +45,7 @@ SpectrumDisplay::SpectrumDisplay ( QWidget* parent ) : QFrame ( parent ), Ui::Sp
  */
 SpectrumDisplay::~SpectrumDisplay()
 {
-	// no need to delete child widgets, Qt does it all for us
+  // no need to delete child widgets, Qt does it all for us
 }
 
 void SpectrumDisplay::resizeEvent ( QResizeEvent * )
@@ -51,10 +54,10 @@ void SpectrumDisplay::resizeEvent ( QResizeEvent * )
     return;          // No data available
   displayWidth=spectrumWindow->width()-2*spectrumWindow->frameWidth();
   if(fftsize < displayWidth)
-  {
-    qDebug("+++ SpectrumDisplay: Spectrum array %d lower than displaywidth %d",fftsize,displayWidth);
-    return;
-  }
+    {
+      qDebug("+++ SpectrumDisplay: Spectrum array %d lower than displaywidth %d",fftsize,displayWidth);
+      return;
+    }
   translate();
   calcFFT();
   spectrumWindow->plotSpectrum(false,fftdata, MinFreq->value(),MaxFreq->value());
@@ -66,21 +69,21 @@ void SpectrumDisplay::calcFFT()
   int i;
   float x,gain;
   if ( inputdata == 0 )
-     return;          // No data available
+    return;          // No data available
   if( Smooth->isChecked())
     {
       for ( i = 0;i < displayWidth;i++ )
-      {
-        if(inputdata[xtranslate[i]]> 0.02)
-           x=log10 ( inputdata[xtranslate[i]])+2;
+        {
+          if(inputdata[xtranslate[i]]> 0.02)
+            x=log10 ( inputdata[xtranslate[i]])+2;
           else
-           x=0.;
-        gain=(1. - exp(-(0.2 * x)));
-        smoothedfft[i]=smoothedfft[i]*(1.-gain) + gain *x;
-        fftdata[i] = smoothedfft[i];
-      }
-     }
-   else
+            x=0.;
+          gain=(1. - exp(-(0.2 * x)));
+          smoothedfft[i]=smoothedfft[i]*(1.-gain) + gain *x;
+          fftdata[i] = smoothedfft[i];
+        }
+    }
+  else
     {
       for ( i = 0;i < displayWidth;i++ )
         {
@@ -96,49 +99,51 @@ void SpectrumDisplay::calcFFT()
 
 void SpectrumDisplay::translate ( void )
 {
-    int i, to, minfreq, maxfreq,tmp;
-	minfreq = MinFreq->value();
-	maxfreq = MaxFreq->value();
-    to = int ( maxfreq * fftsize *4/ settings.sampleRate );
-    for ( i = 0;i < displayWidth;i++ )
+  int i, to, minfreq, maxfreq,tmp;
+  minfreq = MinFreq->value();
+  maxfreq = MaxFreq->value();
+  to = int ( maxfreq * fftsize *2/ settings.sampleRate );
+  for ( i = 0;i < displayWidth;i++ )
     {
       tmp= ( ( ( maxfreq - minfreq ) * i * to / displayWidth ) + minfreq * to ) / maxfreq;
       if( tmp < fftsize)
         xtranslate[i] = tmp;
       else
-      {
-        qDebug("+++ SpectrumDisplay: translation array size %d lower than requested size %d",fftsize,tmp);
-        return;
-      }
+        {
+          qDebug("+++ SpectrumDisplay: translation array size %d lower than requested size %d",fftsize,tmp);
+          return;
+        }
     }
 }
 
 void SpectrumDisplay::startPlot ( double *x, bool overload )
 {
-	inputdata = x;
-    int tmp=spectrumWindow->width()-2*spectrumWindow->frameWidth();
-    if( tmp != displayWidth)
+  inputdata = x;
+  int tmp=spectrumWindow->width()-2*spectrumWindow->frameWidth();
+  if( (tmp != displayWidth) || (oldMinfreq != MinFreq->value()) || (oldMaxfreq != MaxFreq->value()))
     {
       displayWidth=tmp;
+      oldMinfreq=MinFreq->value();
+      oldMaxfreq=MaxFreq->value();
       translate();
     }
-	calcFFT();
-    spectrumWindow->plotSpectrum(overload,fftdata, MinFreq->value(),MaxFreq->value());
-    waterfallWindow->plotWaterfall(fftdata);
+  calcFFT();
+  spectrumWindow->plotSpectrum(overload,fftdata, oldMinfreq,oldMaxfreq);
+  waterfallWindow->plotWaterfall(fftdata);
 }
 
 void SpectrumDisplay::setnewFrequency ( int position )
 {
 
-	double freq;
-    freq = ( position * ( MaxFreq->value() - MinFreq->value() ) ) / displayWidth + MinFreq->value();
-	settings.ActChannel->setRxFrequency ( freq );
-	emit FrequencyChanged ( freq );
+  double freq;
+  freq = ( position * ( MaxFreq->value() - MinFreq->value() ) ) / displayWidth + MinFreq->value();
+  settings.ActChannel->setRxFrequency ( freq );
+  emit FrequencyChanged ( freq );
 }
 
 void SpectrumDisplay::setPhasePointer ( std::complex<float> *p )
 {
-   spectrumWindow->setPhasePointer(p);
+  spectrumWindow->setPhasePointer(p);
 }
 void SpectrumDisplay::setColorList(QList<QColor> *c)
 {
@@ -146,7 +151,7 @@ void SpectrumDisplay::setColorList(QList<QColor> *c)
 }
 QByteArray SpectrumDisplay::spectrumSplitterState() const
 {
-   return spectrumSplitter->saveState();
+  return spectrumSplitter->saveState();
 }
 void SpectrumDisplay::restoreSplitterState(const QByteArray & spectrumState)
 {
diff --git a/gui/spectrumdisplay.h b/gui/spectrumdisplay.h
index 1a589cb..270c51e 100644
--- a/gui/spectrumdisplay.h
+++ b/gui/spectrumdisplay.h
@@ -30,7 +30,8 @@ class QWidget;
 /**
   *@author Volker Schroer
   */
-const int fftsize=1024; // Check size to protect arrays
+//const int fftsize=1024; // Check size to protect arrays
+const int fftsize=2048; // Check size to protect arrays
 
 class SpectrumDisplay : public QFrame , private Ui::SpectrumDisplay
 {
diff --git a/gui/spectrumdisplay.ui b/gui/spectrumdisplay.ui
index 705a1fb..e7bf1db 100644
--- a/gui/spectrumdisplay.ui
+++ b/gui/spectrumdisplay.ui
@@ -20,15 +20,24 @@
    <enum>QFrame::Raised</enum>
   </property>
   <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>1</number>
+   </property>
+   <property name="topMargin">
+    <number>1</number>
+   </property>
+   <property name="rightMargin">
+    <number>1</number>
+   </property>
+   <property name="bottomMargin">
+    <number>1</number>
+   </property>
    <property name="horizontalSpacing">
     <number>1</number>
    </property>
    <property name="verticalSpacing">
     <number>2</number>
    </property>
-   <property name="margin">
-    <number>1</number>
-   </property>
    <item row="1" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
@@ -89,13 +98,13 @@
         <number>1400</number>
        </property>
        <property name="maximum">
-        <number>2500</number>
+        <number>3100</number>
        </property>
        <property name="singleStep">
         <number>100</number>
        </property>
        <property name="value">
-        <number>2500</number>
+        <number>2900</number>
        </property>
       </widget>
      </item>
diff --git a/linpsk.pro b/linpsk.pro
index 5731129..15a7e80 100644
--- a/linpsk.pro
+++ b/linpsk.pro
@@ -1,8 +1,23 @@
-CONFIG += warn_on debug_and_release \
+CONFIG += warn_on \
           qt \
          thread
+CONFIG += link_pkgconfig
+
+!packagesExist(fftw3) {
+error("LinPSK requires fftw3")
+}
+
+CONFIG(debug, debug|release) {
+message(Building Qt$$QT_VERSION debug version)
+QMAKE_CFLAGS_DEBUG += '-g3 -O0'
+QMAKE_CXXFLAGS_DEBUG += '-g3 -O0'
+} else {
+message(Building Qt$$QT_VERSION release)
+DEFINES += QT_NO_DEBUG
+}
+QT += network
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
-QT += network widgets
 
 TEMPLATE = app
 TARGET = linpsk
@@ -20,13 +35,25 @@ INCLUDEPATH += . src gui
 LIBS += -lasound -lfftw3
 
 
+packagesExist( hamlib ) {
+      message(LinPSK builds with hamlib)
+      LIBS +=$$system("pkg-config --libs hamlib")
+      DEFINES += WITH_HAMLIB
+      HEADERS +=src/rigcontrol.h
+      SOURCES +=src/rigcontrol.cpp
+}
+else {
+    message(LinPSK builds without hamlib)
+}
 # Input
+
 HEADERS += gui/activatemacros.h \
            gui/addmacro.h \
            gui/addrxwindow.h \
            gui/controlpanel.h \
            gui/crxdisplay.h \
            gui/ctxdisplay.h \
+           gui/definebandlist.h \
            gui/deletemacro.h \
            gui/editmacro.h \
            gui/generalsettings.h \
@@ -64,7 +91,6 @@ HEADERS += gui/activatemacros.h \
            src/parameter.h \
            src/processlogdata.h \
            src/pskmodulator.h \
-           src/psktable.h \
            src/qpskdemodulator.h \
            src/qpskmodulator.h \
            src/readonlystringlistmodel.h \
@@ -72,16 +98,18 @@ HEADERS += gui/activatemacros.h \
            src/rttymodulator.h \
            src/spectrumwindow.h \
            src/tabwidget.h \
-           src/textinput.h \
            src/viterbi.h \
            src/waterfallwindow.h \
-           src/waveinput.h
+           src/waveinput.h \
+           src/psk63demodulator.h \
+           src/psk63modulator.h
 FORMS += gui/activatemacros.ui \
          gui/addmacro.ui \
          gui/addrxwindow.ui \
          gui/controlpanel.ui \
          gui/crxdisplay.ui \
          gui/ctxdisplay.ui \
+         gui/definebandlist.ui \
          gui/deletemacro.ui \
          gui/editmacro.ui \
          gui/generalsettings.ui \
@@ -98,6 +126,7 @@ SOURCES += gui/activatemacros.cpp \
            gui/controlpanel.cpp \
            gui/crxdisplay.cpp \
            gui/ctxdisplay.cpp \
+           gui/definebandlist.cpp \
            gui/deletemacro.cpp \
            gui/editmacro.cpp \
            gui/generalsettings.cpp \
@@ -140,8 +169,14 @@ SOURCES += gui/activatemacros.cpp \
            src/rttymodulator.cpp \
            src/spectrumwindow.cpp \
            src/tabwidget.cpp \
-           src/textinput.cpp \
            src/viterbi.cpp \
            src/waterfallwindow.cpp \
-           src/waveinput.cpp
+           src/waveinput.cpp \
+           src/psk63demodulator.cpp \
+           src/psk63modulator.cpp
 RESOURCES += src/application.qrc
+
+DISTFILES += \
+    README \
+    ChangeLog \
+    COPYING
diff --git a/src/bpskdemodulator.cpp b/src/bpskdemodulator.cpp
index c9a89dc..718c297 100644
--- a/src/bpskdemodulator.cpp
+++ b/src/bpskdemodulator.cpp
@@ -16,6 +16,7 @@
  ***************************************************************************/
 
 #include "bpskdemodulator.h"
+#include "firfilter.h"
 
 BPskDemodulator::BPskDemodulator():CPskDemodulator()
 {
@@ -23,7 +24,12 @@ BPskDemodulator::BPskDemodulator():CPskDemodulator()
   ave2=1.0;
 
 }
-BPskDemodulator::~BPskDemodulator(){
+BPskDemodulator::~BPskDemodulator()
+{
+  if( downFilter )
+    delete downFilter;
+  if ( syncFilter )
+    delete syncFilter;
 }
 void BPskDemodulator::DecodeSymbol(double angle)
 
@@ -35,7 +41,8 @@ void BPskDemodulator::DecodeSymbol(double angle)
   CalcQuality(angle);
   bit = GetBPSKSymb();
 
-  if( (bit==0) && m_LastBitZero )	//if character delimiter
+//  if( (bit==0) && m_LastBitZero )	//if character delimiter
+    if( (!bit) && m_LastBitZero )	//if character delimiter
     {
       if(m_BitAcc != 0 )
         {
@@ -56,7 +63,8 @@ void BPskDemodulator::DecodeSymbol(double angle)
     {
       m_BitAcc <<= 1;
       m_BitAcc |= bit;
-      if(bit==0)
+//      if(bit==0)
+      if(!bit)
         m_LastBitZero = true;
       else
         m_LastBitZero = false;
@@ -83,21 +91,11 @@ bool BPskDemodulator::GetBPSKSymb()
   return (Phase_Vector.real()> 0.0);
 }
 
-//////////////////////////////////////////////////////////////////////
-// Calculate signal quality based on the statistics of the phase
-//	difference angle.  The more dispersion of the "0" and "180" degree
-//  phase shifts, the worse the signal quality.  This information is used
-//  to activate the squelch control.  If 20 consecutive "180" degree shifts
-//  occur, the squelch is forced on, and if 20 consecutive "0" degree
-//  shifts occur, the squelch is forced off quickly.
-//////////////////////////////////////////////////////////////////////
-
 void BPskDemodulator::CalcQuality(  double angle )
 {
 
   double temp;
 
-
   if ( fabs(angle) < M_PI_2)
     temp= angle;
   else
@@ -107,7 +105,6 @@ void BPskDemodulator::CalcQuality(  double angle )
       else
         temp = M_PI+ angle;
     }
-  m_QFreqError = -temp;
   temp = fabs(temp);
   m_DevAve =0.5 * ave1 + 0.45 * ave2 + 0.05 *temp;
   ave2=ave1;
@@ -116,3 +113,28 @@ void BPskDemodulator::CalcQuality(  double angle )
   m_DevAve = 100. -m_DevAve *63.67;
 
 }
+void BPskDemodulator::Init(double Fs ,int BlockSize)
+{
+  SampleRate = Fs;        //sample rate
+  NxSamples = BlockSize;  //size data input buffer
+  downFilter = new FIRFilter(PI2*31.25/Fs,79,ComplexData,10.);
+  syncFilter = new FIRFilter(PI2*31.25*18./Fs,79, ComplexData,5.);
+  downRate = 18;
+
+}
+double BPskDemodulator::calcFreqError(complex<double> s)
+{
+ double x,y;
+ complex<double> z;
+ if (abs(s) >1 )
+  z=s/abs(s);
+ else z=s;
+ x= z.real()*z.imag();
+ x /=5000.; // Adopt deviation to samplerate
+// x /=2.8016548; //Gain
+ y=x_loop_1+x +0.2861361823*y_loop_1;
+ x_loop_1=x;
+ y_loop_1=y;
+ return -y;
+
+}
diff --git a/src/bpskdemodulator.h b/src/bpskdemodulator.h
index 969c30e..7be0ce7 100644
--- a/src/bpskdemodulator.h
+++ b/src/bpskdemodulator.h
@@ -28,19 +28,20 @@
 
 class BPskDemodulator : public CPskDemodulator  {
 public: 
-	BPskDemodulator();
-	~BPskDemodulator();
+  BPskDemodulator();
+  ~BPskDemodulator();
+   void Init(double Fs ,int BlockSize);
 protected:	
 /** Decodes a BPSK Symbol */
-void DecodeSymbol( double);
 
-void CalcQuality(double);
+  void DecodeSymbol( double);
+
+  void CalcQuality(double);
+  double calcFreqError(complex<double> s);
 private:
-	bool GetBPSKSymb();
+  bool GetBPSKSymb();
   double ave1;
-	double ave2;
-
-
+  double ave2;
 };
 
 #endif
diff --git a/src/bpskmodulator.cpp b/src/bpskmodulator.cpp
index 1863479..0093658 100644
--- a/src/bpskmodulator.cpp
+++ b/src/bpskmodulator.cpp
@@ -1,83 +1,76 @@
 /***************************************************************************
-                          bpskmodulator.cpp  -  description
-                             -------------------
-    begin                : Mon Feb 24 2003
-    copyright            : (C) 2003 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
- *   The PSK part is based on WinPSK 1.0 by Moe Wheatly, AE4JY             *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
 #include "bpskmodulator.h"
 #include "constants.h"
+#include "parameter.h"
+#include "ctxbuffer.h"
+
+extern Parameter settings;
 
 #define SYM_NOCHANGE 0 //Stay the same phase
 #define SYM_P180 2  //Plus 180 deg
-#define SYM_OFF 4  //No output
-#define SYM_ON 5  //constant output
 
-BPSKModulator::BPSKModulator ( int FS, double freq, CTxBuffer *TxBuffer ) : PSKModulator ( FS, freq, TxBuffer )
-{
-}
-BPSKModulator::~BPSKModulator()
+
+BpskModulator::BpskModulator(int FS, double frequency, CTxBuffer *TxBuffer):PskModulator(FS,frequency,TxBuffer)
 {
 }
-char BPSKModulator::GetNextSymbol ( void )
+char BpskModulator::getNextSymbolBit()
 {
-  char symb;
-  int ch;
-  symb = m_Lastsymb;
-  if ( m_TxShiftReg == 0 )
-  {
-    if ( m_AddEndingZero ) // if is end of code
+  int bit;
+  if(txShiftRegister != 0)
     {
-      symb = SYM_P180;  // end with a zero
-      m_AddEndingZero = false;
+      if(txShiftRegister &0x8000)
+        bit=SYM_NOCHANGE;
+      else
+        bit=SYM_P180;
+      txShiftRegister <<=1;
+      if(txShiftRegister == 0)
+        addEndingZero=true;
     }
-    else
+  else
     {
-      ch = GetChar();   //get next character to xmit
-      if ( ch >= 0 ) //if is not a control code
+      if(addEndingZero)
       {
-        //get next VARICODE codeword to send
-        m_TxShiftReg = VARICODE_TABLE[ ch&0xFF ];
-        symb = SYM_P180; //Start with a zero
-      }
-      else     // is a control code
-      {
-        switch ( ch )
+        bit=SYM_P180;
+        addEndingZero=false;
+       }
+      else
         {
-          case TXON_CODE:
-            symb = SYM_ON;
-            break;
-          case TXTOG_CODE:
-            symb = SYM_P180;
-            break;
-          case TXOFF_CODE:
-            symb = SYM_OFF;
-            break;
+          int ch;
+          if((ch = getChar())>= 0)
+            {       // No controlcode
+              txShiftRegister = VARICODE_TABLE[ ch&0xFF ];
+              bit=SYM_P180; //Start with a zero
+             }
+          else
+            switch ( ch )
+            {
+              case TXON_CODE:
+              case TXTOG_CODE:    //Idle
+                bit = SYM_P180;
+                break;
+              case TXOFF_CODE:
+                bit = SYM_NOCHANGE;
+                break;
+            }
         }
-      }
     }
-  }
-  else   // is not end of code word so send next bit
-  {
-    if ( m_TxShiftReg&0x8000 )
-      symb = SYM_NOCHANGE;
-    else
-      symb = SYM_P180;
-    m_TxShiftReg = m_TxShiftReg << 1; //point to next bit
-    if ( m_TxShiftReg == 0 )  // if at end of codeword
-      m_AddEndingZero = true;  // need to send a zero nextime
-  }
-  m_Lastsymb = symb;
-  return symb;
-
+  return bit;
 }
diff --git a/src/bpskmodulator.h b/src/bpskmodulator.h
index 9d52714..090378c 100644
--- a/src/bpskmodulator.h
+++ b/src/bpskmodulator.h
@@ -1,18 +1,20 @@
 /***************************************************************************
-                          bpskmodulator.h  -  description
-                             -------------------
-    begin                : Mon Feb 24 2003
-    copyright            : (C) 2003 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
- *   The PSK part is based on WinPSK 1.0 by Moe Wheatley, AE4JY            *              
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
 #ifndef BPSKMODULATOR_H
@@ -20,17 +22,13 @@
 
 #include "pskmodulator.h"
 
-class CTxBuffer;
-/**
-  *@author Volker Schroer
-  */
+class BpskModulator : public PskModulator
+{
+public:
+  BpskModulator(int FS, double frequency, CTxBuffer *TxBuffer);
 
-class BPSKModulator : public PSKModulator
-  {
-public: 
-	BPSKModulator(int, double, CTxBuffer *);
-	~BPSKModulator();
-char GetNextSymbol(void);
+protected:
+  char getNextSymbolBit();
 };
 
-#endif
+#endif // BPSKMODULATOR_H
diff --git a/src/cdemodulator.cpp b/src/cdemodulator.cpp
index f3c9af7..d192517 100644
--- a/src/cdemodulator.cpp
+++ b/src/cdemodulator.cpp
@@ -18,9 +18,10 @@
 
 CDemodulator::CDemodulator()
 {
-UseAfc = Off;
-Squelch = true;
-Threshold= 50;
+  UseAfc = Off;
+  Squelch = true;
+  Threshold= 50;
+  OszFrequency = 0.0;
 }
 
 CDemodulator::~CDemodulator()
@@ -31,8 +32,15 @@ void CDemodulator::setAfcMode(AfcMode afc) { UseAfc=afc; }
 
 void CDemodulator::setRxFrequency(double freq)
 {
- if ( (freq > 200 ) && (freq < 3000 ) ) 
-  RxFrequency = freq;
+ if ( (freq > 200 ) && (freq < 3000 ) )
+  {
+    RxFrequency = freq;
+    OszFreqinc = freq*PI2/SampleRate;
+  }
+}
+complex<float> *CDemodulator::getPhasePointer()
+{
+  return NULL;
 }
 
 double CDemodulator::getRxFrequency(void)
@@ -58,10 +66,6 @@ bool CDemodulator::getSquelchState()
 {
 return Squelch;
 }
-std::complex<float> * CDemodulator::getPhasePointer()
-{
-return 0;
-}
 int CDemodulator::getThreshold()
 {
 return Threshold;
diff --git a/src/cdemodulator.h b/src/cdemodulator.h
index 6375d6f..9bacd17 100644
--- a/src/cdemodulator.h
+++ b/src/cdemodulator.h
@@ -17,10 +17,11 @@
 #ifndef CDEMODULATOR_H
 #define CDEMODULATOR_H
 
+using namespace std;
+#include "constants.h"
 #include <complex>
 #include <qobject.h>
-//#include <cstdio>
-#include "constants.h"
+
 /**Base class for all possible types of demodulators
   *@author Volker Schroer
   */
@@ -39,8 +40,8 @@ public:
  virtual double getRxFrequency(void);
  virtual double get2RxFrequency(void);
  /** Initialises something */
- virtual bool Init(double,int) = 0;
- virtual std::complex<float> * getPhasePointer();
+ virtual void Init(double,int) = 0;
+ virtual complex<float> *getPhasePointer();
  virtual int getSquelchValue() = 0;
  virtual AfcMode getAfcMode();
  virtual AfcMode AfcProperties() = 0;
diff --git a/src/cmodulator.cpp b/src/cmodulator.cpp
index ff36f69..b3da8a8 100644
--- a/src/cmodulator.cpp
+++ b/src/cmodulator.cpp
@@ -20,7 +20,7 @@ CModulator::CModulator(int FS,CTxBuffer *TxBuffer)
 {
 
 SampleRate=FS;
-Buffer=TxBuffer;
+transmitBuffer=TxBuffer;
 
 }
 CModulator::~CModulator()
diff --git a/src/cmodulator.h b/src/cmodulator.h
index 4873b19..82635ee 100644
--- a/src/cmodulator.h
+++ b/src/cmodulator.h
@@ -30,29 +30,29 @@ class CTxBuffer;
 
 class CModulator : public QObject
 {
-Q_OBJECT
+  Q_OBJECT
 public: 
-	CModulator(int FS,CTxBuffer *);
-	~CModulator();
-        virtual void setParameter(RxTxParameterType,void *);
+  CModulator(int FS,CTxBuffer *);
+  ~CModulator();
+  virtual void setParameter(RxTxParameterType,void *);
 
-/** Calculate the Signal to be fed into the soundcard */
-	virtual int CalcSignal(double *data,int BufferSize) = 0;
-/** data Pointer to the computed signal values
+  /** Calculate the Signal to be fed into the soundcard */
+  virtual int CalcSignal(double *data,int BufferSize) = 0;
+  /** data Pointer to the computed signal values
     Size of Buffer for the computed signal
-		returns Number of computed signal values  and -Number at the end of Transmission
+                returns Number of computed signal values  and -Number at the end of Transmission
   **/
 
 protected: // Protected attributes
   /** Samplerate of Soundcard */
   unsigned int SampleRate;
-	CTxBuffer *Buffer;
+  CTxBuffer *transmitBuffer;
 
 
 public slots:
 
 signals:
-void charSend(char);
+  void charSend(char);
 
 };
 
diff --git a/src/constants.h b/src/constants.h
index 7397860..4f02f6f 100644
--- a/src/constants.h
+++ b/src/constants.h
@@ -19,8 +19,8 @@
 #define CONSTANTS_H
 
 #include <math.h>                        // for some constants like PI
-#include <QString>
 #include <QDate>
+#include <QString>
 #include <QTime>
 
 enum BUTTONSTATUS // Status of RX/TX Button
@@ -48,11 +48,21 @@ SW            // Switching to RX
 
 #define Ts (.032+.000000)			// Ts == symbol period(correct for +/- .23%error)
 #define M_PI_3_2	(M_PI_2+M_PI)		// 3Pi/2
-#define M_PI_3_4  (M_PI_2+M_PI_4) // 3Pi/4
+#define M_PI_3_4        (M_PI_2+M_PI_4) // 3Pi/4
 #define M_PI_5_4	(M_PI + M_PI_4) // 5Pi/4
 #define M_PI_7_4	(M_PI + M_PI_2 + M_PI_4) // 7Pi/4
 
-enum Mode {BPSK=0,QPSK,RTTY,MFSK16};
+#define PHASE_DISPLAY_BUFFER_LENGTH 12
+struct Band {
+  QString bandName;
+  int bandStart;
+  int bandEnd;
+  int preferedFreq;
+};
+
+enum Mode {BPSK31=0,BPSK63,QPSK,RTTY,MFSK16};
+
+
 enum AfcMode {Off,Narrow,Wide};
 
 enum Paritaet {None,Even,Odd};
@@ -87,7 +97,6 @@ typedef struct
  QString OpName;
  QString Qth;
  QString Locator;
- int QsoFrequency; // Number of item in QCombobox
  QString HisRST;
  QString MyRST;
  QDate QsoDate;
diff --git a/src/cpskdemodulator.cpp b/src/cpskdemodulator.cpp
index 48246a8..ddfda41 100644
--- a/src/cpskdemodulator.cpp
+++ b/src/cpskdemodulator.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          cpskdemodulator.cpp  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -15,163 +7,73 @@
  *    based on the work of  Moe Wheatly, AE4JY                             *  
  ***************************************************************************/
 
+//#include <assert.h>
+//#include <math.h>
 #include "cpskdemodulator.h"
-#include "fircoeffs.h"
+#include "firfilter.h"
 #include "parameter.h"
 #include <cstdio>
 extern Parameter settings;
 
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
 CPskDemodulator::CPskDemodulator(): CDemodulator()
 {
-	m_pQue1 = NULL;
-	m_pQue2 = NULL;
-	m_pQue3 = NULL;
-	m_VaricodeDecTbl = NULL;
-        Phase= NULL;
-}
-
-CPskDemodulator::~CPskDemodulator()
-{
-	if(m_pQue1)
-		delete m_pQue1;
-	if(m_pQue2)
-		delete m_pQue2;
-	if(m_pQue3)
-		delete m_pQue3;
-	if(m_VaricodeDecTbl)
-		delete m_VaricodeDecTbl;
-        if(Phase )
-         delete Phase;
-
-}
-
-/////////////////////////////////////////////////////////////////
-//       Initialize PskDet buffers and pointers
-/////////////////////////////////////////////////////////////////
-bool CPskDemodulator::Init( double Fs, int BlockSize )
-{
-unsigned short int wTemp;
-int i;
-//circular delay lines.(data stays put and the pointers move)
- 
-	if( (m_pQue1 = new complex<double>[DEC3_LPFIR_LENGTH] ) == NULL)
-		return false;
-	if( (m_pQue2 = new complex<double>[DEC3_LPFIR_LENGTH] ) == NULL)
-		return false;
-	if( (m_pQue3 = new complex<double>[BITFIR_LENGTH] ) == NULL)
-		return false;
-	if( (	m_VaricodeDecTbl = new unsigned char[2048] )== NULL)
-		return false;
-    
-  if ( ( Phase = new complex<float>[228] ) == NULL )
-    return false;
-	for(int i=0; i<DEC3_LPFIR_LENGTH; i++)
-	{
-	// fill delay buffer with zero
-		m_pQue1[i] = complex<double>(0.0,0.0);
-	}
-	for(i=0; i<DEC3_LPFIR_LENGTH; i++)
-	{
-	// fill delay buffer with zero
-		m_pQue2[i] = complex<double>(0.0,0.0);
-
-	}
-	for( i=0; i<BITFIR_LENGTH; i++)
-	{
-	// fill delay buffer with zero
-		m_pQue3[i] = complex<double>(0.0,0.0);
-	}
-
-	for( int j=0; j<2048; j++)		//init inverse varicode lookup decoder table
-	{
-		m_VaricodeDecTbl[j] = 0;
-		for(int i=0; i<256;i++)
-
-		{
-			wTemp = VARICODE_TABLE[i];
-			wTemp >>= 4;
-			while( !(wTemp&1) )
-				wTemp >>= 1;
-			wTemp >>= 1;
-			if( wTemp == j)
-				m_VaricodeDecTbl[j] = (unsigned char)i;
-		}
-	}
-	m_pInPtr1 = m_pQue1;		//initialize que ptrs
-	m_pInPtr2 = m_pQue2;
-	m_pInPtr3 = m_pQue3;
-	SampleRate = Fs;					//sample rate
-	NxSamples = BlockSize;	//size data input buffer
-	OszFreqinc = 1000.0*PI2/SampleRate;
-	m_BitPhaseInc = 9.0/SampleRate;		//bit oversampling period
-	m_SignalLevel = 1.0;
-	m_BitPhasePos = 0.0;
-	m_BitAcc = 0;
-	m_LastBitZero = false;
-	m_SampCnt = 0;
-	m_OnCount = 0;
-	m_OffCount = 0;
-
- for (i=0;i< 228; i++)
-  Phase[i]=0.0;
- for( i=0; i<40; i++)
-  DelayLine[i] = 0.0;					// initialize the array
-
-
-// Init a bunch of "static" variables used in various member fuctions
-	m_AGCave = 0.0;
-	m_FreqError = 0.0;
-	OszFrequency = 0.0;
-	m_LastFreq = 1000.0;
-	m_PkPos = 0;
-	m_BitPos = 0;
+  int i,temp;
+  m_LastFreq = 1000.0;
+  m_BitPhasePos = 0.0;
   Prev_Sample=complex<double>(0.0,0.0) ;
-  Phase_Vector = Prev_Sample;  
-	m_DevAve = 0.78;
-	m_QFreqError = 0.0;
-	m_LastPkPos = 0;
-	m_ClkErrCounter = 0;
-	m_ClkErrTimer = 0;
-	m_ClkError = 0;
-// Initializing Variables for AFC
-fe0=0.0;
-fe1=0.0;
-fe2=0.0;
+  Phase_Vector = Prev_Sample;
+  m_DevAve = 0.78;
 // FastSquelch
-fastSquelch=false;
+  fastSquelch=false;
 // IMD
-IMD=0.0; // Means Unknown
- x_loop_1=0;
- y_loop_1=0;
-return true;
+  IMD=0.0; // Means Unknown
+  f1=15.625;
+  f2=46.875;
+  x_loop_1=0;
+  y_loop_1=0;
+
+  m_SampCnt = 0;
+  m_VaricodeDecTbl = NULL;
+  downFilter = NULL;
+  syncFilter = NULL;
+  for(i=0; i < 20; i++ )
+    syncBuf[i]=0;
+  m_VaricodeDecTbl = new unsigned char[2048];
+  for (i=0;i< PHASE_DISPLAY_BUFFER_LENGTH; i++)
+   Phase[i]=0.0;
+  phasePosition=0;
+  for(i=0; i < 2048;i++)
+    m_VaricodeDecTbl[i]=0;
+  for(i=0; i<256;i++)
+    {
+      temp = VARICODE_TABLE[i];
+      temp >>= 4;
+      while( !(temp&1) )
+         temp >>= 1;
+      temp >>= 1;
+      m_VaricodeDecTbl[temp] = (unsigned char)i;
+     }
+  m_BitAcc=0;
+  m_LastBitZero = false;
+  m_OnCount=0;
+  m_OffCount=0;
 }
 
-//////////////////////////////////////////////////////////////////////
-// Main routine called to process the next block of data 'pIn'.
-//  The center frequency is specified by 'Freq'.
-//  'UseAFC' specifies whether to automatically lock to the frequency.
-//  30mSec for BPSK, 38mSec for QPSK( 133MHz Pentium )
-//////////////////////////////////////////////////////////////////////
+CPskDemodulator::~CPskDemodulator()
+{
+  if(m_VaricodeDecTbl)
+    delete m_VaricodeDecTbl;
+}
 
 void CPskDemodulator::ProcessInput( double* pIn, double *Spectrum)
 {
 double vcophz = OszFrequency;
-int i,j;
+int i;
 complex<double> acc;
-const double* Kptr;
-complex<double>* Firptr;
-complex<double>* Inptr1;			//decimation FIR #1 variables
-complex<double>* Qptr1;
-complex<double>* Inptr2;			//decimation FIR #2 variables
-complex<double>* Qptr2;
 
 if ( UseAfc == Wide )
  { 
-// Check if we are near the center frequency in Spectrum
+// Check if we are near the centerphasePosition frequency in Spectrum
   int index;
   index=(int) (RxFrequency/2.69165);
   double smooth[15],xx;
@@ -198,63 +100,33 @@ if ( UseAfc == Wide )
           RxFrequency += 1.5;
     }
 
- m_DispTrig = false;
- j=0;
  if( RxFrequency != m_LastFreq )	//caller is changing center frequency
  {
   OszFreqinc = (PI2/SampleRate)*RxFrequency;	//new center freq inc
   m_LastFreq = RxFrequency;
  }
- Inptr1 = m_pInPtr1;		//use local copies of member variables
- Qptr1 = m_pQue1;		// for better speed.
- Inptr2 = m_pInPtr2;
- Qptr2 = m_pQue2;
  for( i = 0; i<NxSamples; i++ )	// put new samples into Queue
  {
-  if( --Inptr1 < Qptr1 )		//deal with FIR pointer wrap around
-   Inptr1 = Qptr1+DEC3_LPFIR_LENGTH-1;
 //Generate complex sample by mixing input sample with NCO's sin/cos
   vcophz = vcophz + OszFreqinc;
   if(vcophz > PI2)		//handle 2 Pi wrap around
    vcophz -= PI2;
-  *Inptr1=pIn[i]*complex<double>(cos(vcophz),sin(vcophz));
-//decimate by 3 filter
-  if( ( (++m_SampCnt)%3 ) == 0 )	//calc first decimation filter every 3 samples
-  {
-   acc=complex<double>(0.0,0.0);
-   Firptr = Inptr1;
-   Kptr = Dec3LPCoef;
-   while( Kptr < (Dec3LPCoef + DEC3_LPFIR_LENGTH) )	//do the MAC's
-   {
-    acc +=(*Firptr)*(*Kptr++);
-    if( (++Firptr) >= Qptr1+DEC3_LPFIR_LENGTH ) //deal with wraparound
-     Firptr = Qptr1;
-   }
-   if( --Inptr2 < Qptr2 )		//deal with FIR pointer wrap around
-    Inptr2 = Qptr2+DEC3_LPFIR_LENGTH-1;
-   *Inptr2=acc;
-//decimate by 3 filter
-  if( (m_SampCnt%9) == 0 )	//calc second decimation filter every 9 samples
-  {
-   acc=complex<double>(0.0,0.0);
-   Firptr = Inptr2;
-   Kptr = Dec3LPCoef;
-   while( Kptr < (Dec3LPCoef + DEC3_LPFIR_LENGTH) )	//do the MAC's
-   {
-    acc +=(*Firptr)*(*Kptr);
-    Kptr++;
-    if( (++Firptr) >= Qptr2+DEC3_LPFIR_LENGTH ) //deal with wraparound
-    Firptr = Qptr2;
-   }
-// here at Fs/9 = 612.5 Hz rate with latest sample in acc.
-// Matched Filter the I and Q data and also a frequency error filter
-// filter puts filtered signals in m_FreqSignal and m_BitSignal.
-  CalcBitFilter( acc );
-   if( SymbSync(m_BitSignal) )	
-   {
-    Phase_Vector=m_BitSignal*conj(Prev_Sample);
-    Prev_Sample = m_BitSignal;
-    Phase[j++]=Phase_Vector;
+  complex<double> xxx =pIn[i]*complex<double>(cos(vcophz),sin(vcophz));
+//  assert(isnan(xxx.real()) == 0);
+  downFilter->processFilter(&xxx,&acc,1);
+//  assert(isnan(acc.real()) == 0);
+  m_SampCnt++;
+  if( (m_SampCnt%downRate) == 0)
+    {
+      syncFilter->processFilter(&acc,&xxx,1);
+//      assert(isnan(xxx.real()) ==0);
+      if( symbSync(xxx))
+      {
+    Phase_Vector=xxx *conj(Prev_Sample);
+    Prev_Sample = xxx;
+    Phase[phasePosition++]=Phase_Vector;
+    if(phasePosition >=PHASE_DISPLAY_BUFFER_LENGTH)
+      phasePosition=0;
     double angle =  atan2(Phase_Vector.imag(),Phase_Vector.real());
     DecodeSymbol( angle);
     if ( (unsigned int) m_DevAve  > Threshold)
@@ -265,14 +137,11 @@ if ( UseAfc == Wide )
     else
      IMD =0.0;
     if( UseAfc != Off )
-     OszFreqinc +=CalcFreqError(Phase_Vector);
+     OszFreqinc +=calcFreqError(Phase_Vector);
     }
    }
   }
- }
  m_SampCnt = m_SampCnt%9;
- m_pInPtr1 = Inptr1;		// save position in circular delay line
- m_pInPtr2 = Inptr2;		// save position in circular delay line
  OszFrequency = vcophz;
 
  if (UseAfc != Off)			// Change RxFrequency, but slowly
@@ -284,145 +153,6 @@ if ( UseAfc == Wide )
 }
 
 
-//////////////////////////////////////////////////////////////////////
-// Called at Fs/9 rate to calculate the symbol sync position
-// Returns true if at center of symbol.
-// Sums up the energy at each sample time, averages it, and picks the
-//   sample time with the highest energy content.
-//////////////////////////////////////////////////////////////////////
-
-bool CPskDemodulator::SymbSync(complex<double> sample)
-
-{
- bool Trigger;
- int BitPos = m_BitPos;
- Trigger=false;
- DelayLine[BitPos]=sample;
- m_BitPhasePos += m_BitPhaseInc;
- if( m_BitPhasePos >= Ts )
- {					// here every symbol time
-  m_BitPhasePos -= Ts;
-  float x,y,maxsample;
-  int kk;
-  x=0;
-  maxsample=-1;
-  for(int i=0; i <10;i++)
-  {
-   kk= BitPos-i-10;
-   if (kk < 0)
-    kk += 40;
-   y= abs(DelayLine[kk]);
-   maxsample=max(maxsample,y);
-   x += y;
-   kk = BitPos-i;
-   if (kk < 0)
-    kk += 40;
-   y = abs(DelayLine[kk]);
-   maxsample=max(maxsample,y);
-   x -= y;
-  }
-   maxsample = 3.* maxsample;
-   if ( x < -maxsample )
-    m_BitPhasePos += m_BitPhaseInc;
-   else if ( x > maxsample)
-    m_BitPhasePos -= m_BitPhaseInc;
-  
-  Trigger=true;
- }
- BitPos++;
- if ( BitPos >= 40 )
-  BitPos=0;
- m_BitPos=BitPos;
- return Trigger;
-}
-
-
-//////////////////////////////////////////////////////////////////////
-//  Frequency error calculator
-//////////////////////////////////////////////////////////////////////
-double CPskDemodulator::CalcFreqError(complex<double> s)
-{
- double x,y;
- complex<double> z;
- if (abs(s) >1 )
-  z=s/abs(s);
- else z=s;
- x= z.real()*z.imag();
- x /=10000.; // Adopt deviation to samplerate
-// x /=2.8016548; //Gain
- y=x_loop_1+x +0.2861361823*y_loop_1;
- x_loop_1=x;
- y_loop_1=y;
- return -y;
-
-}
-
-//////////////////////////////////////////////////////////////////////
-// Automatic gain control calculator
-//////////////////////////////////////////////////////////////////////
-double CPskDemodulator::CalcAGC( complex<double> Samp)
-{
-double mag;
-
-  mag = abs(Samp);
-	if( mag > m_AGCave )
-
-		m_AGCave = (1.0-1.0/250.0)*m_AGCave + (1.0/250.0)*mag;
-	else
-		m_AGCave = (1.0-1.0/1000.0)*m_AGCave + (1.0/1000.0)*mag;
-	if( m_AGCave >= 1.0 )	// divide signal by ave if not almost zero
-	{
-		m_BitSignal /= m_AGCave;
-//		m_BitSignal.y /= m_AGCave;
-		m_FreqSignal /= m_AGCave;
-//		m_FreqSignal.y /= m_AGCave;
-	}
-	return(m_AGCave);
-}
-
-
-//////////////////////////////////////////////////////////////////////
-// BIT FIR filters. A narrow matched(?) data filter for data
-//                  and wider filter for the AFC/AGC functions
-//////////////////////////////////////////////////////////////////////
-void CPskDemodulator::CalcBitFilter(complex<double> Samp)
-{
-complex<double> acc1;
-complex<double> acc2;
-const double* Kptr1;
-const double* Kptr2;
-complex<double>* Firptr;
-complex<double>* Qptr;
-complex<double>* Inptr;
-	Inptr = m_pInPtr3;		//use local copies of member variables
-	Qptr = m_pQue3;			// for better speed.
-	if( --Inptr < Qptr )	//deal with LPFIR pointer wrap around
-		Inptr = Qptr+BITFIR_LENGTH-1;
-//	Inptr->x = Samp.x;	//place in circular Queue
-	*Inptr = Samp;
-//	acc1.x = 0.0;
-	acc1 = complex<double>(0.0,0.0);
-//	acc2.x = 0.0;
-	acc2 = complex<double>(0.0,0.0);
-	Firptr = Inptr;
-	Kptr1 = FreqFirCoef;	//frequency error filter
-	Kptr2 = BitFirCoef;	//bit data filter
-	while( Kptr2 < (BitFirCoef + BITFIR_LENGTH) )	//do the MAC's
-	{
-//		acc1.x += ( (Firptr->x)*(*Kptr1) );
-		acc1 += ( (*Firptr)*(*Kptr1++) );
-						
-//		acc2.x += ( (Firptr->x)*(*Kptr2) );
-		acc2 += ( (*Firptr)*(*Kptr2++) );
-						
-		if( (++Firptr) >= (Qptr+BITFIR_LENGTH) ) //deal with wraparound
-			Firptr = Qptr;
-	}
-	m_pInPtr3 = Inptr;		// save position in circular delay line
-	m_FreqSignal = acc1;
-	m_BitSignal = acc2;
-}
-
 complex<float> * CPskDemodulator::getPhasePointer()
 {
 return  Phase;
@@ -436,11 +166,11 @@ void CPskDemodulator::calcIMD(double *Spectrum)
 {
 int freq1,freq2;
 
-freq1 = (int) ((RxFrequency+15.625)/2.69165);  
-freq2 = (int) ((RxFrequency+46.875)/2.69165);
+freq1 = (int) ((RxFrequency+f1)/2.69165);
+freq2 = (int) ((RxFrequency+f2)/2.69165);
 IMD=(Spectrum[freq2-1]+Spectrum[freq2]+Spectrum[freq2+1])/(Spectrum[freq1-1]+Spectrum[freq1]+Spectrum[freq1+1]);
-freq1=(int) ( (RxFrequency- 15.625)/2.69165);
-freq2=(int) ( (RxFrequency- 46.875)/2.69165);
+freq1=(int) ( (RxFrequency- f1)/2.69165);
+freq2=(int) ( (RxFrequency- f2)/2.69165);
 IMD = 10.*log10( (IMD + (Spectrum[freq2-1]+Spectrum[freq2]+Spectrum[freq2+1])/(Spectrum[freq1-1]+Spectrum[freq1]+Spectrum[freq1+1]))/2);
 
 }
@@ -452,3 +182,37 @@ AfcMode CPskDemodulator::AfcProperties()
 {
 return Wide;
 }
+
+bool CPskDemodulator::symbSync(complex<double> sample)
+{
+  bool trigger;
+  double sum,ampsum;
+  trigger =false;
+
+  int index = (int) m_BitPhasePos;
+//  assert((index >= 0) && (index <20));
+  syncBuf[index] = 0.7 * syncBuf[index] + 0.3 * abs(sample);
+//  syncBuf[index] = abs(sample);
+  sum=0;
+  ampsum=0;
+  index = SYNCBUFFERLENGTH/2;
+  for(int i=0; i <index; i++)
+    {
+      sum += (syncBuf[i] - syncBuf[index+i]);
+      ampsum +=(syncBuf[i] + syncBuf[index+i]);
+    }
+  sum = (ampsum == 0 ? 0 : sum / ampsum);
+  m_BitPhasePos -= sum/5.0;
+  m_BitPhasePos +=1.01;
+  if( m_BitPhasePos >=SYNCBUFFERLENGTH)
+    {
+      m_BitPhasePos -=SYNCBUFFERLENGTH;
+      trigger =  true;
+    }
+  else if(m_BitPhasePos < 0.)
+    m_BitPhasePos +=SYNCBUFFERLENGTH;
+
+  return trigger;
+}
+
+
diff --git a/src/cpskdemodulator.h b/src/cpskdemodulator.h
index 516d8e4..545c9e8 100644
--- a/src/cpskdemodulator.h
+++ b/src/cpskdemodulator.h
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          cpskdemodulator.h  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -27,6 +19,9 @@ using namespace std;
 
 #include "cdemodulator.h"
 
+#define SYNCBUFFERLENGTH 20 // Just small oversample
+
+class FIRFilter;
 
 class CPskDemodulator  : public CDemodulator
 {
@@ -34,7 +29,7 @@ class CPskDemodulator  : public CDemodulator
 public:
  CPskDemodulator();
  virtual ~CPskDemodulator();
- bool Init(double Fs ,int BlockSize);
+
  int getSquelchValue();
  void ProcessInput( double *pIn, double *Spectrum);
  complex<float> * getPhasePointer();
@@ -42,73 +37,54 @@ public:
  AfcMode AfcProperties();
 	
 protected:
-
 // Methods
 /** Decodes the symbol depending on the PskModes */	
  virtual void DecodeSymbol( double) = 0;
 /** Calculates the Cuality of the signal -- depends on the mode */	
 	virtual	void CalcQuality( double angle ) = 0;	
 	
-// Variables		
+// Variables
+  double m_LastFreq;
   complex<double> Prev_Sample;
   complex<double> Phase_Vector;
-	int m_BitAcc;
-	bool m_LastBitZero;
-	unsigned char* m_VaricodeDecTbl;
-	int m_OnCount;
-	int m_OffCount;	
-	double m_FreqError;
-	double m_QFreqError;
+
+  bool m_LastBitZero;
+  int m_BitAcc;
+  int m_OnCount;
+  int m_OffCount;
+
+  unsigned char* m_VaricodeDecTbl;
 
   double m_DevAve;
 
   bool fastSquelch;
+  FIRFilter *downFilter;
+  int downRate;
+  FIRFilter *syncFilter;
+  float f1,f2;
+  virtual double calcFreqError(complex<double>) =0;
+
+/** Some Variable for CalcQuality */
+  double x_loop_1,y_loop_1;
+
 private:
-	int m_ClkErrTimer;
-	int m_ClkErrCounter;
-	int m_ClkError;
 
-//methods
+  bool symbSync( complex<double> sample);
 
 
-	bool SymbSync(complex<double> );
-	void CalcBitFilter(  complex<double>);
-	double CalcAGC( complex<double> );
-	double CalcFreqError(complex<double>);
   void calcIMD(double *Spectrum);  
 //variables
-	double m_QPSKprob[4];
-	int m_LastPkPos;
-	int m_SampCnt;
-	bool m_DispTrig;
-	float m_BitPhaseInc;
-	float m_BitPhasePos;
-//	float m_SyncAve[21];
-        complex<float> DelayLine[40];
-	float m_SignalLevel;
-
-	complex<double>* m_pQue1;
-	complex<double>* m_pQue2;
-	complex<double>* m_pQue3;
-	complex<double>* m_pInPtr1;
-	complex<double>* m_pInPtr2;
-	complex<double>* m_pInPtr3;
-
-	complex<double> m_FreqSignal;
-	complex<double> m_BitSignal;
+
+  int m_SampCnt;
+
 // Phase Values
-  complex<float> * Phase;
-// Local variables for various functions that need to be saved between calls
-	double m_AGCave;
-	double m_LastFreq;
-	int	m_PkPos;
-	int m_BitPos;
-float IMD;
+  complex<float> Phase[PHASE_DISPLAY_BUFFER_LENGTH];
+  int phasePosition; // Position in phase display buffer
 
-/** Some Variable for CalcQuality */
+  double syncBuf[SYNCBUFFERLENGTH]; //  samples per symbol
+  float m_BitPhasePos;
 
-double fe0,fe1,fe2;
-double x_loop_1,y_loop_1;
+  float IMD;
 
 public slots:
 signals: // Signals
diff --git a/src/crxchannel.cpp b/src/crxchannel.cpp
index cef2586..88e1c78 100644
--- a/src/crxchannel.cpp
+++ b/src/crxchannel.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          crxchannel.cpp  -  description
-                             -------------------
-    begin                : Sam Jan 4 2003
-    copyright            : (C) 2003 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -21,6 +13,7 @@
 #include "crxwindow.h"
 #include "qpskdemodulator.h"
 #include "bpskdemodulator.h"
+#include "psk63demodulator.h"
 #include "rttydemodulator.h"
 #include "mfskdemodulator.h"
 #include "parameter.h"
@@ -43,6 +36,8 @@ CRxChannel::CRxChannel ( int ID, QWidget *parent, Mode DemodulatorType, unsigned
   {
     case QPSK:
       Demodulator = new QPskDemodulator();
+      SampleRate = 11025;
+      BufferLength = BUF_SIZE;
       break;
     case RTTY:
       Demodulator = new RTTYDemodulator();
@@ -54,13 +49,22 @@ CRxChannel::CRxChannel ( int ID, QWidget *parent, Mode DemodulatorType, unsigned
       SampleRate = 11025;
       BufferLength = BUF_SIZE;
       break;
-
-    default:
+    case BPSK63:
+      Demodulator = new PSk63Demodulator();
+      SampleRate = 11025;
+      BufferLength = BUF_SIZE;
+      break;
+    case BPSK31:
       Demodulator = new BPskDemodulator();
+      SampleRate = 11025;
+      BufferLength = BUF_SIZE;
       break;
+/**    default:
+      Demodulator = new BPskDemodulator();
+      break;*/
   }
   Demodulator->Init ( SampleRate, BufferLength ); // Should changed later to
-  // adjusted Samplerate
+                                                  // adjusted Samplerate
   Demodulator->setRxFrequency ( double ( Freq ) );
   Demodulator->setAfcMode ( Demodulator->AfcProperties() );
   RxWindow = new CRxWindow ( parent );
@@ -75,7 +79,6 @@ CRxChannel::CRxChannel ( int ID, QWidget *parent, Mode DemodulatorType, unsigned
 
   QsoData.QsoDate= t.date() ;
   QsoData.QsoTime= t1.time();
-  QsoData.QsoFrequency=5;
 }
 CRxChannel::~CRxChannel()
 {
@@ -169,10 +172,7 @@ void CRxChannel::setPrevChannel ( CRxChannel *p )
 
 complex<float>* CRxChannel::getPhasePointer()
 {
-  if ( ( RxMode == BPSK ) || ( RxMode == QPSK ) )
-    return Demodulator->getPhasePointer();
-  else
-    return 0;
+  return Demodulator->getPhasePointer();
 }
 
 int CRxChannel::getID()
@@ -244,6 +244,8 @@ void CRxChannel::setMode ( Mode DemodulatorType )
     {
       case QPSK:
         Demodulator = new QPskDemodulator();
+        SampleRate = 11025;
+        BufferLength = BUF_SIZE;
         break;
       case RTTY:
         Demodulator = new RTTYDemodulator();
@@ -257,9 +259,21 @@ void CRxChannel::setMode ( Mode DemodulatorType )
         BufferLength = BUF_SIZE;
         break;
 
-      default:
+      case BPSK63:
+        Demodulator = new PSk63Demodulator();
+        SampleRate = 11025;
+        BufferLength = BUF_SIZE;
+        break;
+
+      case BPSK31:
         Demodulator = new BPskDemodulator();
+        SampleRate = 11025;
+        BufferLength = BUF_SIZE;
         break;
+
+/**      default:
+        Demodulator = new BPskDemodulator();
+        break; */
     }
     RxMode = DemodulatorType;
     Demodulator->Init ( SampleRate, BufferLength ); // Should changed later to
diff --git a/src/crxchannel.h b/src/crxchannel.h
index 4408c94..c79dc88 100644
--- a/src/crxchannel.h
+++ b/src/crxchannel.h
@@ -33,7 +33,7 @@ class CRxChannel : public QObject
  {
  Q_OBJECT
 public: 
-	CRxChannel(int ID,QWidget* parent=0,Mode DemodulatorType= BPSK,unsigned int Freq=1000);
+        CRxChannel(int ID,QWidget* parent=0,Mode DemodulatorType= BPSK31,unsigned int Freq=1000);
 virtual ~CRxChannel();
   void insertChannel(CRxChannel * );
   void setPrevChannel(CRxChannel *);
diff --git a/src/crxwindow.cpp b/src/crxwindow.cpp
index 9d18715..7f7ba57 100644
--- a/src/crxwindow.cpp
+++ b/src/crxwindow.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          crxwindow.cpp  -  description
-                             -------------------
-    begin                : Mon Mar 6 2000
-    copyright            : (C) 2000 by Volker Schroer
-    email                : DL1KSV at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -72,7 +64,6 @@ CRxWindow::CRxWindow ( QWidget* parent )
     linesLayout->addWidget(ScrollBuffer[i]);
     ScrollBuffer[i]->setContextMenuPolicy ( Qt::NoContextMenu );
   }
-  DisplayLineHeight = ScrollBuffer[0]->height()-1;
   setBackgroundRole ( ScrollBuffer[0]->backgroundRole() );
   menu = new QMenu ( tr ( "Log value" ), DisplayBox );
   QAction *A = menu->addAction ( tr ( "Callsign" ) );
@@ -266,7 +257,23 @@ void CRxWindow::contextMenu ( QPoint p )
   int selectedLine, selectedColumn;
   char c = 0xF8;
   QPoint p1 = QCursor::pos();
-  selectedLine = (p.y()-3) / DisplayLineHeight;
+//  selectedLine = (p.y()-3) / (ScrollBuffer[0]->height()-1);
+  selectedLine = p.y() / ScrollBuffer[0]->height();
+
+#ifndef QT_NO_DEBUG
+  qDebug("Line %d selected, lineheight, %d ",selectedLine,ScrollBuffer[0]->height());
+  qDebug("*****Cursor: x: %i y: %i",p.x(),p.y());
+  int start;
+  start=selectedLine-4;
+  if(start <0)
+    start=0;
+  for(int i=start;i <=selectedLine;i++)
+    {
+      qDebug("Zeile: %i, %s",i,qPrintable(ScrollBuffer[i]->text()));
+    }
+  qDebug("***Menuposition x: %i y: %i",p1.x(),p1.y());
+#endif
+
   if(selectedLine >= RXWINDOWBUFFER)
     selectedLine=RXWINDOWBUFFER-1;
   selectedColumn=0;
@@ -294,17 +301,8 @@ void CRxWindow::contextMenu ( QPoint p )
     ScrollBuffer[selectedLine]->cursorWordForward ( true );
     selectedString = ScrollBuffer[selectedLine]->selectedText();
   }
-  /**
-  qDebug("*****Cursor: x: %i y: %i",p.x(),p.y());
-  int start;
-  start=selectedLine-4;
-  if(start <0)
-    start=0;
-  for(int i=start;i <=selectedLine;i++)
-    {
-      qDebug("Zeile: %i, %s",i,qPrintable(ScrollBuffer[i]->text()));
-    }
-    **/
+
+
   menu->exec ( p1 );
   ScrollBuffer[selectedLine]->deselect();
 }
diff --git a/src/crxwindow.h b/src/crxwindow.h
index 6cf488d..e7f74d7 100644
--- a/src/crxwindow.h
+++ b/src/crxwindow.h
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          crxwindow.h  -  description
-                             -------------------
-    begin                : Mon Mar 6 2000
-    copyright            : (C) 2000 by Volker Schroer
-    email                : DL1KSV at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -79,7 +71,7 @@ private:
 
   QMenu *menu;
   QString selectedString;
-  int DisplayLineHeight;
+
 signals:
   void Triggered();
   void setQsoData(QsoData,QString);
diff --git a/src/csound.cpp b/src/csound.cpp
index d7ce3e9..99b5707 100644
--- a/src/csound.cpp
+++ b/src/csound.cpp
@@ -429,7 +429,7 @@ void CSound::PTT ( bool mode )
 
 bool CSound::close_Device()
 {
-  wait();
+//  wait();
   if ( handle != 0 )
     snd_pcm_close ( handle );
   handle = 0;
@@ -481,6 +481,12 @@ void CSound::record()
       if ( available >= BUF_SIZE )
         emit samplesAvailable();
     }
+    else if ( err > 0)
+      {
+        qDebug("Strange situation, only %d bytes read\nRetry",err);
+        snd_pcm_prepare ( handle );
+        snd_pcm_start ( handle );
+      }
     else
     {
       if ( err == -EPIPE )
@@ -514,7 +520,7 @@ void CSound::play()
   toBePlayed = 0;
   qDebug ( "Play thread started" );
 
-  while ( started )
+  while ( started || (!started && (toBePlayed >0))) // We should flush the buffer
   {
     LockPointers.lock();
     if ( toBePlayed <= BUF_SIZE && ( !signaled ) )
@@ -522,16 +528,9 @@ void CSound::play()
       emit samplesAvailable();
       signaled = true;
     }
-//    if ( free > ( 2* BUF_SIZE ) )
-//      qDebug ( "Out of bounds" );
     while ( toBePlayed < laenge && started )
       WakeUp.wait ( &LockPointers );
     LockPointers.unlock();
-    if ( !started )
-    {
- //     qDebug ( "Stop received" );
-      break;
-    }
     if ( toBePlayed >= BUF_SIZE )
       signaled = false;
     for ( int i = 0;i < laenge;i++ )
@@ -572,7 +571,7 @@ void CSound::play()
 
     }
   }
-  snd_pcm_drop ( handle );
+  snd_pcm_drain ( handle );
   qDebug ( "Play Thread terminated" );
 }
 int CSound::getDeviceNumber(QString device)
@@ -586,10 +585,12 @@ int CSound::getDeviceNumber(QString device)
           getline (cards, line);
           if ( line.find( device.toStdString() ) != std::string::npos )  {
               std::istringstream( line ) >>id;
+              cards.close();
               return id;
           }
       }
   }
+  cards.close();
   return id;
 }
 #ifdef SOUND_DEBUG
diff --git a/src/ctxbuffer.cpp b/src/ctxbuffer.cpp
index 5c7d28f..a761e06 100644
--- a/src/ctxbuffer.cpp
+++ b/src/ctxbuffer.cpp
@@ -20,108 +20,110 @@
 
 CTxBuffer::CTxBuffer()
 {
-filled=0;
-inpos=0;
-outpos=0;
+  filled=0;
+  inpos=0;
+  outpos=0;
 }
 CTxBuffer::~CTxBuffer()
 {
 }
 bool CTxBuffer::Filled()
 {
-if ( filled < TXBUFFER_LENGTH )
-  return false;
-else
-  return true;
+  if ( filled < TXBUFFER_LENGTH )
+    return false;
+  else
+    return true;
 }
 int CTxBuffer::getTxChar()
 {
-int ch;
-if (filled > 0)
-	{
-		ch=txbuffer[outpos++];
-		filled--;
-		if (filled == 0)
-			{
-				inpos=0;
-				outpos=0;
-			}
-		 else
-			outpos=outpos % TXBUFFER_LENGTH;
-		return ch;
-	}
-else
-	 return TXTOG_CODE;
+  int ch;
+  if (filled > 0)
+    {
+      ch=txbuffer[outpos++];
+      filled--;
+      if (filled == 0)
+        {
+          inpos=0;
+          outpos=0;
+        }
+      else
+        outpos=outpos % TXBUFFER_LENGTH;
+      return ch;
+    }
+  else
+    return TXTOG_CODE;
 
 }
 void CTxBuffer::insert(int c)
 {
-if ( c != '\b' )
-{
- if (filled < TXBUFFER_LENGTH)
- {
-  filled++;
-  txbuffer[inpos++]=c;
-  inpos = inpos % TXBUFFER_LENGTH;
-  }
-}
-else
-{
- filled--;
- if ( filled <= 0)
- {
-  inpos=0;
-  outpos=0;
-  if( filled < 0)
-  {
-    filled=1;
-    txbuffer[inpos++]=c;
-  }
- }
- else
- {
- inpos--;
- if (inpos < 0)
-  inpos +=TXBUFFER_LENGTH;
- }
-}   
+  if ( c != '\b' )
+    {
+      if (filled < TXBUFFER_LENGTH)
+        {
+          filled++;
+          txbuffer[inpos++]=c;
+          inpos = inpos % TXBUFFER_LENGTH;
+        }
+    }
+  else
+    {
+      filled--;
+      if ( filled <= 0)
+        {
+          inpos=0;
+          outpos=0;
+          if( filled < 0)
+            {
+              filled=1;
+              txbuffer[inpos++]=c;
+            }
+        }
+      else
+        {
+          inpos--;
+          if (inpos < 0)
+            inpos +=TXBUFFER_LENGTH;
+        }
+    }
 }
 void CTxBuffer::clear()
 {
+/**
   if(filled > 0)
-  {
-   if(txbuffer[(outpos+filled-1) %  TXBUFFER_LENGTH] == TXOFF_CODE) // We have to keep switching to rx
-   {
-     outpos = (outpos+filled-1) %  TXBUFFER_LENGTH;
-     inpos = (inpos+filled-1) %  TXBUFFER_LENGTH;
-     filled=1;
-     return;
-   }
-  }
-filled=0;
-inpos=0;
-outpos=0;
+    {
+      if(txbuffer[(outpos+filled-1) %  TXBUFFER_LENGTH] == TXOFF_CODE) // We have to keep switching to rx
+        {
+          outpos = (outpos+filled-1) %  TXBUFFER_LENGTH;
+          inpos = (inpos+filled-1) %  TXBUFFER_LENGTH;
+          filled=1;
+          return;
+        }
+    }
+**/
+  filled=0;
+  inpos=0;
+  outpos=0;
 }
 void CTxBuffer::insert(QString Text,int length)
 {
-for (int i=0;i <length; i++)
- {
-  if ( filled < TXBUFFER_LENGTH )
+  for (int i=0;i <length; i++)
     {
-    filled++;
-    txbuffer[inpos++]=(unsigned char) Text.at(i).toLatin1();
-    inpos = inpos % TXBUFFER_LENGTH;
+      if ( filled < TXBUFFER_LENGTH )
+        {
+          filled++;
+          txbuffer[inpos++]=(unsigned char) Text.at(i).toLatin1();
+          inpos = inpos % TXBUFFER_LENGTH;
+        }
+      else
+        {
+          while(this->Filled()) // Wait until Buffer is not filled
+            qApp->processEvents(QEventLoop::AllEvents,100);
+          filled++;
+          txbuffer[inpos++]=Text.at(i).toLatin1();
+          inpos = inpos % TXBUFFER_LENGTH;
+
+        }
     }
-   else
-    {
-    while(this->Filled()) // Wait until Buffer is not filled
-      qApp->processEvents(QEventLoop::AllEvents,100);
-    filled++;
-    txbuffer[inpos++]=Text.at(i).toLatin1();
-    inpos = inpos % TXBUFFER_LENGTH;
-      
-    }   
-  } 
 }
 bool CTxBuffer::isEmpty()
 {
diff --git a/src/firfilter.cpp b/src/firfilter.cpp
index 39b67ce..93f5d51 100644
--- a/src/firfilter.cpp
+++ b/src/firfilter.cpp
@@ -15,22 +15,54 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <assert.h>
 #include "firfilter.h"
+#include <math.h>
 
-FIRFilter::FIRFilter(double *Filtercoeffs,int Filterlength,FilterMode Mode)
+FIRFilter::FIRFilter(double Fc, int Filterlength, FilterMode Mode, double gain)
 {
-NxCoeffs=Filterlength;
+  // Cutoff Fc in radians
+  double normalize = 0;
+  int fhalbe;
+  assert(Filterlength%2 == 1);
+  fhalbe=(Filterlength-1)/2;
+  NxCoeffs=Filterlength;
+
+  h=new double[Filterlength];
+  if (Mode == RealData)
+    {
+     filterbuffer=new double[Filterlength];
+     cfilterbuffer = 0;
+    }
+  else
+    {
+     cfilterbuffer=new complex<double>[Filterlength];
+     filterbuffer =0;
+    }
+  /** Calculate coefficients of sinc lp filter */
+
+// sin(x-tau)/(x-tau)
+  for (int i = 0; i < Filterlength; i++)
+      if (i == fhalbe)
+          h[i] = Fc;
+      else
+          h[i] = sin(Fc*(i - fhalbe))/(i-fhalbe);
+// blackman window
+  for (int i = 1; i < Filterlength+1; i++)
+      h[i-1] = h[i-1] * (0.42 - 0.5 * cos(2*M_PI*i/(Filterlength+1)) + 0.08 * cos(4*M_PI*i/(Filterlength+1)));
+//  h[0]=0;
+//  h[Filterlength-1]=0;
+// normalization factor
+  for (int i = 1; i < Filterlength-1; i++)
+      normalize += h[i];
+  if(gain !=0)
+    normalize /=gain;
+// normalize the filter
+  for (int i = 1; i < Filterlength-1; i++)
+     h[i] /= normalize;
 
-h=new double[Filterlength];
-if (Mode == RealData)
- filterbuffer=new double[Filterlength];
-else
- cfilterbuffer=new complex<double>[Filterlength];
- 
 for(int i=0;i <Filterlength;i++)
  {
-   if(Filtercoeffs != 0)
-    h[i] = *(Filtercoeffs+i);
    if (Mode == RealData)
     filterbuffer[i]=0.0;
    else
@@ -76,14 +108,15 @@ for(int i=0; i <NxSamples;i++)
  }  
 
 
-fbBuffer=fbPtr;          
+  fbBuffer=fbPtr;
 }
+/**
 void FIRFilter::setnewCoeffs(double *Filtercoeffs)
 {
 for(int i=0;i <NxCoeffs;i++)
    h[i] = *(Filtercoeffs+i);
  }
-
+**/
 void FIRFilter::processFilter(complex<double> *input,complex<double> *output,int NxSamples)
 {
  complex<double> *oPtr,*fbPtr;
diff --git a/src/firfilter.h b/src/firfilter.h
index 2b82449..12a43af 100644
--- a/src/firfilter.h
+++ b/src/firfilter.h
@@ -26,11 +26,11 @@ using namespace std;
 enum FilterMode{RealData,ComplexData};
 class FIRFilter {
 public: 
-	FIRFilter(double *Filtercoeffs,int Filterlength,FilterMode);
+	FIRFilter(double Fc, int Filterlength, FilterMode, double gain =1.);
 	~FIRFilter();
   void processFilter(double *input,double *output,int NxSamples);
   void processFilter(complex<double> *input,complex<double> *output,int NxSamples);
-  void setnewCoeffs(double *Filtercoeffs);
+//  void setnewCoeffs(double *Filtercoeffs);
 private:
 int NxCoeffs;
 double *h;
diff --git a/src/frequencyselect.cpp b/src/frequencyselect.cpp
index 14f10ac..f74e986 100644
--- a/src/frequencyselect.cpp
+++ b/src/frequencyselect.cpp
@@ -32,9 +32,9 @@ FrequencySelect::FrequencySelect( QWidget* parent , AfcMode WithMode)
     setAlignment( Qt::AlignCenter );
 
     Activate = new QRadioButton(  "Activate", this );
-Activate->setAutoExclusive(false);
+    Activate->setAutoExclusive(false);
     AfcWide = new QRadioButton("Wide", this);
-AfcWide->setAutoExclusive(false);
+    AfcWide->setAutoExclusive(false);
     modus=Wide;
     switch (WithMode)
     {
diff --git a/src/fskmodulator.h b/src/fskmodulator.h
index 71900a1..e4a3e6c 100644
--- a/src/fskmodulator.h
+++ b/src/fskmodulator.h
@@ -1,18 +1,9 @@
 /***************************************************************************
-                          fskmodulator.h  -  description
-                             -------------------
-    begin                : Sam M�r 1 2003
-    copyright            : (C) 2003 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
- *   The PSK part is based on WinPSK 1.0 by Moe Wheatley, AE4JY            *
  ***************************************************************************/
 
 #ifndef FSKMODULATOR_H
@@ -20,9 +11,6 @@
 
 #include "cmodulator.h"
 
-/**
-  *@author Volker Schroer
-  */
 
 class FSKModulator : public CModulator  {
 public: 
@@ -32,8 +20,7 @@ public:
 protected:
 virtual int getToneNumber()=0;
 unsigned int NumberofTones;
-//double *ToneFrequencyr;
-//double *ToneFrequencyi;
+
 double ToneFrequencyr[16];
 double ToneFrequencyi[16];
 double Frequencyr,Frequencyi;
diff --git a/src/mfskdemodulator.cpp b/src/mfskdemodulator.cpp
index a5ca79f..c91f984 100644
--- a/src/mfskdemodulator.cpp
+++ b/src/mfskdemodulator.cpp
@@ -62,7 +62,7 @@ int MFSKDemodulator::getSquelchValue()
 
 	return 0;
 }
-bool MFSKDemodulator::Init ( double FS, int NumberofSamples )
+void MFSKDemodulator::Init( double FS, int NumberofSamples )
 {
 	int i;
 	NxSamples = NumberofSamples;
@@ -79,8 +79,6 @@ bool MFSKDemodulator::Init ( double FS, int NumberofSamples )
 		delayLine[i] = complex<double> ( 0.0, 0.0 );
 	for ( i = 0; i < RESOLUTION;i++ )
 		twiddles[i] = complex<double> ( cos ( i *  M_PI / RESOLUTION ), - sin ( i  * M_PI / RESOLUTION ) );
-
-	return true;
 }
 
 
diff --git a/src/mfskdemodulator.h b/src/mfskdemodulator.h
index a791c2f..ca3a82a 100644
--- a/src/mfskdemodulator.h
+++ b/src/mfskdemodulator.h
@@ -43,7 +43,7 @@ public:
 	/** Prozess the input */
 	void ProcessInput(double * input,double *);
   int getSquelchValue();
-	bool Init(double,int);
+  void Init(double,int);
   virtual double get2RxFrequency();
 private:
 AfcMode AfcProperties();
diff --git a/src/mfskmodulator.cpp b/src/mfskmodulator.cpp
index ce70277..89bf1d6 100644
--- a/src/mfskmodulator.cpp
+++ b/src/mfskmodulator.cpp
@@ -22,96 +22,96 @@
 
 MFSKModulator::MFSKModulator ( int FS, double freq, CTxBuffer *TxBuffer ) : FSKModulator ( FS, TxBuffer )
 {
-	Encoder = new MFSKVaricode();
-	leave = new Interleaver ( 10 );
-	Fec = new FECCoder();
-	Allbitsgone = true;
-	bitcounter = 0;
-	varicode = 0;
-	NumberofTones = 16;
-	postamblePtr = 0;
-	preamblePtr = 5;
-// ToneFrequencyr = new double[NumberofTones];
-// ToneFrequencyi = new double[NumberofTones];
-	Baudrate = 15.625;
-	SamplesperSymbol = ( int ) ( SampleRate / Baudrate + 0.5 );
-// Tonespacing has the same value like Baudrate so
-	for ( unsigned int i = 0; i < NumberofTones;i++ )
-	{
-		ToneFrequencyr[i] = cos ( PI2 * ( freq + i * Baudrate ) / SampleRate );
-		ToneFrequencyi[i] = sin ( PI2 * ( freq + i * Baudrate ) / SampleRate );
-	}
-	NxSamples = SamplesperSymbol;
+  Encoder = new MFSKVaricode();
+  leave = new Interleaver ( 10 );
+  Fec = new FECCoder();
+  Allbitsgone = true;
+  bitcounter = 0;
+  varicode = 0;
+  NumberofTones = 16;
+  postamblePtr = 0;
+  preamblePtr = 5;
+  // ToneFrequencyr = new double[NumberofTones];
+  // ToneFrequencyi = new double[NumberofTones];
+  Baudrate = 15.625;
+  SamplesperSymbol = ( int ) ( SampleRate / Baudrate + 0.5 );
+  // Tonespacing has the same value like Baudrate so
+  for ( unsigned int i = 0; i < NumberofTones;i++ )
+    {
+      ToneFrequencyr[i] = cos ( PI2 * ( freq + i * Baudrate ) / SampleRate );
+      ToneFrequencyi[i] = sin ( PI2 * ( freq + i * Baudrate ) / SampleRate );
+    }
+  NxSamples = SamplesperSymbol;
 }
 MFSKModulator::~MFSKModulator()
 {
-	if ( Encoder != 0 )
-		delete Encoder;
-	if ( leave != 0 )
-		delete leave;
-	if ( Fec != 0 )
-		delete Fec;
+  if ( Encoder != 0 )
+    delete Encoder;
+  if ( leave != 0 )
+    delete leave;
+  if ( Fec != 0 )
+    delete Fec;
 }
 int MFSKModulator::getToneNumber()
 {
-	int ch;
-	if ( postamblePtr == 1 )
-		return  TXOFF_CODE;
-	for ( ;; )
-	{
-		if ( Allbitsgone )
-		{
-			if ( postamblePtr > 1 )
-			{
-				postamblePtr--;
-				ch = 0;
-			}
-			else if ( preamblePtr > 0 )
-			{
-				preamblePtr--;
-				ch = 0;
-			}
-			else
-			{
-				ch = Buffer->getTxChar();
-				if ( ch < 0 )
-				{
-					if ( ch == TXOFF_CODE )
-//    {
-						postamblePtr = 10;
-//     ch=0;
-//    }
-//    else
-					ch = 0; // <Nul>
-				}
-				else
-					emit charSend ( ( char ) ch );
-			}
-			varicode = Encoder->encode ( ch );
-			Allbitsgone = false ;
-			bitposition = 0x0800;
-			// find first bit from left
-			while ( ! ( varicode & bitposition ) )
-				bitposition = bitposition >> 1;
+  int ch;
+  if ( postamblePtr == 1 )
+    return  TXOFF_CODE;
+  for ( ;; )
+    {
+      if ( Allbitsgone )
+        {
+          if ( postamblePtr > 1 )
+            {
+              postamblePtr--;
+              ch = 0;
+            }
+          else if ( preamblePtr > 0 )
+            {
+              preamblePtr--;
+              ch = 0;
+            }
+          else
+            {
+              ch = transmitBuffer->getTxChar();
+              if ( ch < 0 )
+                {
+                  if ( ch == TXOFF_CODE )
+                    //    {
+                    postamblePtr = 10;
+                  //     ch=0;
+                  //    }
+                  //    else
+                  ch = 0; // <Nul>
+                }
+              else
+                emit charSend ( ( char ) ch );
+            }
+          varicode = Encoder->encode ( ch );
+          Allbitsgone = false ;
+          bitposition = 0x0800;
+          // find first bit from left
+          while ( ! ( varicode & bitposition ) )
+            bitposition = bitposition >> 1;
 
-		}
-		while ( bitposition  && ( bitcounter < 4 ) )
-		{
-			if ( varicode & bitposition )
-				Fec->FECEncode ( 1 , &bit[bitcounter] );
-			else
-				Fec->FECEncode ( 0, &bit[bitcounter] );
-			bitcounter += 2;
-			bitposition = bitposition >> 1;
-		}
-		if ( bitposition == 0 )
-			Allbitsgone = true;
-		if ( bitcounter == 4 )
-		{
-			bitcounter = 0;
-			return grayencode ( leave->interleave ( bit ) );
-		}
-	}
+        }
+      while ( bitposition  && ( bitcounter < 4 ) )
+        {
+          if ( varicode & bitposition )
+            Fec->FECEncode ( 1 , &bit[bitcounter] );
+          else
+            Fec->FECEncode ( 0, &bit[bitcounter] );
+          bitcounter += 2;
+          bitposition = bitposition >> 1;
+        }
+      if ( bitposition == 0 )
+        Allbitsgone = true;
+      if ( bitcounter == 4 )
+        {
+          bitcounter = 0;
+          return grayencode ( leave->interleave ( bit ) );
+        }
+    }
 }
 
 
diff --git a/src/parameter.cpp b/src/parameter.cpp
index ba11c3c..898dce3 100644
--- a/src/parameter.cpp
+++ b/src/parameter.cpp
@@ -34,9 +34,6 @@ QSOFileName="QSOData.adif";
 timeoffset=-2;
 
 DemoMode=true;
-DemoModeFileType[0]="*.wav";
-DemoModeFileType[1]="*.out";
-DemoTypeNumber=0;
 
 slashed0=false;
 autoCrLf=true;
@@ -55,6 +52,18 @@ complexFormat=false;
 LangName[0]="B";
 LangName[1]="E";
 LangName[2]="G";
+
+/** Rig **/
+rigModelNumber=0; // No rig
+#ifdef WITH_HAMLIB
+rig=0;
+#endif
+rigDevice="none";
+QsoFrequency=-1;
+pwr=5;
+handshake=1; // hardware
+baudrate=9600;
+
 }
 Parameter::~Parameter()
 {
diff --git a/src/parameter.h b/src/parameter.h
index 63a0187..4eafff7 100644
--- a/src/parameter.h
+++ b/src/parameter.h
@@ -29,6 +29,7 @@
 class CRxChannel;
 class QString;
 class QFont;
+class RigControl;
 
 /**Contains parameters for transmitting and receiving
 
@@ -49,8 +50,6 @@ void setupDevices();
 QString callsign;             // Callsign
 QString myLocator;
 QString inputFilename;        //Name of Demofile
-QString DemoModeFileType[2];  // File Type of DemoFile
-int DemoTypeNumber;           // Index of selected FileType
 int serial;                   // Filedescriptor for serial Device for PTT
 QString SerialDevice;         //Filename for PTT Device
 //Logging
@@ -86,6 +85,19 @@ BUTTONSTATUS Status;
 QFont *ApplicationFont;
 QString dateFormat;
 
+/** Rig **/
+int QsoFrequency; // Number of item in QCombobox
+int pwr;
+int rigModelNumber;
+int handshake;
+int baudrate;
+#ifdef WITH_HAMLIB
+RigControl *rig;
+#endif
+QString rigDevice;
+
+QList<Band> bandList;
+
 };
 
 #endif
diff --git a/src/processlogdata.cpp b/src/processlogdata.cpp
index 8a123ef..a166beb 100644
--- a/src/processlogdata.cpp
+++ b/src/processlogdata.cpp
@@ -31,6 +31,8 @@ ProcessLogData::ProcessLogData ( QObject *parent )
   tcpSocket = 0;
   connectionEstablished = false;
   connectionError = false;
+  connect(this,SIGNAL(executeAction()),this,SLOT(doAction()),Qt::QueuedConnection);
+
 }
 
 
@@ -39,15 +41,11 @@ ProcessLogData::~ProcessLogData()
 }
 void ProcessLogData::saveQsoData ( QString s )
 {
-  qDebug ( "Request save" );
-  requestType = Save;
   actionString = s;
-  doAction();
+  emit executeAction();
 }
-void ProcessLogData::requestCallSign ( QLabel **r, QString s )
+void ProcessLogData::requestCallsign (QLabel **r, QString s )
 {
-  qDebug ( "Request Callsign" );
-  requestType = Request;
   actionString.clear();
   actionString.append ( "@@@@" );
   actionString.append ( s );
@@ -55,19 +53,23 @@ void ProcessLogData::requestCallSign ( QLabel **r, QString s )
 
   for ( int i = 0; i < 6;i++ )
     results[i] = r[i];
-  doAction();
+  emit executeAction();
 }
 void ProcessLogData::run()
 {
   connectionEstablished = false;
   connectionError = false;
   qRegisterMetaType<QAbstractSocket::SocketError> ( "QAbstractSocket::SocketError" );
+
   tcpSocket = new QTcpSocket();
-  connect ( tcpSocket, SIGNAL ( disconnected() ), this, SLOT ( connectionClosedbyHost() ) );
-  connect ( tcpSocket, SIGNAL ( readyRead() ), this, SLOT ( readAnswer() ) );
-  connect ( tcpSocket, SIGNAL ( connected() ), this, SLOT ( setConnected() ) );
+  connect ( tcpSocket, SIGNAL ( disconnected() ), this, SLOT ( connectionClosedbyHost() ) ,Qt::QueuedConnection);
+  connect ( tcpSocket, SIGNAL ( readyRead() ), this, SLOT ( readAnswer() ) ,Qt::QueuedConnection);
+  connect ( tcpSocket, SIGNAL ( connected() ), this, SLOT ( setConnected() ) ,Qt::QueuedConnection);
+
   connect ( tcpSocket, SIGNAL ( error ( QAbstractSocket::SocketError ) ), this, SLOT ( setError ( QAbstractSocket::SocketError ) ) );
   tcpSocket->connectToHost ( QHostAddress::LocalHost, 8080, QIODevice::ReadWrite );
+  tcpSocket->waitForConnected(6000);
+
   exec();
 }
 void ProcessLogData::doAction()
@@ -91,14 +93,15 @@ void ProcessLogData::doAction()
     return;
   }
 
-//  qDebug ( "SocketError %d", tcpSocket->state() );
+  //qDebug ( "SocketError %d", tcpSocket->state() );
   if ( tcpSocket->state() == QAbstractSocket::UnconnectedState )
   {
     QMessageBox::information ( 0, "LinPSK", tr ( "Cannot connect to LinLogBook" ) );
     return;
   }
+
   int n = tcpSocket->write ( actionString.toLatin1(), actionString.length() );
-//  qDebug ( "Written %d, to be written %d", n, actionString.length() );
+ // qDebug ( "Written %d, to be written %d", n, actionString.length() );
   if ( n < 0 ) // Retry
   {
     usleep ( 100 );
@@ -106,11 +109,12 @@ void ProcessLogData::doAction()
 //    qDebug ( "Written %d, to be written %d", n, actionString.length() );
   }
  /** qt 4.7 lets flush write data again*/
-//  tcpSocket->flush();
+ // tcpSocket->flush();
 }
 void ProcessLogData::connectionClosedbyHost()
 {
   connectionEstablished = false;
+  tcpSocket->disconnect();
   if ( tcpSocket != 0 )
     delete tcpSocket;
   tcpSocket = 0;
@@ -144,8 +148,6 @@ void ProcessLogData::setError ( QAbstractSocket::SocketError  )
 {
   connectionEstablished = false;
   connectionError = true;
-//  if ( tcpSocket != 0 )
-//    qDebug ( "SocketError %d", tcpSocket->state() );
 }
 
 
diff --git a/src/processlogdata.h b/src/processlogdata.h
index d430a11..6ac4490 100644
--- a/src/processlogdata.h
+++ b/src/processlogdata.h
@@ -38,16 +38,19 @@ class ProcessLogData : public QThread
 
     ~ProcessLogData();
     void saveQsoData ( QString s );
-    void requestCallSign ( QLabel **, QString s );
     void run();
+    void requestCallsign (QLabel **r, QString s );
+
   private:
-    enum RequestType {Save = 0, Request};
-    RequestType requestType;
+
     QString actionString;
     QTcpSocket *tcpSocket;
     QLabel * results[6];
     bool connectionEstablished;
     bool connectionError;
+  public slots:
+
+
   private slots:
     void doAction();
     void connectionClosedbyHost();
@@ -57,6 +60,7 @@ class ProcessLogData : public QThread
 signals:
 void unabletoConnect();
 void answerAvailable();
+void executeAction();
 };
 
 #endif
diff --git a/src/bpskdemodulator.cpp b/src/psk63demodulator.cpp
similarity index 62%
copy from src/bpskdemodulator.cpp
copy to src/psk63demodulator.cpp
index c9a89dc..7f894e2 100644
--- a/src/bpskdemodulator.cpp
+++ b/src/psk63demodulator.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          bpskdemodulator.cpp  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -15,17 +7,22 @@
  *    based on the work of  Moe Wheatly, AE4JY                             *
  ***************************************************************************/
 
-#include "bpskdemodulator.h"
+#include "psk63demodulator.h"
+#include "firfilter.h"
 
-BPskDemodulator::BPskDemodulator():CPskDemodulator()
+PSk63Demodulator::PSk63Demodulator():CPskDemodulator()
 {
   ave1=1.0;
   ave2=1.0;
-
 }
-BPskDemodulator::~BPskDemodulator(){
+PSk63Demodulator::~PSk63Demodulator()
+{
+  if( downFilter )
+    delete downFilter;
+  if ( syncFilter )
+    delete syncFilter;
 }
-void BPskDemodulator::DecodeSymbol(double angle)
+void PSk63Demodulator::DecodeSymbol(double angle)
 
 {
 
@@ -78,26 +75,16 @@ void BPskDemodulator::DecodeSymbol(double angle)
 
 
 }
-bool BPskDemodulator::GetBPSKSymb()
+bool PSk63Demodulator::GetBPSKSymb()
 {
   return (Phase_Vector.real()> 0.0);
 }
 
-//////////////////////////////////////////////////////////////////////
-// Calculate signal quality based on the statistics of the phase
-//	difference angle.  The more dispersion of the "0" and "180" degree
-//  phase shifts, the worse the signal quality.  This information is used
-//  to activate the squelch control.  If 20 consecutive "180" degree shifts
-//  occur, the squelch is forced on, and if 20 consecutive "0" degree
-//  shifts occur, the squelch is forced off quickly.
-//////////////////////////////////////////////////////////////////////
-
-void BPskDemodulator::CalcQuality(  double angle )
+void PSk63Demodulator::CalcQuality(  double angle )
 {
 
   double temp;
 
-
   if ( fabs(angle) < M_PI_2)
     temp= angle;
   else
@@ -107,7 +94,6 @@ void BPskDemodulator::CalcQuality(  double angle )
       else
         temp = M_PI+ angle;
     }
-  m_QFreqError = -temp;
   temp = fabs(temp);
   m_DevAve =0.5 * ave1 + 0.45 * ave2 + 0.05 *temp;
   ave2=ave1;
@@ -116,3 +102,29 @@ void BPskDemodulator::CalcQuality(  double angle )
   m_DevAve = 100. -m_DevAve *63.67;
 
 }
+void PSk63Demodulator::Init(double Fs ,int BlockSize)
+{
+  SampleRate = Fs;        //sample rate
+  NxSamples = BlockSize;  //size data input buffer
+  downFilter = new FIRFilter(PI2*125./Fs,79,ComplexData,10.);
+  syncFilter = new FIRFilter(PI2*62.5*9./Fs,79, ComplexData);
+  downRate = 9;
+  f1=31.25;
+  f2=93.75;
+}
+double PSk63Demodulator::calcFreqError(complex<double> s)
+{
+ double x,y;
+ complex<double> z;
+ if (abs(s) >1 )
+  z=s/abs(s);
+ else z=s;
+ x= z.real()*z.imag();
+ x /=2500.; // Adopt deviation to samplerate
+// x /=2.8016548; //Gain
+ y=x_loop_1+x +0.2861361823*y_loop_1;
+ x_loop_1=x;
+ y_loop_1=y;
+ return -y;
+
+}
diff --git a/src/bpskdemodulator.h b/src/psk63demodulator.h
similarity index 56%
copy from src/bpskdemodulator.h
copy to src/psk63demodulator.h
index 969c30e..5562194 100644
--- a/src/bpskdemodulator.h
+++ b/src/psk63demodulator.h
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          bpskdemodulator.h  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -15,8 +7,8 @@
  *   based on the work of Moe Wheatley, AE4JY                              *
  ***************************************************************************/
 
-#ifndef BPSKDEMODULATOR_H
-#define BPSKDEMODULATOR_H
+#ifndef PSK63DEMODULATOR_H
+#define PSK63DEMODULATOR_H
 
 #include <complex>
 #include "cpskdemodulator.h"
@@ -26,21 +18,22 @@
   *@author Volker Schroer
   */
 
-class BPskDemodulator : public CPskDemodulator  {
+class PSk63Demodulator : public CPskDemodulator  {
 public: 
-	BPskDemodulator();
-	~BPskDemodulator();
+  PSk63Demodulator();
+  ~PSk63Demodulator();
+   void Init(double Fs ,int BlockSize);
 protected:	
 /** Decodes a BPSK Symbol */
-void DecodeSymbol( double);
 
-void CalcQuality(double);
+  void DecodeSymbol( double);
+
+  void CalcQuality(double);
+  double calcFreqError(complex<double> s);
 private:
-	bool GetBPSKSymb();
+  bool GetBPSKSymb();
   double ave1;
-	double ave2;
-
-
+  double ave2;
 };
 
 #endif
diff --git a/gui/addrxwindow.cpp b/src/psk63modulator.cpp
similarity index 50%
copy from gui/addrxwindow.cpp
copy to src/psk63modulator.cpp
index 0f91fc8..5137562 100644
--- a/gui/addrxwindow.cpp
+++ b/src/psk63modulator.cpp
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by volker, DL1KSV   *
- *   schroer at tux64   *
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -18,38 +17,63 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-
-#include "addrxwindow.h"
+#include "psk63modulator.h"
+#include "constants.h"
 #include "parameter.h"
+#include "ctxbuffer.h"
 
 extern Parameter settings;
 
-AddRxWindow::AddRxWindow(QWidget* parent, Qt::WindowFlags fl)
-: QDialog( parent, fl ), Ui::AddRxWindow()
-{
-	setupUi(this);
-RxMode->insertItem(0,"BPSK");
-RxMode->insertItem(1,"QPSK");
-RxMode->insertItem(2,"RTTY");
-RxMode->insertItem(3,"MFSK16");
-RxMode->setCurrentRow(0);
-TitleText->setText("Rx " + QString().setNum(settings.RxChannels+1));
+#define SYM_NOCHANGE 0 //Stay the same phase
+#define SYM_P180 2  //Plus 180 deg
 
-}
 
-AddRxWindow::~AddRxWindow()
-{
-}
-Mode AddRxWindow::selectedMode()
-{
-return (Mode) RxMode->currentRow();
-}
-QString AddRxWindow::titleText()
+Psk63Modulator::Psk63Modulator(int FS, double frequency, CTxBuffer *TxBuffer):PskModulator(FS,frequency,TxBuffer)
 {
- return TitleText->text();
+  symbolSize=(((100 * FS) / 6250) + 1);
+  periodTime=1./62.5;
+  period=periodTime;
 }
-int AddRxWindow::frequency()
+char Psk63Modulator::getNextSymbolBit()
 {
- return Frequency->value();
+  int bit;
+  if(txShiftRegister != 0)
+    {
+      if(txShiftRegister &0x8000)
+        bit=SYM_NOCHANGE;
+      else
+        bit=SYM_P180;
+      txShiftRegister <<=1;
+      if(txShiftRegister == 0)
+        addEndingZero=true;
+    }
+  else
+    {
+      if(addEndingZero)
+      {
+        bit=SYM_P180;
+        addEndingZero=false;
+       }
+      else
+        {
+          int ch;
+          if((ch = getChar())>= 0)
+            {       // No controlcode
+              txShiftRegister = VARICODE_TABLE[ ch&0xFF ];
+              bit=SYM_P180; //Start with a zero
+             }
+          else
+            switch ( ch )
+            {
+              case TXON_CODE:
+              case TXTOG_CODE:    //Idle
+                bit = SYM_P180;
+                break;
+              case TXOFF_CODE:
+                bit = SYM_NOCHANGE;
+                break;
+            }
+        }
+    }
+  return bit;
 }
-
diff --git a/gui/addrxwindow.h b/src/psk63modulator.h
similarity index 71%
copy from gui/addrxwindow.h
copy to src/psk63modulator.h
index 051c7ab..41e70ae 100644
--- a/gui/addrxwindow.h
+++ b/src/psk63modulator.h
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by volker, DL1KSV   *
- *   schroer at tux64   *
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -18,35 +17,18 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef ADDRXWINDOW_H
-#define ADDRXWINDOW_H
+#ifndef PSK63MODULATOR_H
+#define PSK63MODULATOR_H
 
-#include <QDialog>
-#include "ui_addrxwindow.h"
-#include "constants.h"
+#include "pskmodulator.h"
 
-class AddRxWindow : public QDialog, private Ui::AddRxWindow
+class Psk63Modulator : public PskModulator
 {
-  Q_OBJECT
-
 public:
-  AddRxWindow(QWidget* parent = 0, Qt::WindowFlags fl = 0 );
-  ~AddRxWindow();
-Mode selectedMode();
-QString titleText();
-int frequency();
-  /*$PUBLIC_FUNCTIONS$*/
-
-public slots:
-  /*$PUBLIC_SLOTS$*/
+  Psk63Modulator(int FS, double frequency, CTxBuffer *TxBuffer);
 
 protected:
-  /*$PROTECTED_FUNCTIONS$*/
-
-protected slots:
-  /*$PROTECTED_SLOTS$*/
-
+  char getNextSymbolBit();
 };
 
-#endif
-
+#endif // BPSKMODULATOR_H
diff --git a/src/pskmodulator.cpp b/src/pskmodulator.cpp
index d5c0ea0..28d6f72 100644
--- a/src/pskmodulator.cpp
+++ b/src/pskmodulator.cpp
@@ -1,632 +1,328 @@
-//////////////////////////////////////////////////////////////////////
-// PSKMod.cpp: implementation of the PSKModulator class.
-//
-//////////////////////////////////////////////////////////////////////
-//      PSK31/CW modulator
-// Copyright 1999.    Moe Wheatley AE4JY  <ae4jy at mindspring.com>
-//
-//This program is free software; you can redistribute it and/or
-//modify it under the terms of the GNU General Public License
-//as published by the Free Software Foundation; either version 2
-//of the License, or any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//GNU General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-//
-//////////////////////////////////////////////////////////////////////
-//
-// modified by Volker Schroer , DL1KSV for use in LinPsk
-
-#include <math.h>
-#include "psktable.h"
+/***************************************************************************
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <complex>
 #include "pskmodulator.h"
+#include "constants.h"
+#include "parameter.h"
 #include "ctxbuffer.h"
 
 
-// local defines.................
-
-#define PHZ_0 0			//specify various signal phase states
-#define PHZ_90 1
-#define PHZ_180 2
-#define PHZ_270 3
-#define PHZ_OFF 4
-
-#define SYM_NOCHANGE 0	//Stay the same phase
-#define SYM_P90 1		//Plus 90  deg
-#define SYM_P180 2		//Plus 180 deg
-#define SYM_M90 3		//Minus 90 deg
-#define SYM_OFF 4		//No output
-#define SYM_ON 5		//constant output
-
-
-#define SYMBOL_RATE 31.25		// 31.25 Symbols per Second
-
-#define MAXRAMP_SIZE (((100*11100)/3125)+1) // max number of envelope ramp steps per symbol
-/** Not needed any longer 
-#define TX_CONSTANT 23000.0		// TX Amplitude Factor
- **/
-#define CW_SPEED 1		//bigger is slower. 1 is fastest.
-
-// The use of static's here preclude having multiple instantiations
-// of this class but should not be an issue since only one soundcard.
-
-
-//Ramp shape tables that are loaded with cosine shaped functions at init
-static double PSKShapeTbl_Z[MAXRAMP_SIZE]; // 0
-static double PSKShapeTbl_P[MAXRAMP_SIZE]; // +1
-static double PSKShapeTbl_M[MAXRAMP_SIZE]; // -1
-static double PSKShapeTbl_ZP[MAXRAMP_SIZE]; // 0 to +1
-static double PSKShapeTbl_PZ[MAXRAMP_SIZE]; // +1 to 0
-static double PSKShapeTbl_MZ[MAXRAMP_SIZE]; // -1 to 0
-static double PSKShapeTbl_PM[MAXRAMP_SIZE]; // +1 to -1
-static double PSKShapeTbl_MP[MAXRAMP_SIZE]; // -1 to +1
-// each character is separated by two zeros. The bits are sent msbit first.
-const unsigned short int PSKModulator::VARICODE_TABLE[] = {
-  0xAAC0, // ASCII =   0	1010101011
-  0xB6C0, // ASCII =   1	1011011011
-  0xBB40, // ASCII =   2	1011101101
-  0xDDC0, // ASCII =   3	1101110111
-  0xBAC0, // ASCII =   4	1011101011
-  0xD7C0, // ASCII =   5	1101011111
-  0xBBC0, // ASCII =   6	1011101111
-  0xBF40, // ASCII =   7	1011111101
-  0xBFC0, // ASCII =   8	1011111111
-  0xEF00, // ASCII =   9	11101111
-  0xE800, // ASCII =  10	11101
-  0xDBC0, // ASCII =  11	1101101111
-  0xB740, // ASCII =  12	1011011101
-  0xF800, // ASCII =  13	11111
-  0xDD40, // ASCII =  14	1101110101
-  0xEAC0, // ASCII =  15	1110101011
-  0xBDC0, // ASCII =  16	1011110111
-  0xBD40, // ASCII =  17	1011110101
-  0xEB40, // ASCII =  18	1110101101
-  0xEBC0, // ASCII =  19	1110101111
-  0xD6C0, // ASCII =  20	1101011011
-  0xDAC0, // ASCII =  21	1101101011
-  0xDB40, // ASCII =  22	1101101101
-  0xD5C0, // ASCII =  23	1101010111
-  0xDEC0, // ASCII =  24	1101111011
-  0xDF40, // ASCII =  25	1101111101
-  0xEDC0, // ASCII =  26	1110110111
-  0xD540, // ASCII =  27	1101010101
-  0xD740, // ASCII =  28	1101011101
-  0xEEC0, // ASCII =  29	1110111011
-  0xBEC0, // ASCII =  30	1011111011
-  0xDFC0, // ASCII =  31	1101111111
-  0x8000, // ASCII = ' '	1
-  0xFF80, // ASCII = '!'	111111111
-  0xAF80, // ASCII = '"'	101011111
-  0xFA80, // ASCII = '#'	111110101
-  0xED80, // ASCII = '$'	111011011
-  0xB540, // ASCII = '%'	1011010101
-  0xAEC0, // ASCII = '&'	1010111011
-  0xBF80, // ASCII = '''	101111111
-  0xFB00, // ASCII = '('	11111011
-  0xF700, // ASCII = ')'	11110111
-  0xB780, // ASCII = '*'	101101111
-  0xEF80, // ASCII = '+'	111011111
-  0xEA00, // ASCII = ','	1110101
-  0xD400, // ASCII = '-'	110101
-  0xAE00, // ASCII = '.'	1010111
-  0xD780, // ASCII = '/'	110101111
-  0xB700, // ASCII = '0'	10110111
-  0xBD00, // ASCII = '1'	10111101
-  0xED00, // ASCII = '2'	11101101
-  0xFF00, // ASCII = '3'	11111111
-  0xBB80, // ASCII = '4'	101110111
-  0xAD80, // ASCII = '5'	101011011
-  0xB580, // ASCII = '6'	101101011
-  0xD680, // ASCII = '7'	110101101
-  0xD580, // ASCII = '8'	110101011
-  0xDB80, // ASCII = '9'	110110111
-  0xF500, // ASCII = ':'	11110101
-  0xDE80, // ASCII = ';'	110111101
-  0xF680, // ASCII = '<'	111101101
-  0xAA00, // ASCII = '='	1010101
-  0xEB80, // ASCII = '>'	111010111
-  0xABC0, // ASCII = '?'	1010101111
-  0xAF40, // ASCII = '@'	1010111101
-  0xFA00, // ASCII = 'A'	1111101
-  0xEB00, // ASCII = 'B'	11101011
-  0xAD00, // ASCII = 'C'	10101101
-  0xB500, // ASCII = 'D'	10110101
-  0xEE00, // ASCII = 'E'	1110111
-  0xDB00, // ASCII = 'F'	11011011
-  0xFD00, // ASCII = 'G'	11111101
-  0xAA80, // ASCII = 'H'	101010101
-  0xFE00, // ASCII = 'I'	1111111
-  0xFE80, // ASCII = 'J'	111111101
-  0xBE80, // ASCII = 'K'	101111101
-  0xD700, // ASCII = 'L'	11010111
-  0xBB00, // ASCII = 'M'	10111011
-  0xDD00, // ASCII = 'N'	11011101
-  0xAB00, // ASCII = 'O'	10101011
-  0xD500, // ASCII = 'P'	11010101
-  0xEE80, // ASCII = 'Q'	111011101
-  0xAF00, // ASCII = 'R'	10101111
-  0xDE00, // ASCII = 'S'	1101111
-  0xDA00, // ASCII = 'T'	1101101
-  0xAB80, // ASCII = 'U'	101010111
-  0xDA80, // ASCII = 'V'	110110101
-  0xAE80, // ASCII = 'W'	101011101
-  0xBA80, // ASCII = 'X'	101110101
-  0xBD80, // ASCII = 'Y'	101111011
-  0xAB40, // ASCII = 'Z'	1010101101
-  0xFB80, // ASCII = '['	111110111
-  0xF780, // ASCII = '\'	111101111
-  0xFD80, // ASCII = ']'	111111011
-  0xAFC0, // ASCII = '^'	1010111111
-  0xB680, // ASCII = '_'	101101101
-  0xB7C0, // ASCII = '`'	1011011111
-  0xB000, // ASCII = 'a'	1011
-  0xBE00, // ASCII = 'b'	1011111
-  0xBC00, // ASCII = 'c'	101111
-  0xB400, // ASCII = 'd'	101101
-  0xC000, // ASCII = 'e'	11
-  0xF400, // ASCII = 'f'	111101
-  0xB600, // ASCII = 'g'	1011011
-  0xAC00, // ASCII = 'h'	101011
-  0xD000, // ASCII = 'i'	1101
-  0xF580, // ASCII = 'j'	111101011
-  0xBF00, // ASCII = 'k'	10111111
-  0xD800, // ASCII = 'l'	11011
-  0xEC00, // ASCII = 'm'	111011
-  0xF000, // ASCII = 'n'	1111
-  0xE000, // ASCII = 'o'	111
-  0xFC00, // ASCII = 'p'	111111
-  0xDF80, // ASCII = 'q'	110111111
-  0xA800, // ASCII = 'r'	10101
-  0xB800, // ASCII = 's'	10111
-  0xA000, // ASCII = 't'	101
-  0xDC00, // ASCII = 'u'	110111
-  0xF600, // ASCII = 'v'	1111011
-  0xD600, // ASCII = 'w'	1101011
-  0xDF00, // ASCII = 'x'	11011111
-  0xBA00, // ASCII = 'y'	1011101
-  0xEA80, // ASCII = 'z'	111010101
-  0xADC0, // ASCII = '{'	1010110111
-  0xDD80, // ASCII = '|'	110111011
-  0xAD40, // ASCII = '}'	1010110101
-  0xB5C0, // ASCII = '~'	1011010111
-  0xED40, // ASCII = 127	1110110101
-  0xEF40, // ASCII = 128	1110111101
-  0xEFC0, // ASCII = 129	1110111111
-  0xF540, // ASCII = 130	1111010101
-  0xF5C0, // ASCII = 131	1111010111
-  0xF6C0, // ASCII = 132	1111011011
-  0xF740, // ASCII = 133	1111011101
-  0xF7C0, // ASCII = 134	1111011111
-  0xFAC0, // ASCII = 135	1111101011
-  0xFB40, // ASCII = 136	1111101101
-  0xFBC0, // ASCII = 137	1111101111
-  0xFD40, // ASCII = 138	1111110101
-  0xFDC0, // ASCII = 139	1111110111
-  0xFEC0, // ASCII = 140	1111111011
-  0xFF40, // ASCII = 141	1111111101
-  0xFFC0, // ASCII = 142	1111111111
-  0xAAA0, // ASCII = 143	10101010101
-  0xAAE0, // ASCII = 144	10101010111
-  0xAB60, // ASCII = 145	10101011011
-  0xABA0, // ASCII = 146	10101011101
-  0xABE0, // ASCII = 147	10101011111
-  0xAD60, // ASCII = 148	10101101011
-  0xADA0, // ASCII = 149	10101101101
-  0xADE0, // ASCII = 150	10101101111
-  0xAEA0, // ASCII = 151	10101110101
-  0xAEE0, // ASCII = 152	10101110111
-  0xAF60, // ASCII = 153	10101111011
-  0xAFA0, // ASCII = 154	10101111101
-  0xAFE0, // ASCII = 155	10101111111
-  0xB560, // ASCII = 156	10110101011
-  0xB5A0, // ASCII = 157	10110101101
-  0xB5E0, // ASCII = 158	10110101111
-  0xB6A0, // ASCII = 159	10110110101
-  0xB6E0, // ASCII = 160	10110110111
-  0xB760, // ASCII = 161	10110111011
-  0xB7A0, // ASCII = 162	10110111101
-  0xB7E0, // ASCII = 163	10110111111
-  0xBAA0, // ASCII = 164	10111010101
-  0xBAE0, // ASCII = 165	10111010111
-  0xBB60, // ASCII = 166	10111011011
-  0xBBA0, // ASCII = 167	10111011101
-  0xBBE0, // ASCII = 168	10111011111
-  0xBD60, // ASCII = 169	10111101011
-  0xBDA0, // ASCII = 170	10111101101
-  0xBDE0, // ASCII = 171	10111101111
-  0xBEA0, // ASCII = 172	10111110101
-  0xBEE0, // ASCII = 173	10111110111
-  0xBF60, // ASCII = 174	10111111011
-  0xBFA0, // ASCII = 175	10111111101
-  0xBFE0, // ASCII = 176	10111111111
-  0xD560, // ASCII = 177	11010101011
-  0xD5A0, // ASCII = 178	11010101101
-  0xD5E0, // ASCII = 179	11010101111
-  0xD6A0, // ASCII = 180	11010110101
-  0xD6E0, // ASCII = 181	11010110111
-  0xD760, // ASCII = 182	11010111011
-  0xD7A0, // ASCII = 183	11010111101
-  0xD7E0, // ASCII = 184	11010111111
-  0xDAA0, // ASCII = 185	11011010101
-  0xDAE0, // ASCII = 186	11011010111
-  0xDB60, // ASCII = 187	11011011011
-  0xDBA0, // ASCII = 188	11011011101
-  0xDBE0, // ASCII = 189	11011011111
-  0xDD60, // ASCII = 190	11011101011
-  0xDDA0, // ASCII = 191	11011101101
-  0xDDE0, // ASCII = 192	11011101111
-  0xDEA0, // ASCII = 193	11011110101
-  0xDEE0, // ASCII = 194	11011110111
-  0xDF60, // ASCII = 195	11011111011
-  0xDFA0, // ASCII = 196	11011111101
-  0xDFE0, // ASCII = 197	11011111111
-  0xEAA0, // ASCII = 198	11101010101
-  0xEAE0, // ASCII = 199	11101010111
-  0xEB60, // ASCII = 200	11101011011
-  0xEBA0, // ASCII = 201	11101011101
-  0xEBE0, // ASCII = 202	11101011111
-  0xED60, // ASCII = 203	11101101011
-  0xEDA0, // ASCII = 204	11101101101
-  0xEDE0, // ASCII = 205	11101101111
-  0xEEA0, // ASCII = 206	11101110101
-  0xEEE0, // ASCII = 207	11101110111
-  0xEF60, // ASCII = 208	11101111011
-  0xEFA0, // ASCII = 209	11101111101
-  0xEFE0, // ASCII = 210	11101111111
-  0xF560, // ASCII = 211	11110101011
-  0xF5A0, // ASCII = 212	11110101101
-  0xF5E0, // ASCII = 213	11110101111
-  0xF6A0, // ASCII = 214	11110110101
-  0xF6E0, // ASCII = 215	11110110111
-  0xF760, // ASCII = 216	11110111011
-  0xF7A0, // ASCII = 217	11110111101
-  0xF7E0, // ASCII = 218	11110111111
-  0xFAA0, // ASCII = 219	11111010101
-  0xFAE0, // ASCII = 220	11111010111
-  0xFB60, // ASCII = 221	11111011011
-  0xFBA0, // ASCII = 222	11111011101
-  0xFBE0, // ASCII = 223	11111011111
-  0xFD60, // ASCII = 224	11111101011
-  0xFDA0, // ASCII = 225	11111101101
-  0xFDE0, // ASCII = 226	11111101111
-  0xFEA0, // ASCII = 227	11111110101
-  0xFEE0, // ASCII = 228	11111110111
-  0xFF60, // ASCII = 229	11111111011
-  0xFFA0, // ASCII = 230	11111111101
-  0xFFE0, // ASCII = 231	11111111111
-  0xAAB0, // ASCII = 232	101010101011
-  0xAAD0, // ASCII = 233	101010101101
-  0xAAF0, // ASCII = 234	101010101111
-  0xAB50, // ASCII = 235	101010110101
-  0xAB70, // ASCII = 236	101010110111
-  0xABB0, // ASCII = 237	101010111011
-  0xABD0, // ASCII = 238	101010111101
-  0xABF0, // ASCII = 239	101010111111
-  0xAD50, // ASCII = 240	101011010101
-  0xAD70, // ASCII = 241	101011010111
-  0xADB0, // ASCII = 242	101011011011
-  0xADD0, // ASCII = 243	101011011101
-  0xADF0, // ASCII = 244	101011011111
-  0xAEB0, // ASCII = 245	101011101011
-  0xAED0, // ASCII = 246	101011101101
-  0xAEF0, // ASCII = 247	101011101111
-  0xAF50, // ASCII = 248	101011110101
-  0xAF70, // ASCII = 249	101011110111
-  0xAFB0, // ASCII = 250	101011111011
-  0xAFD0, // ASCII = 251	101011111101
-  0xAFF0, // ASCII = 252	101011111111
-  0xB550, // ASCII = 253	101101010101
-  0xB570, // ASCII = 254	101101010111
-  0xB5B0 // ASCII = 255	101101011011
-};
-
-struct PSKStruct {
-  double* iptr;
-  double* qptr;
-
-  int next;
-};
-
-typedef PSKStruct PSKSTATE;
-
-//Lookup table for determining the next ramp shape depending on the
-//  next symbol and the present output phase.
-// indexing format is [symbol][presentPhase]
-//returns the PSKSTRUCT containing the next phase and the I and Q
-//   ramp table pointers.
 
-static PSKSTATE PSKPhaseLookupTable[6][5] ={
-  // SYMBOL = 0 = SYM_NOCHANGE
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_P, PSKShapeTbl_P, PHZ_0}, //present PHZ_0
-    {PSKShapeTbl_M, PSKShapeTbl_P, PHZ_90}, //present PHZ_90
-    {PSKShapeTbl_M, PSKShapeTbl_M, PHZ_180}, //present PHZ_180
-    {PSKShapeTbl_P, PSKShapeTbl_M, PHZ_270}, //present PHZ_270
-    {PSKShapeTbl_Z, PSKShapeTbl_Z, PHZ_OFF}}, //present PHZ_OFF
-  // SYMBOL = 1 = SYM_P90 = Advance 90 degrees
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_PM, PSKShapeTbl_P, PHZ_90}, //present PHZ_0
-    {PSKShapeTbl_M, PSKShapeTbl_PM, PHZ_180}, //present PHZ_90
-    {PSKShapeTbl_MP, PSKShapeTbl_M, PHZ_270}, //present PHZ_180
-    {PSKShapeTbl_P, PSKShapeTbl_MP, PHZ_0}, //present PHZ_270
-    {PSKShapeTbl_ZP, PSKShapeTbl_ZP, PHZ_0}}, //present PHZ_OFF
-  // SYMBOL = 2 = SYM_P180 = Advance 180 degrees
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_PM, PSKShapeTbl_PM, PHZ_180}, //present PHZ_0
-    {PSKShapeTbl_MP, PSKShapeTbl_PM, PHZ_270}, //present PHZ_90
-    {PSKShapeTbl_MP, PSKShapeTbl_MP, PHZ_0}, //present PHZ_180
-    {PSKShapeTbl_PM, PSKShapeTbl_MP, PHZ_90}, //present PHZ_270
-    {PSKShapeTbl_ZP, PSKShapeTbl_ZP, PHZ_0}}, //present PHZ_OFF
-  // SYMBOL = 3 = SYM_M90	= retard 90 degrees
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_P, PSKShapeTbl_PM, PHZ_270}, //present PHZ_0
-    {PSKShapeTbl_MP, PSKShapeTbl_P, PHZ_0}, //present PHZ_90
-    {PSKShapeTbl_M, PSKShapeTbl_MP, PHZ_90}, //present PHZ_180
-    {PSKShapeTbl_PM, PSKShapeTbl_M, PHZ_180}, //present PHZ_270
-    {PSKShapeTbl_ZP, PSKShapeTbl_ZP, PHZ_0}}, //present PHZ_OFF
-  // SYMBOL = 4 = SYM_OFF
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_PZ, PSKShapeTbl_PZ, PHZ_OFF}, //present PHZ_0
-    {PSKShapeTbl_MZ, PSKShapeTbl_PZ, PHZ_OFF}, //present PHZ_90
-    {PSKShapeTbl_MZ, PSKShapeTbl_MZ, PHZ_OFF}, //present PHZ_180
-    {PSKShapeTbl_PZ, PSKShapeTbl_MZ, PHZ_OFF}, //present PHZ_270
-    {PSKShapeTbl_Z, PSKShapeTbl_Z, PHZ_OFF}}, //present PHZ_OFF
-  // SYMBOL = 5 = SYM_ON
-  //   I ramp shape     Q ramp shape     Next Phase
-  {
-    {PSKShapeTbl_P, PSKShapeTbl_P, PHZ_0}, //present PHZ_0
-    {PSKShapeTbl_MP, PSKShapeTbl_P, PHZ_0}, //present PHZ_90
-    {PSKShapeTbl_MP, PSKShapeTbl_MP, PHZ_0}, //present PHZ_180
-    {PSKShapeTbl_P, PSKShapeTbl_MP, PHZ_0}, //present PHZ_270
-    {PSKShapeTbl_ZP, PSKShapeTbl_ZP, PHZ_0}} //present PHZ_OFF
-};
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-PSKModulator::PSKModulator(int FS, double freq, CTxBuffer *TxBuffer) : CModulator(FS, TxBuffer) {
-
-  m_AmblePtr = 0;
-  int RampSize;
-  int i;
-
-  m_PSKPhaseInc = PI2 * freq / (double) SampleRate; //carrier frequency
-
-  m_PSKSecPerSamp = 1.0 / (double) SampleRate;
-  m_PSKTime = 0.0;
-  m_t = 0.0;
-  m_Ramp = 0;
-  m_PSKPeriodUpdate = 1.0 / SYMBOL_RATE; //symbol period
-  m_Lastsymb = SYM_OFF;
-  m_AddEndingZero = true;
-  m_CWState = 0;
-  m_CWtimer = 0;
-  // Generate cosine ramp envelope lookup tables
-  RampSize = (((100 * SampleRate) / 3125) + 1); //  number of envelope ramp steps per symbol
-  for (i = 0; i < RampSize; i++) {
-    PSKShapeTbl_Z[i] = 0.0;
-    PSKShapeTbl_P[i] = 1.0;
-    PSKShapeTbl_M[i] = -1.0;
-    PSKShapeTbl_PM[i] = cos((double) i * PI2 / (RampSize * 2));
-    PSKShapeTbl_MP[i] = -PSKShapeTbl_PM[i];
-
-    if (i < RampSize / 2) {
-      PSKShapeTbl_PZ[i] = cos((double) i * PI2 / (RampSize * 2));
-      PSKShapeTbl_MZ[i] = -PSKShapeTbl_PZ[i];
-      PSKShapeTbl_ZP[i] = 0.0;
-    } else {
-      PSKShapeTbl_ZP[i] = -cos((double) i * PI2 / (RampSize * 2));
-      PSKShapeTbl_PZ[i] = 0.0;
-      PSKShapeTbl_MZ[i] = 0.0;
-    }
-
-  }
-  i = 0;
-  while (i < 32) //create post/preamble tables
-  {
-    m_Preamble[i] = TXTOG_CODE;
-    m_Postamble[i++] = TXON_CODE;
-  }
-  m_Preamble[i] = 0; // null terminate these tables
-  m_Postamble[i] = 0;
-
-  m_pPSKtxI = PSKShapeTbl_Z;
-  m_pPSKtxQ = PSKShapeTbl_Z;
-  m_PresentPhase = PHZ_OFF;
-  m_TxShiftReg = 0;
-  status = TX_PREAMBLE_STATE;
-
-}
-
-PSKModulator::~PSKModulator() {
+extern Parameter settings;
+extern  unsigned short int VariCode_Table[];
+
+#define SYM_NOCHANGE 0 //Stay the same phase
+#define SYM_P180 2  //Plus 180 deg
+
+PskModulator::PskModulator(int FS, double frequency, CTxBuffer *TxBuffer):CModulator(FS,TxBuffer)
+{
+
+  transition[0][0]=ZZ;  //old 0 new 0
+  transition[0][1]=ZN;  //old 0 new 90
+  transition[0][2]=ZP;  //old 0 new 180
+  transition[0][3]=ZZ7; //old 0 new 270 = -90
+  transition[1][0]=NN;  //old 90 new 90
+  transition[1][1]=NP;  //old 90 new 180
+  transition[1][2]=NZ7; //old 90 new 270 = -90
+  transition[1][3]=NZ;  //old 90 new 0
+  transition[2][0]=PP;  //old 180 new 180
+  transition[2][1]=PZ7; //old 180 new 270 = -90
+  transition[2][2]=PZ;  //old 180 new 0
+  transition[2][3]=PN;  //old 180 new  = 90
+  transition[3][0]=Z7Z7;//old 270 = -90 new 270 = -90
+  transition[3][1]=Z7Z; //old 270 = -90 new 0
+  transition[3][2]=Z7N; //old 270 = -90 new 90
+  transition[3][3]=Z7P; //old 270 = -90 new 180
+
+/**  transition[0][1]=ZZ7;
+  transition[0][3]=ZN;
+  transition[1][0]=Z7Z7;
+  transition[3][0]=NN;**/
+  status=TX_OFF_STATE;
+  addEndingZero=false;
+  amblePtr=0;
+  pState=PZ;
+  aktBit=2;
+
+  aktFrequency=0.;
+  txShiftRegister=0;
+  txFrequencyInc=PI2 * frequency / SampleRate; //carrier frequency
+  symbolSize=(((100 * FS) / 3125) + 1);
+  periodTime=1./31.25;
+  periodDelta=1./FS;
+  period=periodTime;
+  inSymbolPtr=0;
 }
 
-///////////++++++++++++++++++++++++++++++++++////////////////
-///////////   P S K 3 1   M O D U L A T O R  ////////////////
-///////////++++++++++++++++++++++++++++++++++////////////////
-
-
-
-/////////////////////////////////////////////////////////////
-// generates n samples of psk31 waveform in data array pData
-/////////////////////////////////////////////////////////////
-
-int PSKModulator::CalcSignal(double *pData, int n)
- {
-  int symbol;
-  int i;
-
-  //		m_RMSConstant = TX_CONSTANT;
-
-  for (i = 0; i < n; i++) //calculate n samples of tx data stream
-  {
-    m_t += m_PSKPhaseInc; // increment radian phase count
-
-    pData[i] = 0.3 * (m_pPSKtxI[m_Ramp] * sin(m_t) + m_pPSKtxQ[m_Ramp] * cos(m_t));
-    m_Ramp++;
-    m_PSKTime += m_PSKSecPerSamp;
-    if (m_PSKTime >= m_PSKPeriodUpdate)//if time to update envelope ramp index
+int PskModulator::CalcSignal(double *data, int BufferSize)
+{
+  short int c;
+  double x;
+  std::complex<double> temp;
+  std::complex<double> I=std::complex<double>(0.,1.);
+#define amp 0.3
+  for(int i=0; i < BufferSize;i++)
     {
-      m_PSKTime -= m_PSKPeriodUpdate; //keep time bounded
-      m_Ramp = 0; // time to update symbol
-      m_t = fmod(m_t, PI2); //keep radian counter bounded
-      if (status == TX_CWID_STATE)
-        symbol = GetNextCWSymbol();
-      else
-        symbol = GetNextSymbol();
-
-      //get new I/Q ramp tables and next phase
-      m_pPSKtxI = PSKPhaseLookupTable[symbol][m_PresentPhase].iptr;
-      m_pPSKtxQ = PSKPhaseLookupTable[symbol][m_PresentPhase].qptr;
-      m_PresentPhase = PSKPhaseLookupTable[symbol][m_PresentPhase].next;
+      if(period >=periodTime)
+        {
+          period -=periodTime;
+          c=getNextSymbolBit();
+          inSymbolPtr=0;
+          if(status == TX_END_STATE)
+            {
+              for(int j=i;j < BufferSize;j++)
+                {
+                  temp=-amp*(cos(aktFrequency) + sin(aktFrequency)* I);
+                  data[j]=temp.real()+temp.imag();
+                  aktFrequency += txFrequencyInc;
+                  aktFrequency=fmod(aktFrequency,PI2);
+                }
+            return -BufferSize;
+            }
+          pState=transition[aktBit][c];
+          switch(pState)
+           {
+             case ZZ:
+               aktBit=0;
+              break;
+             case ZN:
+               aktBit=1;
+              break;
+             case ZP:
+               aktBit=2;
+              break;
+             case ZZ7:
+               aktBit=3;
+              break;
+             case NN:
+               aktBit=1;
+              break;
+             case NP:
+               aktBit=2;
+              break;
+             case NZ7:
+               aktBit=3;
+              break;
+             case NZ:
+               aktBit=0;
+              break;
+             case PP:
+               aktBit=2;
+              break;
+             case PZ7:
+               aktBit=3;
+              break;
+             case PZ:
+               aktBit=0;
+              break;
+             case PN:
+               aktBit=1;
+              break;
+            case Z7Z7:
+               aktBit=3;
+              break;
+            case Z7Z:
+               aktBit=0;
+              break;
+            case Z7N:
+               aktBit=1;
+              break;
+            case Z7P:
+               aktBit=2;
+              break;
+           }
+
+        }
+       switch(pState)
+         {
+           case ZZ:
+             temp=amp*(cos(aktFrequency) + sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case ZN:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(cos(aktFrequency)+x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case ZP:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(x*cos(aktFrequency) + x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case ZZ7:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(x*cos(aktFrequency) + sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case NN:
+             temp=amp*(cos(aktFrequency) - sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case NZ:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(cos(aktFrequency) -x * sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case NP:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(x*cos(aktFrequency) - sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case NZ7:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(x*cos(aktFrequency)-x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case PP:
+             temp=-amp*(cos(aktFrequency) + sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case PZ7:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(-cos(aktFrequency)-x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case PZ:
+             x=-cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(x*cos(aktFrequency) + x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case PN:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(-x*cos(aktFrequency) - sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case Z7Z7:
+             temp=amp*(-cos(aktFrequency) + sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case Z7Z:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(-x*cos(aktFrequency) + sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case Z7N:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(-x*cos(aktFrequency) + x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+           case Z7P:
+             x=cos((double) inSymbolPtr * M_PI / (double) symbolSize);
+             temp=amp*(-cos(aktFrequency) + x*sin(aktFrequency)*I);
+             data[i]=temp.real() + temp.imag();
+            break;
+          }
+          aktFrequency += txFrequencyInc;
+          aktFrequency=fmod(aktFrequency,PI2);
+          inSymbolPtr++;
+          period +=periodDelta;
     }
-    if (status == TX_END_STATE) // We have reached end of Transmission
-      return -i;
-  }
-  return n;
+    return BufferSize;
 }
 
 
-/////////////////////////////////////////////////////////////
-// called every symbol time to get next CW symbol and get the
-// next character from the character Queue if no more symbols
-// are left to send.
-/////////////////////////////////////////////////////////////
-
-char PSKModulator::GetNextCWSymbol(void) {
-  char symb;
-  int ch;
-  symb = m_Lastsymb; //use last symbol unless it needs to change
-  if ((m_TxShiftReg == 0) && (m_CWState == 0)) {
-    ch = GetChar(); //get next character to xmit
-    if (ch >= 0) //if is not a control code
+char PskModulator::getNextSymbolBit()
+{
+  int bit;
+  if(txShiftRegister != 0)
     {
-      ch &= 0xFF;
-      ch = (int) toupper((char) ch); //make upper case
-      if (ch >= ' ' && ch <= 'Z')
-        m_TxShiftReg = CW_TABLE[ ch - ' ']; //look up pattern
-    } else // is a control code
+      if(txShiftRegister &0x8000)
+        bit=SYM_NOCHANGE;
+      else
+        bit=SYM_P180;
+      txShiftRegister <<=1;
+      if(txShiftRegister == 0)
+        addEndingZero=true;
+    }
+  else
     {
-      if (ch == TXON_CODE)
-        symb = SYM_ON;
+      if(addEndingZero)
+      {
+        bit=SYM_P180;
+        addEndingZero=false;
+       }
       else
-        symb = SYM_OFF;
-      return symb;
+        {
+          int ch;
+          if((ch = getChar())>= 0)
+            {       // No controlcode
+              txShiftRegister = VARICODE_TABLE[ ch&0xFF ];
+              bit=SYM_P180; //Start with a zero
+             }
+          else
+            switch ( ch )
+            {
+              case TXON_CODE:
+              case TXTOG_CODE:    //Idle
+                bit = SYM_P180;
+                break;
+              case TXOFF_CODE:
+                bit = SYM_NOCHANGE;
+                break;
+            }
+        }
     }
-    m_CWState = 0;
-  }
-  switch (m_CWState) // CW timing state machine
-  {
-    case 0: //get next cw symbol state from pattern
-      switch (m_TxShiftReg & 0xC000) {
-        case 0x4000: //dot
-          m_CWState = 1;
-          m_CWtimer = 1 * CW_SPEED;
-          symb = SYM_ON;
-          break;
-        case 0x8000: //dash
-          m_CWState = 1;
-          m_CWtimer = 3 * CW_SPEED;
-          symb = SYM_ON;
-          break;
-        case 0xC000: //inter char space
-          m_CWState = 2;
-          m_CWtimer = 3 * CW_SPEED;
-          symb = SYM_OFF;
-          break;
-        default:
-          symb = SYM_OFF;
-          break;
-      }
-      m_TxShiftReg = m_TxShiftReg << 2; //
-      break;
-    case 1: //On time state
-      if (--m_CWtimer <= 0) {
-        m_CWState = 2;
-        m_CWtimer = 1 * CW_SPEED; //inter symbol time
-        symb = SYM_OFF;
-      } else
-        symb = SYM_NOCHANGE;
-      break;
-    case 2: //Off time state
-      if (--m_CWtimer <= 0)
-        m_CWState = 0;
-      break;
-  }
-  m_Lastsymb = symb;
-  return symb;
+  return bit;
 }
-/////////////////////////////////////////////////////////////
-//get next character/symbol depending on TX state.
-/////////////////////////////////////////////////////////////
-
-int PSKModulator::GetChar() {
+int PskModulator::getChar()
+{
   int ch=0;
-  switch (status) {
-    case TX_OFF_STATE: //is receiving
-      ch = TXOFF_CODE; //else turn off
-      break;
-    case TX_TUNE_STATE:
-      ch = TXON_CODE; // steady carrier
-      break;
-    case TX_PAUSED_STATE:
-      ch = TXTOG_CODE; // steady idle symbol
-      break;
-    case TX_POSTAMBLE_STATE: // ending sequence
-      ch = m_Postamble[m_AmblePtr++];
-      if (ch == 0) //m_Postamble is 0 terminated
-      {
-        m_AmblePtr = 0;
-        ch = TXOFF_CODE;
-        status = TX_END_STATE;
-      }
-      break;
-    case TX_PREAMBLE_STATE: //starting sequence
-      if (!(ch = m_Preamble[m_AmblePtr++])) {
-        status = TX_SENDING_STATE;
-        m_AmblePtr = 0;
-        ch = TXTOG_CODE;
-      }
+  switch(status)
+    {
+     case TX_OFF_STATE:
+      status=TX_PREAMBLE_STATE;
+      amblePtr++;
+      ch=TXON_CODE;
       break;
-    case TX_CWID_STATE: // id sending CW ID
-    /**
-    if( m_AmblePtr >= settings.CWIdString.length() )
-      {
-       m_AmblePtr = 0;
-       ch = TXOFF_CODE;
-       status = TX_END_STATE;
-      }
+    case TX_PREAMBLE_STATE:
+      if(amblePtr++ < 33)
+          ch=TXON_CODE;
       else
-      ch = settings.CWIdString.at(m_AmblePtr++).cell();
-       **/
-      ch = TXOFF_CODE;
-      break;
-    case TX_SENDING_STATE: //if sending text from TX window
-      ch = Buffer->getTxChar();
-      if (ch > 0) {
-        emit charSend((char) ch);
-        m_AmblePtr = 0;
-      } else
-        if (ch == TXOFF_CODE)
-        status = TX_POSTAMBLE_STATE;
-      m_AmblePtr = 0;
-      break;
+        {
+          amblePtr=0;
+          status=TX_SENDING_STATE;
+          ch = TXTOG_CODE;
+        }
+        break;
+      case TX_SENDING_STATE:
+        ch=transmitBuffer->getTxChar();
+        if(ch > 0)
+            emit charSend(ch);
+        if(ch == TXOFF_CODE)
+          {
+            status=TX_POSTAMBLE_STATE;
+            ch = TXTOG_CODE; //Necessary to print last character at receiver side
+            amblePtr=0;
+          }
+        break;
+      case TX_POSTAMBLE_STATE:
+        ch=TXON_CODE;
+        if(amblePtr++ >31)
+          {
+            status=TX_END_STATE;
+            ch=TXOFF_CODE;
+          }
+       break;
     case TX_END_STATE:
-      ch=0;
+      qDebug("TX_END_STATE should never be reached here!");
       break;
-  }
-//  last = ch;
-  return ( ch);
+    }
+  return ch;
 }
-
diff --git a/src/pskmodulator.h b/src/pskmodulator.h
index b3e2454..8b134eb 100644
--- a/src/pskmodulator.h
+++ b/src/pskmodulator.h
@@ -1,110 +1,81 @@
-//////////////////////////////////////////////////////////////////////
-// PSKMod.h: interface for the CPSKMod class.
-//
-//////////////////////////////////////////////////////////////////////
-//      PSK31/CW modulator
-// Copyright 1999.    Moe Wheatley AE4JY  <ae4jy at mindspring.com>
-//
-//This program is free software; you can redistribute it and/or
-//modify it under the terms of the GNU General Public License
-//as published by the Free Software Foundation; either version 2
-//of the License, or any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//GNU General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-//
-//////////////////////////////////////////////////////////////////////
-//
-// Modified by Volker Schroer, DL1KSV, for use in LinPsk
+/***************************************************************************
+ *   Copyright (C) 2012 -2017 by Volker Schroer, DL1KSV                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef PSKMODULATOR_H
+#define PSKMODULATOR_H
 
-#ifndef PSKMOD_H
-#define PSKMOD_H
-
-#include <qobject.h>
-#include <ctype.h>
-
-#include "ctxdisplay.h"
 #include "cmodulator.h"
 
-
-
-class CTxBuffer;
-
-class PSKModulator  : public CModulator
+class PskModulator : public CModulator
 {
-   Q_OBJECT
 public:
-	PSKModulator(int,double,CTxBuffer *);
-	virtual ~PSKModulator();
-// PSK31 and CW modulator
-	int CalcSignal( double* pData , int n);
-/** length = CalcSignal (double *pData, int n)
-		Reads tx  Buffer and calculates the signal values to be transmitted
-		double *pData 	pointer to array for computed signal values
-		n								length of array
-		length 					number of calculated values , normally n
-                    -length at the end of transmission   
-*/
-
-private:
-	QString m_TestString;
-	unsigned int m_AmblePtr;
-	int m_Preamble[33];
-	int m_Postamble[33];
-
-// PSK31 and CW generator variables
-	double m_t;
-	int m_Ramp;
-///	double m_RMSConstant;
+  PskModulator(int FS, double frequency, CTxBuffer *TxBuffer);
+  int CalcSignal(double *data,int BufferSize);
 
-	double m_PSKSecPerSamp;
-	double m_PSKTime;
-	double m_PSKPeriodUpdate;
-	double m_PSKPhaseInc;
-
-
-	double* m_pPSKtxI;
-	double* m_pPSKtxQ;
-	int m_PresentPhase;
-	int m_CWState;
-	int m_CWtimer;
-
-
-// PSK31 and CW modulator private functions
-
-//	char GetNextBPSKSymbol(void);
-//	char GetNextQPSKSymbol(void);
-virtual  char GetNextSymbol(void)=0;
-	char GetNextCWSymbol(void);
 protected:
-	char m_Lastsymb;
-	unsigned short int m_TxShiftReg;
-	int GetChar();
-	bool m_AddEndingZero;
-static const unsigned short int VARICODE_TABLE[];
-enum Status
-{
-TX_END_STATE,				//Xmitting should be stoped
-TX_OFF_STATE,				//TX is off, so we are receiving
-TX_SENDING_STATE,		//TX is sending text
-TX_PAUSED_STATE ,		//TX is paused
-TX_PREAMBLE_STATE,	//TX sending starting preamble
-TX_POSTAMBLE_STATE,	//TX sending ending posteamble
-TX_CWID_STATE,			//TX sending CW ID
-TX_TUNE_STATE			//TX is tuning mode
-};
-Status status; 
-public slots:
-signals: // Signals
-  /** Tx finished */
-//  void finished();
-//  void charSend(char);
+  virtual char getNextSymbolBit()=0;
+  int getChar();
+
+  double aktFrequency;
+  double txFrequencyInc;
+  unsigned short txShiftRegister;
+
+  int symbolSize;
+  int inSymbolPtr;
+  int amblePtr;
+  short int aktBit;
+  enum TxStatus
+  {
+    TX_END_STATE,	//Xmitting should be stoped
+    TX_OFF_STATE,	//TX is off, so we are receiving
+    TX_SENDING_STATE,	//TX is sending text
+    TX_PREAMBLE_STATE,	//TX sending starting preamble
+    TX_POSTAMBLE_STATE	//TX sending ending posteamble
+//  TX_TUNE_STATE	//TX is tuning mode
+  };
+  TxStatus status;
+  enum PhaseState
+  { //    old   , new
+    ZZ,  // 0    , 0
+    ZN,  // 0    , 90
+    ZP,  // 0    , 180
+    ZZ7, // 0    , 270
+    NN , // 90   , 90
+    NP , // 90   , 180
+    NZ7, // 90   , 270
+    NZ , // 90   , 0
+    PZ,  // 180  , 0
+    PN,  // 180  , 90
+    PP,  // 180  , 180
+    PZ7, // 180  , 270
+    Z7Z, // 270  , 0
+    Z7N, // 270  , 90
+    Z7P, // 270  , 180
+    Z7Z7,// 270  , 270
+  };
+  PhaseState pState;
+  PhaseState transition[4][4];
+  double periodTime;
+  double periodDelta;
+  double period;
+
+  bool addEndingZero;
 };
 
-#endif
+#endif // BPSKMODULATOR_H
diff --git a/src/psktable.h b/src/psktable.h
deleted file mode 100644
index 79f187f..0000000
--- a/src/psktable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#if !defined(PSKTablesXYZ)
-#define PSKTablesXYZ
-//////////////////////////////////////////////////////////////////////
-// Copyright 1999.    Moe Wheatley AE4JY  <ae4jy at mindspring.com>
-//
-//This program is free software; you can redistribute it and/or
-//modify it under the terms of the GNU General Public License
-//as published by the Free Software Foundation; either version 2
-//of the License, or any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//GNU General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-//
-//////////////////////////////////////////////////////////////////////
-//
-////////////////////  Various constant tabels  //////////////////////////
-// The word in the CW table is divided into 8 groups of two bits starting
-// at the msb side.  The two bits represent one of four possible states.
-//  00 - end of character
-//  01 - DOT
-//  10 - DASH 
-//  11 - SPACE of two dot times
-const unsigned short int CW_TABLE[59]=
-{
-	0xF000,		// 1111 0000 0000 0000b  ( 32)       WORD SPACE
-	0x0000,		// 0000 0000 0000 0000b  ( 33)  !
-	0x0000,		// 0000 0000 0000 0000b  ( 34)  "
-	0x0000,		// 0000 0000 0000 0000b  ( 35)  #
-	0x0000,		// 0000 0000 0000 0000b  ( 36)  $
-	0x0000,		// 0000 0000 0000 0000b  ( 37)  %
-	0x0000,		// 0000 0000 0000 0000b  ( 38)  &
-	0x0000,		// 0000 0000 0000 0000b  ( 39)  '
-	0x0000,		// 0000 0000 0000 0000b  ( 40)  (
-	0x0000,		// 0000 0000 0000 0000b  ( 41)  )
-	0x566C,		// 0101 0110 0110 1100b  ( 42)  *    ...-.-  SK
-	0x6670,		// 0110 0110 0111 0000b  ( 43)  +    .-.-.   AR
-	0xA5AC,		// 1010 0101 1010 1100b  ( 44)  ,    --..--
-	0x0000,		// 0000 0000 0000 0000b  ( 45)  -
-	0x666C,		// 0110 0110 0110 1100b  ( 46)  .    .-.-.-
-	0x9670,		// 1001 0110 0111 0000b  ( 47)  /    -..-.
-	0xAAB0,		// 1010 1010 1011 0000b  ( 48)  0    -----
-	0x6AB0,		// 0110 1010 1011 0000b  ( 49)  1    .----
-	0x5AB0,		// 0101 1010 1011 0000b  ( 50)  2    ..---
-	0x56B0,		// 0101 0110 1011 0000b  ( 51)  3    ...--
-	0x55B0,		// 0101 0101 1011 0000b  ( 52)  4    ....-
-	0x5570,		// 0101 0101 0111 0000b  ( 53)  5    .....
-	0x9570,		// 1001 0101 0111 0000b  ( 54)  6    -....
-	0xA570,		// 1010 0101 0111 0000b  ( 55)  7    --...
-	0xA970,		// 1010 1001 0111 0000b  ( 56)  8    ---..
-	0xAA70,		// 1010 1010 0111 0000b  ( 57)  9    ----.
-	0x0000,		// 0000 0000 0000 0000b  ( 58)  :
-	0x0000,		// 0000 0000 0000 0000b  ( 59)  ;
-	0x0000,		// 0000 0000 0000 0000b  ( 60)  <    
-	0x95B0,		// 1001 0101 1011 0000b  ( 61)  =    -...-   BT
-	0x0000,		// 0000 0000 0000 0000b  ( 62)  >
-	0x5A5C,		// 0101 1010 0101 1100b  ( 63)  ?    ..--..
-	0x0000,		// 0000 0000 0000 0000b  ( 64)  @
-	0x6C00,		// 0110 1100 0000 0000b  ( 65)  A    .-
-	0x95C0,		// 1001 0101 1100 0000b  ( 66)  B    -...
-	0x99C0,		// 1001 1001 1100 0000b  ( 67)  C    -.-.
-	0x9700,		// 1001 0111 0000 0000b  ( 68)  D    -..
-	0x7000,		// 0111 0000 0000 0000b  ( 69)  E    .
-	0x59C0,		// 0101 1001 1100 0000b  ( 70)  F    ..-.
-	0xA700,		// 1010 0111 0000 0000b  ( 71)  G    --.
-	0x55C0,		// 0101 0101 1100 0000b  ( 72)  H    ....
-	0x5C00,		// 0101 1100 0000 0000b  ( 73)  I    ..
-	0x6AC0,		// 0110 1010 1100 0000b  ( 74)  J    .---
-	0x9B00,		// 1001 1011 0000 0000b  ( 75)  K    -.-
-	0x65C0,		// 0110 0101 1100 0000b  ( 76)  L    .-..
-	0xAC00,		// 1010 1100 0000 0000b  ( 77)  M    --
-	0x9C00,		// 1001 1100 0000 0000b  ( 78)  N    -.
-	0xAB00,		// 1010 1011 0000 0000b  ( 79)  O    ---
-	0x69C0,		// 0110 1001 1100 0000b  ( 80)  P    .--.
-	0xA6C0,		// 1010 0110 1100 0000b  ( 81)  Q    --.-
-	0x6700,		// 0110 0111 0000 0000b  ( 82)  R    .-.
-	0x5700,		// 0101 0111 0000 0000b  ( 83)  S    ...
-	0xB000,		// 1011 0000 0000 0000b  ( 84)  T    -
-	0x5B00,		// 0101 1011 0000 0000b  ( 85)  U    ..-
-	0x56C0,		// 0101 0110 1100 0000b  ( 86)  V    ...-
-	0x6B00,		// 0110 1011 0000 0000b  ( 87)  W    .--
-	0x96C0,		// 1001 0110 1100 0000b  ( 88)  X    -..-
-	0x9AC0,		// 1001 1010 1100 0000b  ( 89)  Y    -.--
-	0xA5C0		// 1010 0101 1100 0000b  ( 90)  Z    --..
-};
-
-
-
-// For the QPSK modulator/demodulator, rate 1/2 constraint length 5 
-//   convolutional FEC coding is used.
-// The generator polynomials used are:
-//  g1(x) = x^4 + x^3           + 1		= 0x19
-//  g0(x) = x^4	+       x^2 + x + 1		= 0x17
-// 
-//                                g1(x)
-//              /----+--------+--------------------------+
-//            /      |        |                          |
-// symbol msb       ---      ---      ---      ---      ---
-//                 | b4|<---| b3|<---| b2|<---| b1|<---| b0| <-- inverted data in
-// symbol lsb       ---      ---      ---      ---      ---
-//            \      |                 |        |        |
-//              \----+-----------------+--------+--------+
-//                                g0(x)
-//
-// Lookup table to get symbol from non-inverted data stream
-/**
-static const unsigned char ConvolutionCodeTable[32] =
-{
-	2, 1, 3, 0, 3, 0, 2, 1,
-	0, 3, 1, 2, 1, 2, 0, 3,
-	1, 2, 0, 3, 0, 3, 1, 2,
-	3, 0, 2, 1, 2, 1, 3, 0 
-};
-**/
-#endif
diff --git a/src/qpskdemodulator.cpp b/src/qpskdemodulator.cpp
index 971371d..a00ca51 100644
--- a/src/qpskdemodulator.cpp
+++ b/src/qpskdemodulator.cpp
@@ -1,12 +1,4 @@
 /***************************************************************************
-                          qpskdemodulator.cpp  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
-
-/***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -15,6 +7,7 @@
  *    based on the work of  Moe Wheatly, AE4JY                             *  
  ***************************************************************************/
 
+#include "firfilter.h"
 #include "qpskdemodulator.h"
 #include "viterbi.h"
 
@@ -51,6 +44,10 @@ v=new Viterbi(5,0x19,0x17,qdistance);
 }
 QPskDemodulator::~QPskDemodulator()
 {
+  if( downFilter )
+    delete downFilter;
+  if ( syncFilter )
+    delete syncFilter;
 }
 void QPskDemodulator::DecodeSymbol(double angle)
 
@@ -107,15 +104,6 @@ char ch =0;
 
 }
 
-//////////////////////////////////////////////////////////////////////
-// Calculate signal quality based on the statistics of the phase
-//	difference angle.  The more dispersion of the "0" and "180" degree
-//  phase shifts, the worse the signal quality.  This information is used
-//  to activate the squelch control.  If 20 consecutive "180" degree shifts
-//  occur, the squelch is forced on, and if 20 consecutive "0" degree
-//  shifts occur, the squelch is forced off quickly.
-//////////////////////////////////////////////////////////////////////
-
 void QPskDemodulator::CalcQuality(  double angle )
 {
 
@@ -134,7 +122,6 @@ else
  }
 if ( angle < 0.0 )
  temp = -temp;
-m_QFreqError = temp;
 temp = fabs(temp);
 
  
@@ -149,4 +136,28 @@ m_DevAve = 100. -m_DevAve *110.;
 
 }
 
+void QPskDemodulator::Init(double Fs ,int BlockSize)
+{
+  SampleRate = Fs;        //sample rate
+  NxSamples = BlockSize;  //size data input buffer
+  downFilter = new FIRFilter(PI2*31.25/Fs,79,ComplexData,10.);
+  syncFilter = new FIRFilter(PI2*31.25*18./Fs,79, ComplexData,5.);
+  downRate = 18;
 
+}
+double QPskDemodulator::calcFreqError(complex<double> s)
+{
+ double x,y;
+ complex<double> z;
+ if (abs(s) >1 )
+  z=s/abs(s);
+ else z=s;
+ x= z.real()*z.imag();
+ x /=5000.; // Adopt deviation to samplerate
+// x /=2.8016548; //Gain
+ y=x_loop_1+x +0.2861361823*y_loop_1;
+ x_loop_1=x;
+ y_loop_1=y;
+ return -y;
+
+}
diff --git a/src/qpskdemodulator.h b/src/qpskdemodulator.h
index 8cbdc1a..4935d33 100644
--- a/src/qpskdemodulator.h
+++ b/src/qpskdemodulator.h
@@ -1,10 +1,3 @@
-/***************************************************************************
-                          qpskdemodulator.h  -  description
-                             -------------------
-    begin                : Sat Jun 2 2001
-    copyright            : (C) 2001 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
 
 /***************************************************************************
  *                                                                         *
@@ -28,18 +21,19 @@ class Viterbi;
 
 class QPskDemodulator : public CPskDemodulator  {
 public: 
-	QPskDemodulator();
-	~QPskDemodulator();
+  QPskDemodulator();
+  ~QPskDemodulator();
+  void Init(double Fs ,int BlockSize);
 
 protected:	
-/** Decodes a QPSK Symbol */
-//void DecodeSymbol( complex<double> newsamp);
-void DecodeSymbol( double);
-
-void CalcQuality(double);	
+  /** Decodes a QPSK Symbol */
+  //void DecodeSymbol( complex<double> newsamp);
+  void DecodeSymbol( double);
+  double calcFreqError(complex<double> s);
+  void CalcQuality(double);
 private:
- double ave1,ave2;
-Viterbi *v;
+  double ave1,ave2;
+  Viterbi *v;
 
 
 };
diff --git a/src/qpskmodulator.cpp b/src/qpskmodulator.cpp
index bc37876..8cd5149 100644
--- a/src/qpskmodulator.cpp
+++ b/src/qpskmodulator.cpp
@@ -1,10 +1,3 @@
-/***************************************************************************
-                          qpskmodulator.cpp  -  description
-                             -------------------
-    begin                : Don Feb 27 2003
-    copyright            : (C) 2003 by Volker Schroer
-    email                : dl1ksv at gmx.de
- ***************************************************************************/
 
 /***************************************************************************
  *                                                                         *
@@ -17,8 +10,8 @@
 
 #include "qpskmodulator.h"
 #include "constants.h"
-#define SYM_OFF 4		//No output
-#define SYM_ON 5		//constant output
+#define SYM_OFF 0		//No change
+#define SYM_ON 2		//Change
 // For the QPSK modulator/demodulator, rate 1/2 constraint length 5
 //   convolutional FEC coding is used.
 // The generator polynomials used are:
@@ -38,66 +31,67 @@
 // Lookup table to get symbol from non-inverted data stream
 static const unsigned char ConvolutionCodeTable[32] =
 {
-	2, 1, 3, 0, 3, 0, 2, 1,
-	0, 3, 1, 2, 1, 2, 0, 3,
-	1, 2, 0, 3, 0, 3, 1, 2,
-	3, 0, 2, 1, 2, 1, 3, 0
+  2, 1, 3, 0, 3, 0, 2, 1,
+  0, 3, 1, 2, 1, 2, 0, 3,
+  1, 2, 0, 3, 0, 3, 1, 2,
+  3, 0, 2, 1, 2, 1, 3, 0
 };
 
-QPskModulator::QPskModulator(int FS,double freq,CTxBuffer *TxBuffer):PSKModulator(FS,freq,TxBuffer)
+QPskModulator::QPskModulator(int FS,double freq,CTxBuffer *TxBuffer):PskModulator(FS,freq,TxBuffer)
 {
-m_TxCodeWord = 0;
+  m_TxCodeWord = 0;
 }
 QPskModulator::~QPskModulator()
 {
 }
-char QPskModulator::GetNextSymbol(void)
+char QPskModulator::getNextSymbolBit(void)
 {
-char symb;
-int ch;
-	symb = ConvolutionCodeTable[m_TxShiftReg&0x1F];	//get next convolution code
-	m_TxShiftReg = m_TxShiftReg<<1;
-	if( m_TxCodeWord == 0 )			//need to get next codeword
-	{
-		if( m_AddEndingZero )		//if need to add a zero
-		{
-			m_AddEndingZero = false;	//end with a zero
-		}
-		else
-		{
-			ch = GetChar();			//get next character to xmit
-			if( ch >=0 )			//if not a control code
-			{						//get next VARICODE codeword to send
-				m_TxCodeWord = VARICODE_TABLE[ ch&0xFF ];
-			}
-			else					//is a control code
-			{
-				switch( ch )
-				{
-				case TXON_CODE:
-					symb = SYM_ON;
-					break;
-				case TXTOG_CODE:
-					m_TxCodeWord = 0;
-					break;
-				case TXOFF_CODE:
-					symb = SYM_OFF;
-					break;
-				}
-			}
-		}
-	}
-	else
-	{
-		if(m_TxCodeWord&0x8000 )
-		{
-			m_TxShiftReg |= 1;
-		}
-		m_TxCodeWord = m_TxCodeWord<<1;
-		if(m_TxCodeWord == 0)
-			m_AddEndingZero = true;	//need to add another zero
-	}
-	return symb;
+  char symb;
+  int ch;
+  symb = ConvolutionCodeTable[txShiftRegister&0x1F];	//get next convolution code
+//  symb=(4-symb)%4;
+  txShiftRegister = txShiftRegister<<1;
+  if( m_TxCodeWord == 0 )			//need to get next codeword
+    {
+      if( addEndingZero )		//if need to add a zero
+        {
+          addEndingZero = false;	//end with a zero
+        }
+      else
+        {
+          ch = getChar();			//get next character to xmit
+          if( ch >=0 )			//if not a control code
+            {						//get next VARICODE codeword to send
+              m_TxCodeWord = VARICODE_TABLE[ ch&0xFF ];
+            }
+          else					//is a control code
+            {
+              switch( ch )
+                {
+                case TXON_CODE:
+                  symb = SYM_ON;
+                  break;
+                case TXTOG_CODE:
+                  m_TxCodeWord = 0;
+                  break;
+                case TXOFF_CODE:
+                  symb = SYM_OFF;
+                  break;
+                }
+            }
+        }
+    }
+  else
+    {
+      if(m_TxCodeWord&0x8000 )
+        {
+          txShiftRegister |= 1;
+        }
+      m_TxCodeWord = m_TxCodeWord<<1;
+      if(m_TxCodeWord == 0)
+        addEndingZero = true;	//need to add another zero
+    }
+  return symb;
 }
 
 
diff --git a/src/qpskmodulator.h b/src/qpskmodulator.h
index 13a3556..50e79a5 100644
--- a/src/qpskmodulator.h
+++ b/src/qpskmodulator.h
@@ -24,11 +24,11 @@ class CTxBuffer;
   *@author Volker Schroer
   */
 
-class QPskModulator : public PSKModulator  {
+class QPskModulator : public PskModulator  {
 public: 
 	QPskModulator(int, double, CTxBuffer *);
 	~QPskModulator();
-char GetNextSymbol(void);
+char getNextSymbolBit(void);
 private:
 
 	unsigned short int m_TxCodeWord;
diff --git a/src/rigcontrol.cpp b/src/rigcontrol.cpp
new file mode 100644
index 0000000..012f05b
--- /dev/null
+++ b/src/rigcontrol.cpp
@@ -0,0 +1,126 @@
+/***************************************************************************
+ *   Copyright (C) 2014 by Volker Schroer, DL1KSV                          *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "rigcontrol.h"
+#include "parameter.h"
+
+#include <QLatin1String>
+extern Parameter settings;
+
+RigControl::RigControl()
+{
+  frequency=0;
+  pwr=0;
+  connected=false;
+  rig= NULL;
+}
+int RigControl::connectRig()
+{
+   int rc;
+   rc = -1;
+   if( (settings.rigModelNumber == 0) || (settings.rigDevice == "None") )
+     return RIG_OK;
+  rig=rig_init(settings.rigModelNumber);
+  if(rig->caps->port_type != RIG_PORT_NONE)
+  {
+    if(rig->caps->port_type == RIG_PORT_SERIAL)
+      {
+        strcpy(rig->state.rigport.pathname,settings.rigDevice.toLatin1());
+        rig->state.rigport.parm.serial.rate=settings.baudrate;
+        rig->state.rigport.parm.serial.handshake = (serial_handshake_e) settings.handshake;
+        rig->state.rigport.retry=3;
+
+      }
+    if (rig)
+      {
+        rc=rig_open(rig);
+        if(rc == RIG_OK )
+          connected=true;
+      }
+  }
+  return rc;
+}
+int RigControl::get_frequency()
+{
+  int rc;
+  freq_t freq;
+  if(connected)
+    {
+      rc = rig_get_freq(rig, RIG_VFO_CURR, &freq);
+      if( rc == RIG_OK)
+        frequency = (int) freq;
+    }
+  return frequency;
+}
+
+void RigControl::set_frequency(int f)
+{
+
+  freq_t freq;
+  if(connected)
+    {
+     freq=f;
+     if(rig_set_freq(rig, RIG_VFO_CURR, freq) == RIG_OK)
+      frequency=f;
+    }
+}
+
+int RigControl::get_pwr()
+{
+  value_t p;
+  if(connected)
+    {
+      if(rig_get_level(rig,RIG_VFO_CURR,RIG_LEVEL_RFPOWER,&p)== RIG_OK )
+        pwr=p.f*100;
+    }
+  return pwr;
+}
+
+void RigControl::set_pwr(int p)
+{
+ value_t pset;
+ if( connected )
+   {
+     pset.f = (float) p/100.;
+     if( rig_set_level(rig,RIG_VFO_CURR,RIG_LEVEL_RFPOWER,pset)== RIG_OK)
+       pwr=p;
+   }
+
+}
+void RigControl::disconnectRig()
+{
+  if ( (rig != NULL) && connected)
+    {
+     rig_close(rig);
+     rig_cleanup(rig);
+    }
+  rig = NULL;
+  connected=false;
+}
+bool RigControl::isConnected()
+{
+  return connected;
+}
+QLatin1String RigControl::getModelName()
+{
+  if(rig == NULL)
+    return QLatin1String("None");
+  else
+  return QLatin1String(rig->caps->model_name);
+}
diff --git a/gui/addmacro.h b/src/rigcontrol.h
similarity index 71%
copy from gui/addmacro.h
copy to src/rigcontrol.h
index c82a42d..a2b4653 100644
--- a/gui/addmacro.h
+++ b/src/rigcontrol.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2012 by Volker Schroer, DL1KSV                          *
+ *   Copyright (C) 2014 by Volker Schroer, DL1KSV                          *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -17,39 +17,33 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef ADDMACRO_H
-#define ADDMACRO_H
+#ifndef RIGCONTROL_H
+#define RIGCONTROL_H
 
-#include <QDialog>
-#include <QString>
-#include <QModelIndex>
+#include <hamlib/rig.h>
 
-#include "constants.h"
+class QLatin1String;
 
-namespace Ui {
-  class AddMacro;
-}
-
-class AddMacro : public QDialog
+class RigControl
 {
-  Q_OBJECT
-
 public:
-  AddMacro(QVector<Macro> *macroList,QStringList tokenList,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
-  ~AddMacro();
-
-public slots:
+  RigControl();
+  int get_frequency();
+  void set_frequency(int f);
+  int get_pwr();
+  void set_pwr(int p);
+  int connectRig();
+  void disconnectRig();
+  bool isConnected();
+  QLatin1String getModelName();
+private:
 
-protected:
+RIG *rig;
 
-protected slots:
-  virtual void  accept();
-  void insertKeyword(QModelIndex);
-private:
-  Ui::AddMacro *ui;
-  QVector<Macro> *mL;
+int frequency;
+int pwr;
 
+bool connected;
 };
 
-#endif
-
+#endif // RIGCONTROL_H
diff --git a/src/rttydemodulator.cpp b/src/rttydemodulator.cpp
index 46314f8..97d653b 100755
--- a/src/rttydemodulator.cpp
+++ b/src/rttydemodulator.cpp
@@ -15,7 +15,7 @@
  ***************************************************************************/
 
 #include "rttydemodulator.h"
-#include "firfilter.h"
+//#include "firfilter.h"
 #include "constants.h"
 
 
@@ -127,7 +127,7 @@ char RTTYDemodulator::baudot_code ( char data )
   return c;
 }
 
-bool RTTYDemodulator::Init ( double FS, int  )
+void RTTYDemodulator::Init( double FS, int  )
 {
   SampleRate = FS;
   Baudrate = 45.45;
@@ -142,7 +142,6 @@ bool RTTYDemodulator::Init ( double FS, int  )
   F1inc = 0.;
   F0max = 0.;
   F1max = 0.;
-  return true;
 }
 
 void RTTYDemodulator::ProcessInput ( double *input, double * )
diff --git a/src/rttydemodulator.h b/src/rttydemodulator.h
index aa9965a..fe28a34 100755
--- a/src/rttydemodulator.h
+++ b/src/rttydemodulator.h
@@ -45,7 +45,7 @@ public:
 /** Prozess the input */
  void ProcessInput(double * input, double *);
  int getSquelchValue();
- bool Init(double,int);
+ void Init(double,int);
  virtual double get2RxFrequency();
  virtual void setParameter(RxTxParameterType,void * );
  virtual void *getParameter(RxTxParameterType);
diff --git a/src/rttymodulator.cpp b/src/rttymodulator.cpp
index 58c26a3..e765d57 100644
--- a/src/rttymodulator.cpp
+++ b/src/rttymodulator.cpp
@@ -12,7 +12,7 @@
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
- *    based on the work of  Moe Wheatly, AE4JY                             *  
+ *    based on the work of  Moe Wheatly, AE4JY                             *
  ***************************************************************************/
 
 #include "rttymodulator.h"
@@ -24,35 +24,35 @@ extern Parameter settings;
 RTTYModulator::RTTYModulator(int FS,double frequency,CTxBuffer *TxBuffer) : CModulator(FS,TxBuffer)
 
 {
-Baudrate=45;
-NumberofStopBits=Onepoint5;
-SamplesPerBit=SampleRate/Baudrate;
-f0=frequency;
-f1=frequency+170.;
-xr=1.0;
-xi=0.0;
-dr[0]=cos(f0*2.0*M_PI/SampleRate);
-di[0]=sin(f0*2.0*M_PI/SampleRate);
-dr[1]=cos(f1*2.0*M_PI/SampleRate);
-di[1]=sin(f1*2.0*M_PI/SampleRate);
+  Baudrate=45;
+  NumberofStopBits=Onepoint5;
+  SamplesPerBit=SampleRate/Baudrate;
+  f0=frequency;
+  f1=frequency+170.;
+  xr=1.0;
+  xi=0.0;
+  dr[0]=cos(f0*2.0*M_PI/SampleRate);
+  di[0]=sin(f0*2.0*M_PI/SampleRate);
+  dr[1]=cos(f1*2.0*M_PI/SampleRate);
+  di[1]=sin(f1*2.0*M_PI/SampleRate);
 
 
 
-NxSamples=SamplesPerBit;
-actBit=0;  // Startbit
-BitsPerChar = 5;
-BitinChar=0;
-actChar=0;
-status=TX_PREAMBLE_STATE;
+  NxSamples=SamplesPerBit;
+  actBit=0;  // Startbit
+  BitsPerChar = 5;
+  BitinChar=0;
+  actChar=0;
+  status=TX_PREAMBLE_STATE;
 
-actCharacterStatus=IGNORE;
-secondchar =0;
+  actCharacterStatus=IGNORE;
+  secondchar =0;
 
-//Initialize ExtraParameter
-extraParameter.stopbits=Onepoint5;
-extraParameter.parity=None;
-extraParameter.reverse=true;
-extraParameter.offset=170;
+  //Initialize ExtraParameter
+  extraParameter.stopbits=Onepoint5;
+  extraParameter.parity=None;
+  extraParameter.reverse=true;
+  extraParameter.offset=170;
 }
 RTTYModulator::~RTTYModulator()
 {
@@ -61,410 +61,404 @@ RTTYModulator::~RTTYModulator()
 
 int RTTYModulator::CalcSignal(double *data,int BUFSIZE)
 {
-int i;
-for(i=0;i<BUFSIZE;i++)
-{
- if ( NxSamples >= SamplesPerBit) // get next bit , NxSamples will be reset in getNextBit
-    actBit = getNextBit();
- if ( status == TX_END_STATE)
- {
-  if (i >0) i--;
-   return -i;
- }
- // Calculate next Sample
- data[i] = calcNextSample(actBit);
- NxSamples++;
-}
-return BUFSIZE;
+  int i;
+  for(i=0;i<BUFSIZE;i++)
+    {
+      if ( NxSamples >= SamplesPerBit) // get next bit , NxSamples will be reset in getNextBit
+        actBit = getNextBit();
+      if ( status == TX_END_STATE)
+        {
+          if (i >0) i--;
+          return -i;
+        }
+      // Calculate next Sample
+      data[i] = calcNextSample(actBit);
+      NxSamples++;
+    }
+  return BUFSIZE;
 }
 
 int RTTYModulator::getNextBit()
 {
-int bit;
+  int bit;
 
-NxSamples =0;
-switch(status)
-	{
-	case TX_PREAMBLE_STATE:       							
-  	bit = 1;
-//		if (BitinChar++ >= Baudrate)
-		if (BitinChar++ >= 1)
-				{
-				status = TX_SENDING_STATE;
-				TX_Status = Startbit;
-				actChar = getChar();
-				if (actChar < 0 )
-					{
-						if ( actChar == TXOFF_CODE )
-							status = TX_END_STATE;
-						else     // No character to transmit at the moment
-							TX_Status = WaitingforChar;
-					}
-				}
-		break;
-	case TX_SENDING_STATE:
-			switch(TX_Status)
-				{
-				case WaitingforChar:
-					actChar = getChar();
-					bit = 1;
-					if ( actChar < 0 )
-						{
-							if ( actChar == TXOFF_CODE )
-								status = TX_END_STATE;
-							else
-								TX_Status = Startbit;
-								actChar = 0;
-							break;
-						}
-					else
-						TX_Status = Startbit; // We got a char to transmit, so start with startbit
-																	// direct
-				case Startbit:
-					bit=0;
-					BitinChar = 0;
-					TX_Status = SendChar;
+  NxSamples =0;
+  switch(status)
+    {
+    case TX_PREAMBLE_STATE:
+      bit = 1;
+      //		if (BitinChar++ >= Baudrate)
+      if (BitinChar++ >= 1)
+        {
+          status = TX_SENDING_STATE;
+          TX_Status = Startbit;
+          actChar = getChar();
+          if (actChar < 0 )
+            {
+              if ( actChar == TXOFF_CODE )
+                status = TX_END_STATE;
+              else     // No character to transmit at the moment
+                TX_Status = WaitingforChar;
+            }
+        }
+      break;
+    case TX_SENDING_STATE:
+      switch(TX_Status)
+        {
+        case WaitingforChar:
+          actChar = getChar();
+          bit = 1;
+          if ( actChar < 0 )
+            {
+              if ( actChar == TXOFF_CODE )
+                status = TX_END_STATE;
+              else
+                TX_Status = Startbit;
+              actChar = 0;
+              break;
+            }
+          else
+            TX_Status = Startbit; // We got a char to transmit, so start with startbit
+          // direct
+        case Startbit:
+          bit=0;
+          BitinChar = 0;
+          TX_Status = SendChar;
           break;
-				case SendChar:
-					if (BitinChar < BitsPerChar )
-						{
-							bit = actChar & 1;
-							BitinChar++;
-							actChar >>=1;
-						}
-					if (BitinChar == BitsPerChar)
-							TX_Status = Stopbit;
-				break;
-				case Stopbit:
-					switch (NumberofStopBits)
-						{
-						case One:
-							NxSamples=0;
-							break;
-						case Onepoint5:
-							NxSamples=-SamplesPerBit/2;
-							break;
-						case Two:
-							NxSamples= - SamplesPerBit;
-							break;
-						}
-///					actChar = getChar();
-					bit = 1;
-///					if ( actChar == TXOFF_CODE )
-///						status = TX_END_STATE;
-///					else
-///					TX_Status = Startbit;
-					TX_Status = WaitingforChar;
-
-				break;
-			  }
-		break;
-//	case TX_POSTAMBLE_STATE:
-//		break;	
-	case TX_TUNE_STATE:
-		actChar = getChar();
-		bit =0;
-		if ( actChar == TXOFF_CODE)
-				status = TX_END_STATE;
-		break;
-	case TX_END_STATE:
-		bit=1;
-		break;
+        case SendChar:
+          if (BitinChar < BitsPerChar )
+            {
+              bit = actChar & 1;
+              BitinChar++;
+              actChar >>=1;
+            }
+          if (BitinChar == BitsPerChar)
+            TX_Status = Stopbit;
+          break;
+        case Stopbit:
+          switch (NumberofStopBits)
+            {
+            case One:
+              NxSamples=0;
+              break;
+            case Onepoint5:
+              NxSamples=-SamplesPerBit/2;
+              break;
+            case Two:
+              NxSamples= - SamplesPerBit;
+              break;
+            }
+          bit = 1;
+          TX_Status = WaitingforChar;
+          break;
+        }
+      break;
+      //	case TX_POSTAMBLE_STATE:
+      //		break;
+    case TX_TUNE_STATE:
+      actChar = getChar();
+      bit =0;
+      if ( actChar == TXOFF_CODE)
+        status = TX_END_STATE;
+      break;
+    case TX_END_STATE:
+      bit=1;
+      break;
 
 
-	}
+    }
 
 
-return bit;
+  return bit;
 }
 double RTTYModulator::calcNextSample(unsigned int bit)
 {
-double temp;
-temp = xr *dr[bit] - xi*di[bit];
-xi = xr *di[bit] + xi*dr[bit];
-xr = temp;
-temp = 2.0 -(xr*xr+xi*xi);
-xr *=temp;
-xi *=temp;
+  double temp;
+  temp = xr *dr[bit] - xi*di[bit];
+  xi = xr *di[bit] + xi*dr[bit];
+  xr = temp;
+  temp = 2.0 -(xr*xr+xi*xi);
+  xr *=temp;
+  xi *=temp;
 
-return  xr;
+  return  xr;
 }
 
 int RTTYModulator::Char2Baudot(int character)
 {
-int value;
-static const char symbols[128]=
-	{
-	0x00,				// NULL               0
-	0x00,				// SOH   undefined    1
-	0x00,				// STX       "        2
-	0x00,				// ETX       "        3
-	0x00,				// EOT	     "        4
-	0x09,				// ENQ                5
-	0x00,				// ACK	undefined     6
-	0x0A,				// BEL                7
-	0x08,				// BS			?						8
-	0x00,				// HT		undefined			9
-	0x02,				// LF                10
-	0x00,				// VT		undefined		 11
-	0x00,				// FF				"        12
-	0x08,				// CR								 13
-	0x00,				// SO		undefined    14
-	0x00,				// SI				"        15
-	0x00,				// DLE	undefined    16
-	0x00,				// DC1			"				 17
-	0x00,				// DC2			"				 18
-	0x00,				// DC3			"        19
-	0x00,				// DC4			"				 20
-	0x00,				// NAK			"				 21		
-	0x00,				// SYN			"				 22
-	0x00,				// ETB			"				 23
-	0x00,				// CAN			"        24
-	0x00,				// EM 			"				 25
-	0x00,				// SUB			"				 26		
-	0x00,				// ESC			"				 27
-	0x00,				// FS 			"				 28
-	0x00,				// GS	 		  "        29
-	0x00,				// RS 	 		"				 30
-	0x00,				// US		  	"				 31		
-	0x04,				// SPACE						 32
-	0x00,				// !	   undefined	 33
-	0x11,				// "								 34
-	0x14,				// #								 35
-	0x09,				// $								 36
-	0x00,				// %		 undefinded	 37
-	0x00,				// &				"        38
-	0x05,				// '				"				 39
-	0x0f,				// (								 40
-	0x12,				// )								 41
-	0x00,				// *			undefined  42
-	0x11,				// +								 43
-	0x0c,				// ,								 44
-	0x03,				// -								 45
-	0x1A,				// .								 46
-	0x1d,				// /								 47
-	0x16,				// 0								 48
-	0x17,				// 1								 49
-	0x13,				// 2								 50
-	0x01,				// 3								 51
-	0x0A,				// 4								 52
-	0x10,				// 5								 53
-	0x15,       // 6								 54			
- 	0x07,				// 7								 55
-	0x06,				// 8								 56
-	0x18,				// 9								 57
-	0x0E,				// :								 58
-	0x1e,				// ;								 59
-	0x00,				// <		undefined		 60
-	0x1e,				// =			?					 61
-	0x00,				// >		undefined 	 62
-	0x19,				// ?								 63
-	0x00,				// @		undefined		 64
-	0x03,				// A								 65
-	0x19,				// B								 66
-	0x0E,				// C								 67
-	0x09,				// D								 68
-	0x01,				// E								 69
-	0x0D,				// F								 70
-	0x1A,				// G								 71
-	0x14,				// H								 72
-	0x06,				// I								 73
-	0x0b,				// J								 74
-	0x0F,				// K								 75
-	0x12,				// L								 76
-	0x1C,				// M								 77
-	0x0C,				// N								 78
-	0x18,				// O								 79
-	0x16,				// P								 80
-	0x17,				// Q								 81
-	0x0A,				// R								 82
-	0x05,				// S								 83
-	0x10,				// T							   84
-	0x07,				// U								 85
-	0x1E,				// V								 86
-	0x13,				// W								 87
-	0x1D,				// X								 88
-	0x15,				// Y								 89
-	0x11,				// Z								 90
-	0x00,				// [ 		undefined		 91
-	0x00,				// \				"				 92
-	0x00,				// ]				"				 93
-	0x00,				// ^				"				 94
-	0x00,				// _				"				 95
-	0x00,				// '				"				 96
-	0x03,				// A								 97
-	0x19,				// B								 98
-	0x0E,				// C								 99
-	0x09,				// D								100
-	0x01,				// E								101
-	0x0D,				// F								102
-	0x1A,				// G								103
-	0x14,				// H								104
-	0x06,				// I								105
-	0x0b,				// J								106
-	0x0F,				// K								107
-	0x12,				// L								108
-	0x1C,				// M								109
-	0x0C,				// N								110
-	0x18,				// O								111
-	0x16,				// P								112
-	0x17,				// Q								113
-	0x0A,				// R								114
-	0x05,				// S								115
-	0x10,				// T							  116
-	0x07,				// U								117
-	0x1E,				// V								118
-	0x13,				// W								119
-	0x1D,				// X								120
-	0x15,				// Y								121
-	0x11,				// Z								122
-	0x00,				// { 		undefined		123
-	0x00,				// \				"				124
-	0x00,				// }				"				125
-	0x00,				// ~				"				126
-	0x00				// DEL			"				127
-	};
-static const CharacterStatus shift[128] =
-	{
+  int value;
+  static const char symbols[128]=
+  {
+    0x00,  // NULL               0
+    0x00,  // SOH   undefined    1
+    0x00,  // STX       "        2
+    0x00,  // ETX       "        3
+    0x00,  // EOT       "        4
+    0x09,  // ENQ                5
+    0x00,  // ACK   undefined    6
+    0x0A,  // BEL                7
+    0x08,  // BS   backspace     8
+    0x00,  // HT    undefined    9
+    0x02,  // LF                10
+    0x00,  // VT    undefined   11
+    0x00,  // FF    undefined   12
+    0x08,  // CR                13
+    0x00,  // SO   undefined    14
+    0x00,  // SI   undefinde    15
+    0x00,  // DLE  undefined    16
+    0x00,  // DC1      "        17
+    0x00,  // DC2      "        18
+    0x00,  // DC3      "        19
+    0x00,  // DC4      "        20
+    0x00,  // NAK      "        21
+    0x00,  // SYN      "        22
+    0x00,  // ETB      "        23
+    0x00,  // CAN      "        24
+    0x00,  // EM       "        25
+    0x00,  // SUB      "        26
+    0x00,  // ESC      "        27
+    0x00,  // FS       "        28
+    0x00,  // GS       "        29
+    0x00,  // RS       "        30
+    0x00,  // US       "        31
+    0x04,  // SPACE             32
+    0x00,  // !     undefined   33
+    0x11,  // "                 34
+    0x14,  // #                 35
+    0x09,  // $                 36
+    0x00,  // %     undefinded  37
+    0x00,  // &         "       38
+    0x05,  // '         "       39
+    0x0f,  // (                 40
+    0x12,  // )                 41
+    0x00,  // *      undefined  42
+    0x11,  // +                 43
+    0x0c,  // ,                 44
+    0x03,  // -                 45
+    0x1A,  // .                 46
+    0x1d,  // /                 47
+    0x16,  // 0                 48
+    0x17,  // 1                 49
+    0x13,  // 2                 50
+    0x01,  // 3                 51
+    0x0A,  // 4                 52
+    0x10,  // 5                 53
+    0x15,  // 6	                54
+    0x07,  // 7                 55
+    0x06,  // 8                 56
+    0x18,  // 9	                57
+    0x0E,  // :                 58
+    0x1e,  // ;                 59
+    0x00,  // <	   undefined    60
+    0x1e,  // =	                61
+    0x00,  // >    undefined    62
+    0x19,  // ?                 63
+    0x00,  // @	   undefined    64
+    0x03,  // A                 65
+    0x19,  // B                 66
+    0x0E,  // C                 67
+    0x09,  // D                 68
+    0x01,  // E                 69
+    0x0D,  // F                 70
+    0x1A,  // G                 71
+    0x14,  // H                 72
+    0x06,  // I                 73
+    0x0b,  // J                 74
+    0x0F,  // K                 75
+    0x12,  // L                 76
+    0x1C,  // M                 77
+    0x0C,  // N                 78
+    0x18,  // O                 79
+    0x16,  // P                 80
+    0x17,  // Q	                81
+    0x0A,  // R	                82
+    0x05,  // S	                83
+    0x10,  // T	                84
+    0x07,  // U	                85
+    0x1E,  // V	                86
+    0x13,  // W	                87
+    0x1D,  // X	                88
+    0x15,  // Y	                89
+    0x11,  // Z	                90
+    0x00,  // [    undefined    91
+    0x00,  // \	       "        92
+    0x00,  // ]	       "        93
+    0x00,  // ^	       "        94
+    0x00,  // _	       "        95
+    0x00,  // '	       "        96
+    0x03,  // A	                97
+    0x19,  // B	                98
+    0x0E,  // C	                99
+    0x09,  // D	               100
+    0x01,  // E	               101
+    0x0D,  // F	               102
+    0x1A,  // G	               103
+    0x14,  // H	               104
+    0x06,  // I	               105
+    0x0b,  // J	               106
+    0x0F,  // K	               107
+    0x12,  // L	               108
+    0x1C,  // M	               109
+    0x0C,  // N	               110
+    0x18,  // O	               111
+    0x16,  // P	               112
+    0x17,  // Q	               113
+    0x0A,  // R	               114
+    0x05,  // S	               115
+    0x10,  // T	               116
+    0x07,  // U	               117
+    0x1E,  // V	               118
+    0x13,  // W	               119
+    0x1D,  // X	               120
+    0x15,  // Y	               121
+    0x11,  // Z	               122
+    0x00,  // {   undefined    123
+    0x00,  // \       "        124
+    0x00,  // }	      "        125
+    0x00,  // ~	      "        126
+    0x00   // DEL     "        127
+  };
+  static const CharacterStatus shift[128] =
+  {
+
+    IGNORE,IGNORE,IGNORE,IGNORE,  // 4* IGNORE
+    FIGS,
+    IGNORE,
+    FIGS,
+    IGNORE,IGNORE,IGNORE,IGNORE,  // 26 * IGNORE
+    IGNORE,IGNORE,IGNORE,IGNORE,
+    IGNORE,IGNORE,IGNORE,IGNORE,
+    IGNORE,IGNORE,IGNORE,IGNORE,
+    IGNORE,IGNORE,IGNORE,IGNORE,
+    IGNORE,IGNORE,IGNORE,IGNORE,
+    IGNORE,IGNORE,
+    FIGS,FIGS,FIGS,              // 3 * FIGS
+    IGNORE,
+    FIGS,FIGS,FIGS,FIGS,         // 4 * FIGS
+    IGNORE,
+    FIGS,FIGS,FIGS,FIGS,FIGS,    // 17 * FIGS
+    FIGS,FIGS,FIGS,FIGS,FIGS,
+    FIGS,FIGS,FIGS,FIGS,FIGS,
+    FIGS,FIGS,
+    IGNORE,
+    FIGS,
+    IGNORE,
+    FIGS,
+    IGNORE,
+    LTRS,LTRS,LTRS,LTRS, 					//26 * LTRS
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,
+    IGNORE,IGNORE,IGNORE,IGNORE,  // 6* IGNORE
+    IGNORE,IGNORE,
+    LTRS,LTRS,LTRS,LTRS,					// 26 * LTRS
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,LTRS,LTRS,
+    LTRS,LTRS,
+    IGNORE,IGNORE,IGNORE,IGNORE,   // 5 * IGNORE
+    IGNORE
 
-	 	IGNORE,IGNORE,IGNORE,IGNORE,  // 4* IGNORE
-		FIGS,
-		IGNORE,
-		FIGS,
-		IGNORE,IGNORE,IGNORE,IGNORE,  // 26 * IGNORE
-	 	IGNORE,IGNORE,IGNORE,IGNORE,
-	 	IGNORE,IGNORE,IGNORE,IGNORE,
-	 	IGNORE,IGNORE,IGNORE,IGNORE,
-	 	IGNORE,IGNORE,IGNORE,IGNORE,
-	 	IGNORE,IGNORE,IGNORE,IGNORE,
-	 	IGNORE,IGNORE,
-		FIGS,FIGS,FIGS,              // 3 * FIGS
-		IGNORE,
-		FIGS,FIGS,FIGS,FIGS,         // 4 * FIGS
-		IGNORE,
-		FIGS,FIGS,FIGS,FIGS,FIGS,    // 17 * FIGS
-		FIGS,FIGS,FIGS,FIGS,FIGS,
-		FIGS,FIGS,FIGS,FIGS,FIGS,
-		FIGS,FIGS,
-		IGNORE,
-		FIGS,
-		IGNORE,
-		FIGS,
-		IGNORE,
-		LTRS,LTRS,LTRS,LTRS, 					//26 * LTRS
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,
-		IGNORE,IGNORE,IGNORE,IGNORE,  // 6* IGNORE
-		IGNORE,IGNORE,
-		LTRS,LTRS,LTRS,LTRS,					// 26 * LTRS
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,LTRS,LTRS,
-		LTRS,LTRS,
-		IGNORE,IGNORE,IGNORE,IGNORE,   // 5 * IGNORE
-		IGNORE
+  };
+  switch (shift[character])
+    {
+    case IGNORE:
+      value = symbols[character];
+      break;
+    case LTRS:
+      if ( actCharacterStatus != LTRS)
+        {
+          value = 0x1f;
+          secondchar = symbols[character];
+          actCharacterStatus = LTRS;
+        }
+      else
+        value = symbols[character];
+      break;
+    case FIGS:
+      if ( actCharacterStatus != FIGS)
+        {
+          value = 0x1b;
+          secondchar = symbols[character];
+          actCharacterStatus = FIGS;
+        }
+      else
+        value = symbols[character];
+      break;
 
-	};
-switch (shift[character])
-	{
-	case IGNORE:
-		value = symbols[character];
-		break;
-	case LTRS:
-		if ( actCharacterStatus != LTRS)
-			{
-				value = 0x1f;
-				secondchar = symbols[character];
-				actCharacterStatus = LTRS;
-			}
-		else
-			value = symbols[character];
-		break;
-	case FIGS:
-		if ( actCharacterStatus != FIGS)
-			{
-				value = 0x1b;
-				secondchar = symbols[character];
-				actCharacterStatus = FIGS;
-			}
-		else
-			value = symbols[character];
-		break;
-			
-	}
-return value;
+    }
+  return value;
 }
 
 int RTTYModulator::getChar()
 {
-int value;
-char ch;
-	
-ch = 0;
+  int value;
+  char ch;
+
+  ch = 0;
 
-if (secondchar != 0)
-	{
-		value = secondchar;
-		secondchar = 0;
-	}
-else
-	do
-		{
-			value =   Buffer->getTxChar();
-				if ( value > 0 )
-					{
-						ch = value;
-						if ( value > 127 )
-						value = value -128;
-					value = Char2Baudot(value);
-	       }
-		}   while ( value == 0 );
-if (ch > 0)
-	emit charSend(ch);
-return value;
+  if (secondchar != 0)
+    {
+      value = secondchar;
+      secondchar = 0;
+    }
+  else
+    do
+    {
+      value =   transmitBuffer->getTxChar();
+      if ( value > 0 )
+        {
+          ch = value;
+          if ( value > 127 )
+            value = value -128;
+          value = Char2Baudot(value);
+        }
+    }   while ( value == 0 );
+  if (ch > 0)
+    emit charSend(ch);
+  return value;
 }
 
 void RTTYModulator::setParameter(RxTxParameterType Type,void *Value)
 {
- switch (Type)
- {
-  case Reverse:
-   extraParameter.reverse =  * (bool *) Value;
-   break;
-  case Offset:
-   extraParameter.offset = * (int *) Value;
-   break;
-  case Parity:
-   extraParameter.parity = * (Paritaet *) Value;
-   break;
-  case Extra:
-   extraParameter = * (ExtraParameter *) Value;
-   break; 
-  default:
-   break;
- }
- init(); 
+  switch (Type)
+    {
+    case Reverse:
+      extraParameter.reverse =  * (bool *) Value;
+      break;
+    case Offset:
+      extraParameter.offset = * (int *) Value;
+      break;
+    case Parity:
+      extraParameter.parity = * (Paritaet *) Value;
+      break;
+    case Extra:
+      extraParameter = * (ExtraParameter *) Value;
+      break;
+    default:
+      break;
+    }
+  init();
 }
 void RTTYModulator::init()
 {
- f1=f0+extraParameter.offset;
- if (!extraParameter.reverse)
- {
-  float x; //Change Mark and Space Frequency
-  x=f0;
-  f0=f1;
-  f1=x;
- }
- xr=1.0;
- xi=0.0;
- dr[0]=cos(f0*2.0*M_PI/SampleRate);
- di[0]=sin(f0*2.0*M_PI/SampleRate);
- dr[1]=cos(f1*2.0*M_PI/SampleRate);
- di[1]=sin(f1*2.0*M_PI/SampleRate); 
+  f1=f0+extraParameter.offset;
+  if (!extraParameter.reverse)
+    {
+      float x; //Change Mark and Space Frequency
+      x=f0;
+      f0=f1;
+      f1=x;
+    }
+  xr=1.0;
+  xi=0.0;
+  dr[0]=cos(f0*2.0*M_PI/SampleRate);
+  di[0]=sin(f0*2.0*M_PI/SampleRate);
+  dr[1]=cos(f1*2.0*M_PI/SampleRate);
+  di[1]=sin(f1*2.0*M_PI/SampleRate);
 }
diff --git a/src/spectrumwindow.cpp b/src/spectrumwindow.cpp
index 6691c3b..dfece76 100644
--- a/src/spectrumwindow.cpp
+++ b/src/spectrumwindow.cpp
@@ -33,6 +33,11 @@ SpectrumWindow::SpectrumWindow(QWidget *parent) :
   pdisplay->fill();
   Farbe=0;
 }
+void SpectrumWindow::setDisplayRange(int minfreq, int maxfreq)
+{
+  minDisplayfrequency=minfreq;
+  maxDisplayfrequency=maxfreq;
+}
 void SpectrumWindow::resizeEvent(QResizeEvent *)
 {
   int x=2*frameWidth();
@@ -41,7 +46,7 @@ void SpectrumWindow::resizeEvent(QResizeEvent *)
   pdisplay =new QPixmap (this->width()-x,this->height()-x);
   pdisplay->fill();
   QPainter p(pdisplay);
-  paintLineal(&p,pdisplay->width(),pdisplay->height(),100,2500);
+  paintLineal(&p,pdisplay->width(),pdisplay->height(),minDisplayfrequency,maxDisplayfrequency);
   p.end();
 }
 
@@ -117,7 +122,7 @@ void SpectrumWindow::plotSpectrum(bool overload,float *fftdata,int minfreq,int m
       z=(int)(((  pRx->getRxFrequency()-minfreq)*xmax)/(maxfreq-minfreq)+0.5);
       p.drawLine(z,0,z,ymax);
 
-      if ( (z =  pRx->get2RxFrequency()) != 0 ) // RTTY demands to lines
+      if ( (z =  pRx->get2RxFrequency()) != 0 ) // RTTY demands two lines
         {
           z=(( z-minfreq)*xmax)/(maxfreq-minfreq);
           p.drawLine(z,0,z,ymax);
@@ -171,7 +176,7 @@ void SpectrumWindow::plotVector ( QPainter *p )
   xc = xc + 20;
   yc = yc + 20;
   p->setPen ( Qt::green );
-  for(int i=0; i< 11; i++)
+  for(int i=0; i< PHASE_DISPLAY_BUFFER_LENGTH; i++)
   {
     mag=abs(Phase[i]);
     if ( mag > 0.001)
diff --git a/src/spectrumwindow.h b/src/spectrumwindow.h
index e2e3dd6..4f3e381 100644
--- a/src/spectrumwindow.h
+++ b/src/spectrumwindow.h
@@ -30,6 +30,7 @@ class SpectrumWindow : public QFrame
 public:
   explicit SpectrumWindow(QWidget *parent = 0);
   void plotSpectrum(bool overload, float *fftdata, int minfreq, int maxfreq);
+  void setDisplayRange(int minfreq, int maxfreq);
   void setColorList(QList<QColor> *c);
   void mousePressEvent ( QMouseEvent *e );
   void setPhasePointer(std::complex<float> *);
@@ -40,6 +41,8 @@ private:
   QPixmap *pdisplay;   // Display for double buffering
   int baseline; // Y Position of X- Axis in window
   std::complex<float> *Phase;
+  int minDisplayfrequency;
+  int maxDisplayfrequency;
 
 protected:
     void resizeEvent( QResizeEvent * );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/linpsk.git



More information about the pkg-hamradio-commits mailing list