Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
MockSampleBlock Class Referencefinal

#include <MockSampleBlock.h>

Inheritance diagram for MockSampleBlock:
[legend]
Collaboration diagram for MockSampleBlock:
[legend]

Public Member Functions

 MockSampleBlock (long long id, constSamplePtr src, size_t numsamples, sampleFormat srcformat)
 
void CloseLock () noexcept override
 
SampleBlockID GetBlockID () const override
 
sampleFormat GetSampleFormat () const override
 
size_t GetSampleCount () const override
 
bool GetSummary256 (float *dest, size_t frameoffset, size_t numframes) override
 Non-throwing, should fill with zeroes on failure. More...
 
bool GetSummary64k (float *dest, size_t frameoffset, size_t numframes) override
 Non-throwing, should fill with zeroes on failure. More...
 
size_t GetSpaceUsage () const override
 
void SaveXML (XMLWriter &) override
 
size_t DoGetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples) override
 
MinMaxRMS DoGetMinMaxRMS (size_t start, size_t len) override
 
MinMaxRMS DoGetMinMaxRMS () const override
 
BlockSampleView GetFloatSampleView (bool mayThrow) override
 
- Public Member Functions inherited from SampleBlock
virtual ~SampleBlock ()
 
virtual void CloseLock () noexcept=0
 
virtual SampleBlockID GetBlockID () const =0
 
size_t GetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples, bool mayThrow=true)
 
virtual BlockSampleView GetFloatSampleView (bool mayThrow)=0
 
virtual sampleFormat GetSampleFormat () const =0
 
virtual size_t GetSampleCount () const =0
 
virtual bool GetSummary256 (float *dest, size_t frameoffset, size_t numframes)=0
 Non-throwing, should fill with zeroes on failure. More...
 
virtual bool GetSummary64k (float *dest, size_t frameoffset, size_t numframes)=0
 Non-throwing, should fill with zeroes on failure. More...
 
MinMaxRMS GetMinMaxRMS (size_t start, size_t len, bool mayThrow=true)
 Gets extreme values for the specified region. More...
 
MinMaxRMS GetMinMaxRMS (bool mayThrow=true) const
 Gets extreme values for the entire block. More...
 
virtual size_t GetSpaceUsage () const =0
 
virtual void SaveXML (XMLWriter &xmlFile)=0
 

Public Attributes

const long long id
 
const sampleFormat srcFormat
 
const std::vector< char > data
 

Additional Inherited Members

virtual size_t DoGetSamples (samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples)=0
 
virtual MinMaxRMS DoGetMinMaxRMS (size_t start, size_t len)=0
 
virtual MinMaxRMS DoGetMinMaxRMS () const =0
 

Detailed Description


Audacity: A Digital Audio Editor

MockSampleBlock.h

Matthieu Hodgkinson

Definition at line 15 of file MockSampleBlock.h.

Constructor & Destructor Documentation

◆ MockSampleBlock()

MockSampleBlock::MockSampleBlock ( long long  id,
constSamplePtr  src,
size_t  numsamples,
sampleFormat  srcformat 
)

Definition at line 25 of file MockSampleBlock.cpp.

27 : id { id }
28 , srcFormat { srcformat }
29 , data { copyToVector(src, numsamples, srcformat) }
30{
31}
const sampleFormat srcFormat
const std::vector< char > data
std::vector< char > copyToVector(constSamplePtr src, size_t numsamples, sampleFormat srcformat)

Member Function Documentation

◆ CloseLock()

void MockSampleBlock::CloseLock ( )
overridevirtualnoexcept

Implements SampleBlock.

Definition at line 33 of file MockSampleBlock.cpp.

34{
35}

◆ DoGetMinMaxRMS() [1/2]

MinMaxRMS MockSampleBlock::DoGetMinMaxRMS ( ) const
overridevirtual

Implements SampleBlock.

Definition at line 89 of file MockSampleBlock.cpp.

90{
91 return { 0, 0, 0 };
92}

◆ DoGetMinMaxRMS() [2/2]

