CLAM::Spectrum Class Reference

Spectrum is a ProcessingData class that allows the following representations: Mag/Phase, Complex, Polar and Break Point Function (BPF). More...

#include <Spectrum.hxx>

List of all members.

Public Member Functions

 Spectrum ()
 Spectrum (const Spectrum &prototype, const bool shareData=false, const bool deep=true)
 __COMMON_DYNAMIC_TYPE (Spectrum, 10)
 __COMMON_DYN_ATTRIBUTE (0, public, EScale, Scale) protected
 The kind of scale.
bool LoadScale (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (1, public, TData, SpectralRange) protected
bool LoadSpectralRange (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (4, public, DataArray, MagBuffer) protected
bool LoadMagBuffer (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (5, public, DataArray, PhaseBuffer) protected
bool LoadPhaseBuffer (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (6, public, Array< Complex >, ComplexArray) protected
bool LoadComplexArray (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (7, public, Array< Polar >, PolarArray) protected
bool LoadPolarArray (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (8, public, BPF, MagBPF) protected
bool LoadMagBPF (CLAM::Storage &s)
 __COMMON_DYN_ATTRIBUTE (9, public, BPF, PhaseBPF) protected
bool LoadPhaseBPF (CLAM::Storage &s)
 Spectrum (const SpectrumConfig &newConfig)
void Configure (const SpectrumConfig &newConfig)
void GetConfig (SpectrumConfig &c) const
 This method synchronizes the Type attribute in the prConfig attribute before returning it.
TData GetMag (TIndex pos) const
 Returns spectral magnitude in a given bin position.
TData GetMag (TData freq) const
 Returns spectral magnitude from a given frequency Inefficient Get, for efficiency work directly on the buffer.
TData GetPhase (TIndex pos) const
 Returns spectral phase in a given bin position Inefficient Get, for efficiency work directly on the buffer.
TData GetPhase (TData freq) const
 Returns spectral phase from a given frequency Inefficient Get, for efficiency work directly on the buffer.
void SetMag (TIndex pos, TData newMag)
 Sets spectral magnitude in a given bin position Inefficient Set, for efficiency work directly on the buffer.
void SetMag (TData freq, TData newMag)
 Sets spectral magnitude from a given frequency Inefficient Set, for efficiency work directly on the buffer.
void SetPhase (TIndex pos, TData newPhase)
 Sets spectral phase in a given bin position Inefficient Set, for efficiency work directly on the buffer.
void SetPhase (TData freq, TData newPhase)
 Sets spectral phase from a given frequency Inefficient Set, for efficiency work directly on the buffer.
void SynchronizeTo (const SpecTypeFlags &tmpFlags)
 Synchronizes all data to the one of the specified type.
void SynchronizeTo (const Spectrum &in)
 Synchronizes all data to the one of the input spectrum.
void SynchronizeTo (const SpecTypeFlags &tmpFlags, const Spectrum &in)
 Actual Synchronization routine.
int GetSize () const
 Getter for accessing size of the spectrum.
void SetSize (int s)
 Sets spectrum size.
int GetBPFSize () const
 Getter for accessing BPF size, useful only if that representation is being used.
void SetBPFSize (int s)
 Setter for BPF size, useful only if that representation is being used.
void GetType (SpecTypeFlags &f) const
 This is not just an accessor.
void SetType (const SpecTypeFlags &newFlags)
 This method updates the instantiation of dynamic attributes acording to the given flags, and sets up the attribute buffers to the correct sice.
void SetTypeSynchronize (const SpecTypeFlags &newFlags)
 Same as set Type but additionaly the data on new buffers is synchronized to existing data.
void ToDB ()
 Converts scale from linear to dB.
void ToLinear ()
 Converts scales from dB to linear.
TIndex IndexFromFreq (TData freq) const
 Returns index from a given frequency.
void Complex2Polar ()
 Convert from Complex to Polar Buffer.
void Polar2Complex ()
 Convert from Polar to Complex Buffer.
void Complex2MagPhase ()
 Convert from Complex to Mag/Phase buffers.
void Polar2MagPhase ()
 Convert from Polar to Mag/Phase buffers.
void MagPhase2Polar ()
 Convert from Mag/Phase to Polar.
void MagPhase2Complex ()
 Convert from Mag/Phase to Complex.
void MagPhase2BPF ()
 Convert to BPF.
void BPF2MagPhase ()
 Convert from BPF to MagPhase.
void Complex2Polar (const Spectrum &in)
 Convert from Complex to Polar Buffer.
void Polar2Complex (const Spectrum &in)
 Convert from Polar to Complex Buffer.
void Complex2MagPhase (const Spectrum &in)
 Convert from Complex to Mag/Phase buffers.
void Polar2MagPhase (const Spectrum &in)
 Convert from Polar to Mag/Phase buffers.
void MagPhase2Polar (const Spectrum &in)
 Convert from Mag/Phase to Polar.
void MagPhase2Complex (const Spectrum &in)
 Convert from Mag/Phase to Complex.
void MagPhase2BPF (const Spectrum &in)
 Convert to BPF.
void BPF2MagPhase (const Spectrum &in)
 Convert from BPF to MagPhase.

Protected Member Functions

void DefaultInit ()
 The concrete dynamic type constructor calls DefaultInit().

Detailed Description

Spectrum is a ProcessingData class that allows the following representations: Mag/Phase, Complex, Polar and Break Point Function (BPF).

Different interfaces are offered but for efficiency you should directly access buffers. Synchronization routines between different possible representations are also offered.

See also:
ProcessingData

Definition at line 45 of file Spectrum.hxx.


Constructor & Destructor Documentation

CLAM::Spectrum::Spectrum (  )  [inline]

Definition at line 48 of file Spectrum.hxx.

CLAM::Spectrum::Spectrum ( const Spectrum prototype,
const bool  shareData = false,
const bool  deep = true 
) [inline]

Definition at line 48 of file Spectrum.hxx.

Spectrum::Spectrum ( const SpectrumConfig newConfig  ) 

Definition at line 88 of file Spectrum.cxx.

References Configure().


Member Function Documentation

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
BPF  ,
PhaseBPF   
) [inline]

Definition at line 64 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
BPF  ,
MagBPF   
) [inline]

Definition at line 63 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
Array< Polar ,
PolarArray   
) [inline]

Definition at line 62 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
Array< Complex ,
ComplexArray   
) [inline]

Definition at line 61 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
DataArray  ,
PhaseBuffer   
) [inline]

Definition at line 60 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
DataArray  ,
MagBuffer   
) [inline]

