// HamFax -- an application for sending and receiving amateur radio facsimiles // Copyright (C) 2001,2002 // Christof Schmitt, DH1CS // // 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 "Config.hpp" #include "FaxTransmitter.hpp" #include FaxTransmitter::FaxTransmitter(QObject* parent, FaxImage* faxImage) : QObject(parent), image(faxImage) { } void FaxTransmitter::start(int sampleRate) { Config& config=Config::instance(); startLength=config.readNumEntry("/hamfax/APT/startLength"); startFreq=config.readNumEntry("/hamfax/APT/startFrequency"); stopLength=config.readNumEntry("/hamfax/APT/stopLength"); stopFreq=config.readNumEntry("/hamfax/APT/stopFrequency"); lpm=config.readNumEntry("/hamfax/fax/LPM"); phasingLines=config.readNumEntry("/hamfax/phasing/lines"); phaseInvers=config.readBoolEntry("/hamfax/phasing/invert"); color=config.readBoolEntry("/hamfax/fax/color"); this->sampleRate=sampleRate; state=APTSTART; sampleNr=0; } void FaxTransmitter::doNext(int n) { double lineSamples=60.0*sampleRate/lpm; double buf[n]; for(int i=0; i=0.975 ) ? (phaseInvers?0.0:1.0) : (phaseInvers?1.0:0.0); sampleNr++; } else { state=ENDPHASING; sampleNr=0; } } if(state==ENDPHASING) { if(sampleNr(std::fmod(sampleNr,lineSamples) /lineSamples*cols); int r=static_cast(sampleNr/lineSamples); if(row!=r) { emit imageLine((row=r)/(color?3:1)); } buf[i]=image->getPixel(c, color? r/3:r, color? r%3:3)/255.0; sampleNr++; } else { state=APTSTOP; sampleNr=0; emit aptStop(); } } if(state==APTSTOP) { if(sampleNrrows=rows; this->cols=cols; } void FaxTransmitter::doAptStop(void) { state=APTSTOP; sampleNr=0; emit aptStop(); }