/*************************************************************************** * Copyright (C) 2004 by Johan Maes - ON4QZ * * on4qz@telenet.be * * http://users.telenet.be/on4qz * * * * 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 SYNTHES_H #define SYNTHES_H #include #define SINTABLEN 1024 class synthesizer { public: synthesizer(double txSmpClock); ~synthesizer(); short int nextSample(double freq) { double temp; int t; short int i; previousAngle=oldAngle; temp=(freq/txSamplingClock)*(double)SINTABLEN+oldAngle; oldAngle=fmod(temp,SINTABLEN); t=(int)(oldAngle+0.5); //t=(int)(oldAngle); i=sineTable[t%SINTABLEN]; return i; } /* short int nextSample(double ) { if((counter%10)==0) { if (state==-1) state=1; else state=-1; } counter++; return state*20000; } */ void unget() { oldAngle=previousAngle; /* counter--; if((counter%10)==0) { if (state==-1) state=1; else state=-1; }*/ } private: double txSamplingClock; double oldAngle; double previousAngle; short int sineTable[SINTABLEN]; /* int counter; int state;*/ }; #endif