MinMaxRMS MockSampleBlock::DoGetMinMaxRMS ( size_t  start,
size_t  len 
)
overridevirtual

Implements SampleBlock.

Definition at line 84 of file MockSampleBlock.cpp.

85{
86 return { 0, 0, 0 };
87}

◆ DoGetSamples()

size_t MockSampleBlock::DoGetSamples ( samplePtr  dest,
sampleFormat  destformat,
size_t  sampleoffset,
size_t  numsamples 
)
overridevirtual

Implements SampleBlock.

Definition at line 73 of file MockSampleBlock.cpp.

76{
77 const auto charOffset = sampleoffset * SAMPLE_SIZE(srcFormat);
78 const auto numChars = numsamples * SAMPLE_SIZE(destformat);
80 data.data() + charOffset, data.data() + charOffset + numChars, dest);
81 return numsamples;
82}
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:52
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), data, SAMPLE_SIZE, and srcFormat.

Here is the call graph for this function:

◆ GetBlockID()

SampleBlockID MockSampleBlock::GetBlockID ( ) const
overridevirtual

Implements SampleBlock.

Definition at line 37 of file MockSampleBlock.cpp.

38{
39 return id;
40}
const long long id

References id.

◆ GetFloatSampleView()

BlockSampleView MockSampleBlock::GetFloatSampleView ( bool  mayThrow)
overridevirtual

Implements SampleBlock.

Definition at line 94 of file MockSampleBlock.cpp.

95{
96 std::vector<float> floatData { reinterpret_cast<const float*>(data.data()),
97 reinterpret_cast<const float*>(
98 data.data() + data.size()) };
99 return std::make_shared<std::vector<float>>(floatData);
100}

References data.

◆ GetSampleCount()

size_t MockSampleBlock::GetSampleCount ( ) const
overridevirtual

Implements SampleBlock.

Definition at line 47 of file MockSampleBlock.cpp.

48{
49 return data.size() / SAMPLE_SIZE(srcFormat);
50}

References data, SAMPLE_SIZE, and srcFormat.

◆ GetSampleFormat()

sampleFormat MockSampleBlock::GetSampleFormat ( ) const
overridevirtual

Implements SampleBlock.

Definition at line 42 of file MockSampleBlock.cpp.

43{
44 return srcFormat;
45}

References srcFormat.

◆ GetSpaceUsage()

size_t MockSampleBlock::GetSpaceUsage ( ) const
overridevirtual

Implements SampleBlock.

Definition at line 64 of file MockSampleBlock.cpp.

65{
66 return data.size();
67}

References data.

◆ GetSummary256()

bool MockSampleBlock::GetSummary256 ( float *  dest,
size_t  frameoffset,
size_t  numframes 
)
overridevirtual

Non-throwing, should fill with zeroes on failure.

Implements SampleBlock.

Definition at line 52 of file MockSampleBlock.cpp.

54{
55 return true;
56}

◆ GetSummary64k()

bool MockSampleBlock::GetSummary64k ( float *  dest,
size_t  frameoffset,
size_t  numframes 
)
overridevirtual

Non-throwing, should fill with zeroes on failure.

Implements SampleBlock.

Definition at line 58 of file MockSampleBlock.cpp.

60{
61 return true;
62}

◆ SaveXML()

void MockSampleBlock::SaveXML ( XMLWriter )
overridevirtual

Implements SampleBlock.

Definition at line 69 of file MockSampleBlock.cpp.

70{
71}

Member Data Documentation

◆ data

const std::vector<char> MockSampleBlock::data

Definition at line 52 of file MockSampleBlock.h.

Referenced by DoGetSamples(), GetFloatSampleView(), GetSampleCount(), and GetSpaceUsage().

◆ id

const long long MockSampleBlock::id

Definition at line 50 of file MockSampleBlock.h.

Referenced by GetBlockID().

◆ srcFormat

const sampleFormat MockSampleBlock::srcFormat

Definition at line 51 of file MockSampleBlock.h.

Referenced by DoGetSamples(), GetSampleCount(), and GetSampleFormat().


The documentation for this class was generated from the following files: