Audacity 3.2.0
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
 
long long GetCorrectedStartSample () const
 
long long GetLength () 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 ,mWindowSize( 2048 )
36 ,mHopSize ( mWindowSize / 4 )
37 // Set start and end in reverse for comparison during data addition
38 ,mStartSample(std::numeric_limits<long long>::max())
39 ,mEndSample( 0 )
40 {}
double mSampleRate
Definition: SpectrumView.h:26
long long mEndSample
Definition: SpectrumView.h:30
long long mStartSample
Definition: SpectrumView.h:29

◆ SpectralData() [2/2]

SpectralData::SpectralData ( const SpectralData src)
delete

Member Function Documentation

◆ addHopBinData()

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

Definition at line 90 of file SpectrumView.h.

90 {
91 // Update the start and end sampleCount of current selection
92 if(hopNum * mHopSize > mEndSample)
93 mEndSample = hopNum * mHopSize;
94 if(hopNum * mHopSize < mStartSample)
95 mStartSample = hopNum * mHopSize;
96
97 dataBuffer[hopNum].insert(freqBin);
98 }
HopsAndBinsMap dataBuffer
Definition: SpectrumView.h:43

References dataBuffer, mEndSample, mHopSize, and mStartSample.

◆ clearAllData()

void SpectralData::clearAllData ( )
inline

Definition at line 109 of file SpectrumView.h.

109 {
110 // DataBuffer should be clear when the user release cursor
111 dataHistory.clear();
112 mStartSample = std::numeric_limits<long long>::max();
113 mEndSample = 0;
114 }
std::vector< HopsAndBinsMap > dataHistory
Definition: SpectrumView.h:44

References dataHistory, mEndSample, and mStartSample.

◆ CopyFrom()

void SpectralData::CopyFrom ( const SpectralData src)
inline

Definition at line 49 of file SpectrumView.h.

49 {
52
53 // std containers will perform deepcopy automatically
57 }
long long GetStartSample() const
Definition: SpectrumView.h:71
long long GetEndSample() const
Definition: SpectrumView.h:75
std::vector< std::pair< int, int > > coordHistory
Definition: SpectrumView.h:46

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

Here is the call graph for this function:

◆ GetCorrectedStartSample()

long long SpectralData::GetCorrectedStartSample ( ) const
inline

Definition at line 79 of file SpectrumView.h.

79 {
80 // Correct the start of range so that the first full window is
81 // centered at that position
82 return std::max<long long>(0, GetStartSample() - 2 * GetHopSize());
83 }
int GetHopSize() const
Definition: SpectrumView.h:59

References GetHopSize(), and GetStartSample().

Referenced by GetLength().

Here is the call graph for this function:
Here is the caller 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(), and GetLength().

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 GetCorrectedStartSample().

Here is the caller graph for this function:

◆ GetLength()

long long SpectralData::GetLength ( ) const
inline

Definition at line 85 of file SpectrumView.h.

85 {
87 }
long long GetCorrectedStartSample() const
Definition: SpectrumView.h:79

References GetCorrectedStartSample(), and GetEndSample().

Here is the call 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.

◆ 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(), and GetCorrectedStartSample().

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.

◆ removeHopBinData()

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

Definition at line 100 of file SpectrumView.h.

100 {
101 // TODO: Recalculate the start and end in case hop falls in 0 || end
102 for(auto &dataBuf: dataHistory){
103 if(dataBuf.find(hopNum) != dataBuf.end()){
104 dataBuf[hopNum].erase(freqBin);
105 }
106 }
107 }

References dataHistory.

◆ saveAndClearBuffer()

void SpectralData::saveAndClearBuffer ( )
inline

Definition at line 116 of file SpectrumView.h.

116 {
117 dataHistory.emplace_back(dataBuffer);
118 dataBuffer.clear();
119 coordHistory.clear();
120 }

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

Definition at line 43 of file SpectrumView.h.

Referenced by addHopBinData(), CopyFrom(), and saveAndClearBuffer().

◆ 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: