Audacity 3.2.0
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
ClipMirAudioReader Class Reference

#include <ClipMirAudioReader.h>

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

Public Member Functions

 ClipMirAudioReader (std::optional< LibFileFormats::AcidizerTags > tags, std::string filename, WaveTrack &singleClipWaveTrack)
 
double GetSampleRate () const override
 
long long GetNumSamples () const override
 
void ReadFloats (float *buffer, long long where, size_t numFrames) const override
 
- Public Member Functions inherited from MIR::MirAudioReader
virtual double GetSampleRate () const =0
 
virtual long long GetNumSamples () const =0
 
virtual void ReadFloats (float *buffer, long long where, size_t numFrames) const =0
 
double GetDuration () const
 
virtual ~MirAudioReader ()=default
 

Public Attributes

const std::optional< LibFileFormats::AcidizerTagstags
 
const std::string filename
 
const WaveTrack::IntervalHolder clip
 

Private Types

using ChannelCache = std::array< std::optional< AudioSegmentSampleView >, 2 >
 

Private Member Functions

void AddChannel (size_t iChannel, float *buffer, sampleCount start, size_t len) const
 

Private Attributes

const std::shared_ptr< const ClipInterfacemClip
 
std::array< ChannelCache, 2 > mCache
 
std::array< bool, 2 > mUseFirst { true, true }
 

Detailed Description

Definition at line 23 of file ClipMirAudioReader.h.

Member Typedef Documentation

◆ ChannelCache

using ClipMirAudioReader::ChannelCache = std::array<std::optional<AudioSegmentSampleView>, 2>
private

Definition at line 53 of file ClipMirAudioReader.h.

Constructor & Destructor Documentation

◆ ClipMirAudioReader()

ClipMirAudioReader::ClipMirAudioReader ( std::optional< LibFileFormats::AcidizerTags tags,
std::string  filename,
WaveTrack singleClipWaveTrack 
)

Audacity: A Digital Audio Editor

ClipMirAudioReader.h

Matthieu Hodgkinson

Definition at line 17 of file ClipMirAudioReader.cpp.

20 : tags { std::move(tags) }
21 , filename { std::move(filename) }
22 , clip(*singleClipWaveTrack.Intervals().begin())
23 , mClip(singleClipWaveTrack.GetClipInterfaces()[0])
24{
25}
const std::optional< LibFileFormats::AcidizerTags > tags
const std::string filename
const std::shared_ptr< const ClipInterface > mClip
const WaveTrack::IntervalHolder clip
auto Intervals()
Definition: WaveTrack.h:671
ClipConstHolders GetClipInterfaces() const
Get access to the (visible) clips in the tracks, in unspecified order.
Definition: WaveTrack.cpp:2592

Member Function Documentation

◆ AddChannel()

void ClipMirAudioReader::AddChannel ( size_t  iChannel,
float *  buffer,
sampleCount  start,
size_t  len 
) const
private

Definition at line 49 of file ClipMirAudioReader.cpp.

51{
52 constexpr auto mayThrow = false;
53 const auto iCache = mUseFirst[iChannel] ? 0 : 1;
54 auto& cache = mCache[iChannel][iCache];
55 auto view = mClip->GetSampleView(iChannel, start, len, mayThrow);
56 cache.emplace(std::move(view));
57 cache->AddTo(buffer, len);
59}
std::array< bool, 2 > mUseFirst
std::array< ChannelCache, 2 > mCache

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, mCache, mClip, and mUseFirst.

Referenced by ReadFloats().

Here is the caller graph for this function:

◆ GetNumSamples()

long long ClipMirAudioReader::GetNumSamples ( ) const
overridevirtual

Implements MIR::MirAudioReader.

Definition at line 32 of file ClipMirAudioReader.cpp.

33{
34 return mClip->GetVisibleSampleCount().as_long_long();
35}

References mClip.

◆ GetSampleRate()

double ClipMirAudioReader::GetSampleRate ( ) const
overridevirtual

Implements MIR::MirAudioReader.

Definition at line 27 of file ClipMirAudioReader.cpp.

28{
29 return mClip->GetRate();
30}

References mClip.

◆ ReadFloats()

void ClipMirAudioReader::ReadFloats ( float *  buffer,
long long  where,
size_t  numFrames 
) const
overridevirtual
Precondition
where >= 0
where + numFrames <= GetNumSamples()

Implements MIR::MirAudioReader.

Definition at line 37 of file ClipMirAudioReader.cpp.

39{
40 std::fill(buffer, buffer + numFrames, 0.f);
41 AddChannel(0, buffer, where, numFrames);
42 if (mClip->NChannels() == 1)
43 return;
44 AddChannel(1, buffer, where, numFrames);
45 std::transform(
46 buffer, buffer + numFrames, buffer, [](float f) { return f / 2; });
47}
void AddChannel(size_t iChannel, float *buffer, sampleCount start, size_t len) const

References AddChannel(), and mClip.

Here is the call graph for this function:

Member Data Documentation

◆ clip

const WaveTrack::IntervalHolder ClipMirAudioReader::clip

Definition at line 32 of file ClipMirAudioReader.h.

◆ filename

const std::string ClipMirAudioReader::filename

Definition at line 31 of file ClipMirAudioReader.h.

◆ mCache

std::array<ChannelCache, 2> ClipMirAudioReader::mCache
mutableprivate

Definition at line 54 of file ClipMirAudioReader.h.

Referenced by AddChannel().

◆ mClip

const std::shared_ptr<const ClipInterface> ClipMirAudioReader::mClip
private

Definition at line 48 of file ClipMirAudioReader.h.

Referenced by AddChannel(), GetNumSamples(), GetSampleRate(), and ReadFloats().

◆ mUseFirst

std::array<bool, 2> ClipMirAudioReader::mUseFirst { true, true }
mutableprivate

Definition at line 55 of file ClipMirAudioReader.h.

Referenced by AddChannel().

◆ tags

const std::optional<LibFileFormats::AcidizerTags> ClipMirAudioReader::tags

Definition at line 30 of file ClipMirAudioReader.h.


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