Definition at line 59 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
TData  ,
SpectralRange   
) [inline]

Definition at line 53 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE ( ,
public  ,
EScale  ,
Scale   
) [inline]

The kind of scale.

Definition at line 52 of file Spectrum.hxx.

CLAM::Spectrum::__COMMON_DYNAMIC_TYPE ( Spectrum  ,
10   
)
void Spectrum::BPF2MagPhase ( const Spectrum in  )  [inline]

Convert from BPF to MagPhase.

Definition at line 720 of file Spectrum.cxx.

References BPF2MagPhase().

void Spectrum::BPF2MagPhase (  )  [inline]

Convert from BPF to MagPhase.

Definition at line 725 of file Spectrum.cxx.

Referenced by BPF2MagPhase(), and SynchronizeTo().

void Spectrum::Complex2MagPhase ( const Spectrum in  )  [inline]

Convert from Complex to Mag/Phase buffers.

Definition at line 628 of file Spectrum.cxx.

References Complex2MagPhase().

void Spectrum::Complex2MagPhase (  )  [inline]

Convert from Complex to Mag/Phase buffers.

Definition at line 633 of file Spectrum.cxx.

Referenced by Complex2MagPhase(), and SynchronizeTo().

void Spectrum::Complex2Polar ( const Spectrum in  )  [inline]

Convert from Complex to Polar Buffer.

Definition at line 574 of file Spectrum.cxx.

References CLAM::ComplexToPolarCnv< T >::ToPolar().

void Spectrum::Complex2Polar (  )  [inline]

Convert from Complex to Polar Buffer.

Definition at line 580 of file Spectrum.cxx.

References CLAM::ComplexToPolarCnv< T >::ToPolar().

Referenced by SynchronizeTo().

void Spectrum::Configure ( const SpectrumConfig newConfig  ) 
void Spectrum::DefaultInit ( void   )  [protected]

The concrete dynamic type constructor calls DefaultInit().

This allows user to initialize his/her object. But we define DefaultInit() here because we don't want to force writting one DefaultInit() function for each concrete dynamic type. If a dynamic type concrete class defines some (not-default) constructors, this should also call the DefaultInit().

