Spectrum is a ProcessingData class that allows the following representations: Mag/Phase, Complex, Polar and Break Point Function (BPF). More...
#include <Spectrum.hxx>
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(). |
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.
Definition at line 45 of file Spectrum.hxx.
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().
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 9 | , | |
public | , | |||
BPF | , | |||
PhaseBPF | ||||
) | [inline] |
Definition at line 64 of file Spectrum.hxx.
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 8 | , | |
public | , | |||
BPF | , | |||
MagBPF | ||||
) | [inline] |
Definition at line 63 of file Spectrum.hxx.
Definition at line 62 of file Spectrum.hxx.
Definition at line 61 of file Spectrum.hxx.
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 5 | , | |
public | , | |||
DataArray | , | |||
PhaseBuffer | ||||
) | [inline] |
Definition at line 60 of file Spectrum.hxx.
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 4 | , | |
public | , | |||
DataArray | , | |||
MagBuffer | ||||
) | [inline] |
Definition at line 59 of file Spectrum.hxx.
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 1 | , | |
public | , | |||
TData | , | |||
SpectralRange | ||||
) | [inline] |
Definition at line 53 of file Spectrum.hxx.
CLAM::Spectrum::__COMMON_DYN_ATTRIBUTE | ( | 0 | , | |
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::ToPolar().
void Spectrum::Complex2Polar | ( | ) | [inline] |
Convert from Complex to Polar Buffer.
Definition at line 580 of file Spectrum.cxx.
References CLAM::ComplexToPolarCnv::ToPolar().
Referenced by SynchronizeTo().
void Spectrum::Configure | ( | const SpectrumConfig & | newConfig | ) |
Definition at line 127 of file Spectrum.cxx.
References CLAM::DynamicType::SetPreAllocateAllAttributes(), and CLAM::DynamicType::UpdateData().
Referenced by DefaultInit(), CLAM::SynthSineSpectrum::Do(), and Spectrum().
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().
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.
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().
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().
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().
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().
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 |
Getter for accessing size of the spectrum.
Definition at line 732 of file Spectrum.cxx.
References CLAM_ASSERT, CLAM_BEGIN_CHECK, and CLAM_END_CHECK.
Referenced by CLAM::DataUtil::CheckMembers(), CLAM::SpectralDescriptors::ComputeHighFrequencyContent(), CLAM::SpectralDescriptors::ComputeMaxMagFreq(), CLAM::SpectralDescriptors::ComputeRolloff(), CLAM::DataUtil::CopyResidualSpectrumsMembers(), CLAM::SpectralPhaseModulation::Do(), CLAM::SpectralPeakDetect::Do(), CLAM::SpectralNotch::Do(), CLAM::SpectralEnvelopeApply::Do(), CLAM::SpectralDelay::Do(), CLAM::FDCombFilter::Do(), GetBPFSize(), GetConfig(), IndexFromFreq(), CLAM::SpectrumInterpolator::SetPrototypes(), CLAM::SpectrumAdder2::SetPrototypes(), SetType(), SynchronizeTo(), ToDB(), and ToLinear().
void Spectrum::GetType | ( | SpecTypeFlags & | f | ) | const |
This is not just an accessor.
The Type attribute is updated in the mConfig object before returning it.
Definition at line 841 of file Spectrum.cxx.
References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, and CLAM::SpecTypeFlags::bPolar.
Referenced by GetMag(), GetPhase(), SetMag(), SetPhase(), CLAM::SpectrumInterpolator::SetPrototypes(), CLAM::SpectrumAdder2::SetPrototypes(), CLAM::IFFT_ooura::SetPrototypes(), SetTypeSynchronize(), and SynchronizeTo().
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] |
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::ToComplex().
void Spectrum::Polar2Complex | ( | ) | [inline] |
Convert from Polar to Complex Buffer.
Definition at line 592 of file Spectrum.cxx.
References CLAM::ComplexToPolarCnv::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.
Definition at line 803 of file Spectrum.cxx.
References CLAM::DynamicType::UpdateData().
Referenced by CLAM::FDFilterGen::Do().
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().
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().
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().
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 | ) |
Sets spectrum size.
Definition at line 763 of file Spectrum.cxx.
Referenced by CLAM::DataUtil::CheckMembers(), CLAM::DataUtil::CopyResidualSpectrumsMembers(), CLAM::SpectralEnvelopeExtract::Do(), CLAM::SpectralAnalysis::Do(), CLAM::FFT_ooura::Do(), CLAM::FFT_fftw3::Do(), and CLAM::FDCombFilter::Do().
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 | |||
) |
Actual Synchronization routine.
Definition at line 464 of file Spectrum.cxx.
References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, BPF2MagPhase(), CLAM::SpecTypeFlags::bPolar, Complex2MagPhase(), Complex2Polar(), GetSize(), GetType(), MagPhase2BPF(), MagPhase2Complex(), MagPhase2Polar(), Polar2Complex(), Polar2MagPhase(), and CLAM::DynamicType::UpdateData().
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 | ( | ) |
Converts scale from linear to dB.
If scale is already set to dB, it does nothing
Definition at line 196 of file Spectrum.cxx.
References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_20log10(), CLAM_sqrt(), CLAM::EScale::eLinear, CLAM::EScale::eLog, GetBPFSize(), GetSize(), CLAM::BPFTmpl< TX, TY >::GetValueFromIndex(), and CLAM::BPFTmpl< TX, TY >::SetValue().
Referenced by CLAM::SpectralPeakDetect::Do(), and CLAM::FDCombFilter::Do().
void Spectrum::ToLinear | ( | ) |
Converts scales from dB to linear.
If scale is already set to linear, it does nothing
Definition at line 283 of file Spectrum.cxx.
References CLAM::SpecTypeFlags::bComplex, CLAM::SpecTypeFlags::bMagPhase, CLAM::SpecTypeFlags::bMagPhaseBPF, CLAM::SpecTypeFlags::bPolar, CLAM_sqrt(), CLAM::EScale::eLinear, CLAM::EScale::eLog, GetBPFSize(), GetSize(), CLAM::BPFTmpl< TX, TY >::GetValueFromIndex(), log2lin(), and CLAM::BPFTmpl< TX, TY >::SetValue().
Referenced by CLAM::FDCombFilter::Do().