00001 /*************************************************************************** 00002 * Copyright (C) 2003 by Gav Wood * 00003 * gav@cs.york.ac.uk * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Library General Public License as * 00007 * published by the Free Software Foundation; either version 2 of the * 00008 * License, or (at your option) any later version. * 00009 ***************************************************************************/ 00010 #ifndef _SIGNALTYPES_SPECTRUM_H 00011 #define _SIGNALTYPES_SPECTRUM_H 00012 00013 #ifdef __GEDDEI_BUILD 00014 #include "signaltype.h" 00015 #else 00016 #include <geddei/signaltype.h> 00017 #endif 00018 using namespace Geddei; 00019 00020 namespace SignalTypes 00021 { 00022 00032 class Spectrum: public SignalType 00033 { 00034 virtual void serialise(QSocketSession &sink) const; 00035 virtual void deserialise(QSocketSession &source); 00036 virtual const uint id() const { return 2; } 00037 virtual const bool sameAsBE(const SignalType *cmp) const; 00038 virtual SignalType *copyBE() const { return new Spectrum(theScope, theFrequency, theStep); } 00039 00040 protected: 00041 float theStep; 00042 00043 public: 00050 const float bandFrequency(uint band) const { return band * theStep; } 00051 00058 const uint size() const { return theScope; } 00059 00066 const float step() const { return theStep; } 00067 00074 const float nyquist() const { return float(theScope) * theStep; } 00075 00085 Spectrum(const uint size = 1, const float frequency = 0, const float step = 1) : SignalType(size, frequency), theStep(step) {} 00086 }; 00087 00088 }; 00089 00090 #endif