See also:
CopyInit()

Reimplemented from CLAM::DynamicType.

Definition at line 122 of file Spectrum.cxx.

References Configure().

int Spectrum::GetBPFSize (  )  const

Getter for accessing BPF size, useful only if that representation is being used.

Note that BPF size has nothing to do with spectral size, it is just the number of points used to represent the spectrum in a break-point function manner.

See also:
BPF

Definition at line 789 of file Spectrum.cxx.

References CLAM_ASSERT, CLAM_BEGIN_CHECK, CLAM_END_CHECK, and GetSize().

Referenced by CLAM::FDFilterGen::Do(), GetConfig(), ToDB(), and ToLinear().

void Spectrum::GetConfig ( SpectrumConfig c  )  const

This method synchronizes the Type attribute in the prConfig attribute before returning it.

The case of BPFSize is a little triky: the configuration object will have it instantiated only if it's different from the spectrum size. When a Spectrum is configurated with a config without BPFSize, it's assumed that the "normal" size will be used for the BPF

Definition at line 94 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, GetBPFSize(), GetSize(), and CLAM::DynamicType::UpdateData().

TData Spectrum::GetMag ( TData  freq  )  const

Returns spectral magnitude from a given frequency Inefficient Get, for efficiency work directly on the buffer.

Definition at line 366 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_ASSERT, GetType(), and IndexFromFreq().

TData Spectrum::GetMag ( TIndex  pos  )  const

Returns spectral magnitude in a given bin position.

Inefficient Get, for efficiency work directly on the buffer

Definition at line 350 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_ASSERT, and GetType().

Referenced by CLAM::SpectralPeakDetect::Do(), and CLAM::SpectralPeakArrayInterpolator::Do().

TData Spectrum::GetPhase ( TData  freq  )  const

Returns spectral phase from a given frequency Inefficient Get, for efficiency work directly on the buffer.

Definition at line 399 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_ASSERT, GetType(), and IndexFromFreq().

TData Spectrum::GetPhase ( TIndex  pos  )  const

Returns spectral phase in a given bin position Inefficient Get, for efficiency work directly on the buffer.

Definition at line 383 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_ASSERT, and GetType().

Referenced by CLAM::SpectralPeakDetect::Do().

int Spectrum::GetSize (  )  const
void Spectrum::GetType ( SpecTypeFlags f  )  const
TIndex Spectrum::IndexFromFreq ( TData  freq  )  const [inline]

Returns index from a given frequency.

Definition at line 849 of file Spectrum.cxx.

References GetSize(), and Round().

Referenced by GetMag(), GetPhase(), SetMag(), and SetPhase().

bool CLAM::Spectrum::LoadComplexArray ( CLAM::Storage s  )  [inline]

Definition at line 61 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadMagBPF ( CLAM::Storage s  )  [inline]

Definition at line 63 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadMagBuffer ( CLAM::Storage s  )  [inline]

Definition at line 59 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadPhaseBPF ( CLAM::Storage s  )  [inline]

Definition at line 64 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadPhaseBuffer ( CLAM::Storage s  )  [inline]

Definition at line 60 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadPolarArray ( CLAM::Storage s  )  [inline]

Definition at line 62 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadScale ( CLAM::Storage s  )  [inline]

Definition at line 52 of file Spectrum.hxx.

bool CLAM::Spectrum::LoadSpectralRange ( CLAM::Storage s  )  [inline]

Definition at line 53 of file Spectrum.hxx.

void Spectrum::MagPhase2BPF ( const Spectrum in  )  [inline]

Convert to BPF.

Definition at line 697 of file Spectrum.cxx.

References MagPhase2BPF().

void Spectrum::MagPhase2BPF (  )  [inline]

Convert to BPF.

Definition at line 702 of file Spectrum.cxx.

Referenced by MagPhase2BPF(), and SynchronizeTo().

void Spectrum::MagPhase2Complex ( const Spectrum in  )  [inline]

Convert from Mag/Phase to Complex.

Definition at line 673 of file Spectrum.cxx.

References MagPhase2Complex().

void Spectrum::MagPhase2Complex (  )  [inline]

Convert from Mag/Phase to Complex.

Definition at line 678 of file Spectrum.cxx.

Referenced by MagPhase2Complex(), and SynchronizeTo().

void Spectrum::MagPhase2Polar ( const Spectrum in  )  [inline]

