Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

VrMixer.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2002 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 /*
00023  *
00024  *  Copyright 1997 Massachusetts Institute of Technology
00025  * 
00026  *  Permission to use, copy, modify, distribute, and sell this software and its
00027  *  documentation for any purpose is hereby granted without fee, provided that
00028  *  the above copyright notice appear in all copies and that both that
00029  *  copyright notice and this permission notice appear in supporting
00030  *  documentation, and that the name of M.I.T. not be used in advertising or
00031  *  publicity pertaining to distribution of the software without specific,
00032  *  written prior permission.  M.I.T. makes no representations about the
00033  *  suitability of this software for any purpose.  It is provided "as is"
00034  *  without express or implied warranty.
00035  * 
00036  */
00037 
00038 
00039 #ifndef _VRMIXER_H_
00040 #define _VRMIXER_H_
00041 
00042 #include <VrSigProc.h>
00043 
00044 template<class iType,class oType> 
00045 class VrMixer : public VrSigProc {
00046 protected:
00047   double freq;
00048   double arg;
00049   double argInc;
00050   void evaluate(int n);
00051   virtual void initialize();
00052 public: 
00053   virtual const char *name() { return "VrMixer"; }
00054   virtual int work(VrSampleRange output, void *ao[],
00055                    VrSampleRange inputs[], void *ai[]);
00056   VrMixer(double f) :VrSigProc(1,sizeof(iType),sizeof(oType)),freq(f),arg(0) { }
00057 };
00058 
00059 template<class iType,class oType> int
00060 VrMixer<iType,oType>::work(VrSampleRange output, void *ao[],
00061                 VrSampleRange inputs[], void *ai[])
00062 {
00063   iType **i = (iType**)ai;
00064   oType **o = (iType**)ao;
00065   int size = output.size;
00066   while(size -- > 0) {
00067     *o[0]++ = (oType) (*i[0]++ * sin(arg));
00068     arg += argInc;
00069   }
00070   return output.size;
00071 }
00072 
00073 template<class iType,class oType> void
00074 VrMixer<iType,oType>::initialize()  
00075 {
00076   argInc = 2*M_PI*freq*(1 / (double)getInputSamplingFrequencyN(0));
00077 }
00078 #endif

Generated on Tue Mar 15 23:55:34 2005 for GNU Radio by  doxygen 1.4.0