/*************************************************************************** mfskmodulator.cpp - description ------------------- begin : Fre Feb 28 2003 copyright : (C) 2003 by Volker Schroer email : dl1ksv@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. * ***************************************************************************/ #include "mfskmodulator.h" #include "mfskvaricode.h" #include "ctxbuffer.h" #include "interleaver.h" #include "feccoder.h" 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; symbol=0; varicode=0; NumberofTones=16; 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 ( int i=0; igetTxChar(); if ( ch < 0 ) { if ( ch == TXOFF_CODE) return ch; else ch = 0; // } 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) ) { int bits; if ( varicode & bitposition ) bits=Fec->FECEncode(1); else bits=Fec->FECEncode(0); bitcounter +=2; bitposition = bitposition >> 1; symbol = ( symbol << 2 ); symbol = symbol | (bits & 3); } if ( bitposition == 0) Allbitsgone = true; if ( bitcounter == 4 ) { for (int i=0;i < 10; i++) symbol = leave[i].interleave(symbol); ch = grayencode(symbol); bitcounter = 0; symbol = 0; return ch; } } }