Audacity  3.0.3
Public Member Functions | Public Attributes | Private Attributes | List of all members
SpectralData Class Reference

#include <SpectrumView.h>

Collaboration diagram for SpectralData:
[legend]

Public Member Functions

 SpectralData (double sr)
 
 SpectralData (const SpectralData &src)=delete
 
void CopyFrom (const SpectralData &src)
 
int GetHopSize () const
 
int GetWindowSize () const
 
double GetSR () const
 
long long GetStartSample () const
 
long long GetEndSample () const
 
void addHopBinData (int hopNum, int freqBin)
 
void removeHopBinData (int hopNum, int freqBin)
 
void clearAllData ()
 
void saveAndClearBuffer ()
 

Public Attributes

HopsAndBinsMap dataBuffer
 
std::vector< HopsAndBinsMapdataHistory
 
std::vector< std::pair< int, int > > coordHistory
 

Private Attributes

double mSampleRate
 
int mWindowSize
 
int mHopSize
 
long long mStartSample
 
long long mEndSample
 

Detailed Description

Definition at line 24 of file SpectrumView.h.

Constructor & Destructor Documentation

◆ SpectralData() [1/2]

SpectralData::SpectralData ( double  sr)
inline

Definition at line 33 of file SpectrumView.h.

34  :mSampleRate(sr)
35  // Set start and end in reverse for comparison during data addition
36  ,mStartSample(std::numeric_limits<long long>::max())
37  ,mEndSample( 0 )
38  ,mWindowSize( 2048 )
39  ,mHopSize ( mWindowSize / 4 )
40  {}

◆ SpectralData() [2/2]

SpectralData::SpectralData ( const SpectralData src)
delete

Member Function Documentation

◆ addHopBinData()

void SpectralData::addHopBinData ( int  hopNum,
int  freqBin 
)
inline

Definition at line 80 of file SpectrumView.h.

80  {
81  // Update the start and end sampleCount of current selection
82  if(hopNum * mHopSize > mEndSample)
83  mEndSample = hopNum * mHopSize;
84  if(hopNum * mHopSize < mStartSample)
85  mStartSample = hopNum * mHopSize;
86 
87  dataBuffer[hopNum].insert(freqBin);
88  }

References dataBuffer, mEndSample, mHopSize, and mStartSample.

◆ clearAllData()

void SpectralData::clearAllData ( )
inline

Definition at line 99 of file SpectrumView.h.

99  {
100  // DataBuffer should be clear when the user release cursor
101  dataHistory.clear();
102  mStartSample = std::numeric_limits<long long>::max();
103  mEndSample = 0;
104  }

References dataHistory, mEndSample, and mStartSample.

◆ CopyFrom()

void SpectralData::CopyFrom ( const SpectralData src)
inline

Definition at line 49 of file SpectrumView.h.

49  {
51  mEndSample = src.GetEndSample();
52 
53  // std containers will perform deepcopy automatically
55  dataBuffer = src.dataBuffer;
57  }

References coordHistory, dataBuffer, dataHistory, GetEndSample(), GetStartSample(), mEndSample, and mStartSample.

Here is the call graph for this function:

◆ GetEndSample()

long long SpectralData::GetEndSample ( ) const
inline

Definition at line 75 of file SpectrumView.h.

75  {
76  return mEndSample;
77  }

References mEndSample.

Referenced by CopyFrom().

Here is the caller graph for this function:

◆ GetHopSize()

int SpectralData::GetHopSize ( ) const
inline

Definition at line 59 of file SpectrumView.h.

59  {
60  return mHopSize;
61  }

References mHopSize.

Referenced by anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), and SpectralDataManager::Worker::Process().

Here is the caller graph for this function:

◆ GetSR()

double SpectralData::GetSR ( ) const
inline

Definition at line 67 of file SpectrumView.h.

67  {
68  return mSampleRate;
69  }

References mSampleRate.

Referenced by anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum().

Here is the caller graph for this function:

◆ GetStartSample()

long long SpectralData::GetStartSample ( ) const
inline

Definition at line 71 of file SpectrumView.h.

71  {
72  return mStartSample;
73  }

References mStartSample.

Referenced by CopyFrom().

Here is the caller graph for this function:

◆ GetWindowSize()

int SpectralData::GetWindowSize ( ) const
inline

Definition at line 63 of file SpectrumView.h.

63  {
64  return mWindowSize;
65  };

References mWindowSize.

Referenced by anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum().

Here is the caller graph for this function:

◆ removeHopBinData()

void SpectralData::removeHopBinData ( int  hopNum,
int  freqBin 
)
inline

Definition at line 90 of file SpectrumView.h.

90  {
91  // TODO: Recalculate the start and end in case hop falls in 0 || end
92  for(auto &dataBuf: dataHistory){
93  if(dataBuf.find(hopNum) != dataBuf.end()){
94  dataBuf[hopNum].erase(freqBin);
95  }
96  }
97  }

References dataHistory.

◆ saveAndClearBuffer()

void SpectralData::saveAndClearBuffer ( )
inline

Definition at line 106 of file SpectrumView.h.

106  {
107  dataHistory.emplace_back(dataBuffer);
108  dataBuffer.clear();
109  coordHistory.clear();
110  }

References coordHistory, dataBuffer, and dataHistory.

Member Data Documentation

◆ coordHistory

std::vector<std::pair<int, int> > SpectralData::coordHistory

Definition at line 46 of file SpectrumView.h.

Referenced by CopyFrom(), and saveAndClearBuffer().

◆ dataBuffer

HopsAndBinsMap SpectralData::dataBuffer

◆ dataHistory

std::vector<HopsAndBinsMap> SpectralData::dataHistory

◆ mEndSample

long long SpectralData::mEndSample
private

Definition at line 30 of file SpectrumView.h.

Referenced by addHopBinData(), clearAllData(), CopyFrom(), and GetEndSample().

◆ mHopSize

int SpectralData::mHopSize
private

Definition at line 28 of file SpectrumView.h.

Referenced by addHopBinData(), and GetHopSize().

◆ mSampleRate

double SpectralData::mSampleRate
private

Definition at line 26 of file SpectrumView.h.

Referenced by GetSR().

◆ mStartSample

long long SpectralData::mStartSample
private

Definition at line 29 of file SpectrumView.h.

Referenced by addHopBinData(), clearAllData(), CopyFrom(), and GetStartSample().

◆ mWindowSize

int SpectralData::mWindowSize
private

Definition at line 27 of file SpectrumView.h.

Referenced by GetWindowSize().


The documentation for this class was generated from the following file:
SpectralData::dataBuffer
HopsAndBinsMap dataBuffer
Definition: SpectrumView.h:43
SpectralData::mEndSample
long long mEndSample
Definition: SpectrumView.h:30
SpectralData::mHopSize
int mHopSize
Definition: SpectrumView.h:28
SpectralData::mSampleRate
double mSampleRate
Definition: SpectrumView.h:26
SpectralData::mWindowSize
int mWindowSize
Definition: SpectrumView.h:27
SpectralData::mStartSample
long long mStartSample
Definition: SpectrumView.h:29
SpectralData::GetEndSample
long long GetEndSample() const
Definition: SpectrumView.h:75
SpectralData::coordHistory
std::vector< std::pair< int, int > > coordHistory
Definition: SpectrumView.h:46
SpectralData::GetStartSample
long long GetStartSample() const
Definition: SpectrumView.h:71
SpectralData::dataHistory
std::vector< HopsAndBinsMap > dataHistory
Definition: SpectrumView.h:44