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

#include <SilenceSegment.h>

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

Public Member Functions

 SilenceSegment (size_t numChannels, sampleCount numSamples)
 
size_t GetFloats (float *const *buffers, size_t numSamples) override
 Fills buffers with as many as numSamples or the number of remaining samples, whichever is smaller. More...
 
bool Empty () const override
 Whether the segment has no more samples to provide. More...
 
size_t NChannels () const override
 The number of channels in the segment. More...
 
- Public Member Functions inherited from AudioSegment
virtual ~AudioSegment ()
 
virtual size_t GetFloats (float *const *buffers, size_t numSamples)=0
 Fills buffers with as many as numSamples or the number of remaining samples, whichever is smaller. More...
 
virtual size_t NChannels () const =0
 The number of channels in the segment. More...
 
virtual bool Empty () const =0
 Whether the segment has no more samples to provide. More...
 

Private Attributes

const size_t mNumChannels
 
sampleCount mNumRemainingSamples
 

Detailed Description


Audacity: A Digital Audio Editor

SilenceSegment.h

Matthieu Hodgkinson

Definition at line 17 of file SilenceSegment.h.

Constructor & Destructor Documentation

◆ SilenceSegment()

SilenceSegment::SilenceSegment ( size_t  numChannels,
sampleCount  numSamples 
)

Audacity: A Digital Audio Editor

SilenceSegment.cpp

Matthieu Hodgkinson

Definition at line 16 of file SilenceSegment.cpp.

17 : mNumChannels { numChannels }
18 , mNumRemainingSamples { numSamples }
19{
20}
sampleCount mNumRemainingSamples
const size_t mNumChannels

Member Function Documentation

◆ Empty()

bool SilenceSegment::Empty ( ) const
overridevirtual

Whether the segment has no more samples to provide.

Implements AudioSegment.

Definition at line 36 of file SilenceSegment.cpp.

37{
38 return mNumRemainingSamples == 0u;
39}

References mNumRemainingSamples.

Referenced by TEST_CASE().

Here is the caller graph for this function:

◆ GetFloats()

size_t SilenceSegment::GetFloats ( float *const *  buffers,
size_t  numSamples 
)
overridevirtual

Fills buffers with as many as numSamples or the number of remaining samples, whichever is smaller.

Parameters
buffersPointers to buffers, one for each channel.
numSamplesThe max. number of samples to write to each buffer.
Returns
The number of samples actually provided in each buffer.

Implements AudioSegment.

Definition at line 23 of file SilenceSegment.cpp.

24{
25 const size_t numSamplesToProduce =
26 std::min<long long>(mNumRemainingSamples.as_long_long(), numSamples);
27 for (auto i = 0u; i < mNumChannels; ++i)
28 {
29 auto buffer = buffers[i];
30 std::fill(buffer, buffer + numSamplesToProduce, 0.f);
31 }
32 mNumRemainingSamples -= numSamplesToProduce;
33 return numSamplesToProduce;
34}
long long as_long_long() const
Definition: SampleCount.h:48

References sampleCount::as_long_long(), mNumChannels, and mNumRemainingSamples.

Referenced by TEST_CASE().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NChannels()

size_t SilenceSegment::NChannels ( ) const
overridevirtual

The number of channels in the segment.

Implements AudioSegment.

Definition at line 41 of file SilenceSegment.cpp.

42{
43 return mNumChannels;
44}

References mNumChannels.

Member Data Documentation

◆ mNumChannels

const size_t SilenceSegment::mNumChannels
private

Definition at line 26 of file SilenceSegment.h.

Referenced by GetFloats(), and NChannels().

◆ mNumRemainingSamples

sampleCount SilenceSegment::mNumRemainingSamples
private

Definition at line 27 of file SilenceSegment.h.

Referenced by Empty(), and GetFloats().


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