Convert from Mag/Phase to Polar.

Definition at line 648 of file Spectrum.cxx.

References MagPhase2Polar().

void Spectrum::MagPhase2Polar (  )  [inline]

Convert from Mag/Phase to Polar.

Definition at line 654 of file Spectrum.cxx.

Referenced by MagPhase2Polar(), and SynchronizeTo().

void Spectrum::Polar2Complex ( const Spectrum in  )  [inline]

Convert from Polar to Complex Buffer.

Definition at line 586 of file Spectrum.cxx.

References CLAM::ComplexToPolarCnv< T >::ToComplex().

void Spectrum::Polar2Complex (  )  [inline]

Convert from Polar to Complex Buffer.

Definition at line 592 of file Spectrum.cxx.

References CLAM::ComplexToPolarCnv< T >::ToComplex().

Referenced by SynchronizeTo().

void Spectrum::Polar2MagPhase ( const Spectrum in  )  [inline]

Convert from Polar to Mag/Phase buffers.

Definition at line 608 of file Spectrum.cxx.

References Polar2MagPhase().

void Spectrum::Polar2MagPhase (  )  [inline]

Convert from Polar to Mag/Phase buffers.

Definition at line 613 of file Spectrum.cxx.

Referenced by Polar2MagPhase(), and SynchronizeTo().

void Spectrum::SetBPFSize ( int  s  ) 

Setter for BPF size, useful only if that representation is being used.

Note that BPF size has nothing to do with spectral size, it is just the number of points used to represent the spectrum in a break-point function manner.

See also:
BPF

Definition at line 803 of file Spectrum.cxx.

References CLAM::DynamicType::UpdateData().

Referenced by CLAM::FDFilterGen::Do().

void Spectrum::SetMag ( TData  freq,
TData  newMag 
)

Sets spectral magnitude from a given frequency Inefficient Set, for efficiency work directly on the buffer.

Definition at line 432 of file Spectrum.cxx.

References IndexFromFreq(), and SetMag().

void Spectrum::SetMag ( TIndex  pos,
TData  newMag 
)

Sets spectral magnitude in a given bin position Inefficient Set, for efficiency work directly on the buffer.

Definition at line 416 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_cos(), CLAM_sin(), and GetType().

Referenced by SetMag().

void Spectrum::SetPhase ( TData  freq,
TData  newPhase 
)

Sets spectral phase from a given frequency Inefficient Set, for efficiency work directly on the buffer.

Definition at line 454 of file Spectrum.cxx.

References IndexFromFreq(), and SetPhase().

void Spectrum::SetPhase ( TIndex  pos,
TData  newPhase 
)

Sets spectral phase in a given bin position Inefficient Set, for efficiency work directly on the buffer.

Definition at line 437 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_cos(), CLAM_sin(), and GetType().

Referenced by SetPhase().

void Spectrum::SetSize ( int  s  ) 
void Spectrum::SetType ( const SpecTypeFlags newFlags  ) 

This method updates the instantiation of dynamic attributes acording to the given flags, and sets up the attribute buffers to the correct sice.

Definition at line 186 of file Spectrum.cxx.

References GetSize().

Referenced by CLAM::SDIFFileReader::ReadFrame(), SetTypeSynchronize(), CLAM::SpectralFocus::SpectralFocus(), and CLAM::SpectralSpread::SpectralSpread().

void Spectrum::SetTypeSynchronize ( const SpecTypeFlags newFlags  ) 

Same as set Type but additionaly the data on new buffers is synchronized to existing data.

Definition at line 824 of file Spectrum.cxx.

References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, GetType(), SetType(), and SynchronizeTo().

void Spectrum::SynchronizeTo ( const SpecTypeFlags tmpFlags,
const Spectrum in 
)
void Spectrum::SynchronizeTo ( const Spectrum in  ) 

Synchronizes all data to the one of the input spectrum.

Definition at line 558 of file Spectrum.cxx.

References GetType(), and SynchronizeTo().

void Spectrum::SynchronizeTo ( const SpecTypeFlags tmpFlags  ) 

Synchronizes all data to the one of the specified type.

Definition at line 459 of file Spectrum.cxx.

Referenced by CLAM::FFT_ooura::Do(), SetTypeSynchronize(), and SynchronizeTo().

void Spectrum::ToDB (  ) 
void Spectrum::ToLinear (  ) 

The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.3