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

Used to create or clone a WaveTrack, with appropriate context from the project that will own the track. More...

#include <WaveTrack.h>

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

Public Member Functions

 WaveTrackFactory (const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
 
 WaveTrackFactory (const WaveTrackFactory &)=delete
 
WaveTrackFactoryoperator= (const WaveTrackFactory &)=delete
 
const SampleBlockFactoryPtrGetSampleBlockFactory () const
 
std::shared_ptr< WaveTrackCreate ()
 Creates an unnamed empty WaveTrack with default sample format and default rate. More...
 
std::shared_ptr< WaveTrackCreate (sampleFormat format, double rate)
 Creates an unnamed empty WaveTrack with custom sample format and custom rate. More...
 
TrackListHolder Create (size_t nChannels)
 Creates new nChannels tracks with project's default rate and format. If number of channels is exactly two then a single stereo track is created instead. More...
 
TrackListHolder Create (size_t nChannels, sampleFormat format, double rate)
 Creates new nChannels tracks with specified format and rate and places them into TrackList. If number of channels is exactly two then a single stereo track is created instead. More...
 
TrackListHolder Create (size_t nChannels, const WaveTrack &proto)
 Creates new nChannels tracks by creating empty copies of proto. If number of channels is exactly two then a single stereo track is created instead. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static WaveTrackFactoryGet (AudacityProject &project)
 
static const WaveTrackFactoryGet (const AudacityProject &project)
 
static WaveTrackFactoryReset (AudacityProject &project)
 
static void Destroy (AudacityProject &project)
 

Private Attributes

const ProjectRatemRate
 
SampleBlockFactoryPtr mpFactory
 

Detailed Description

Used to create or clone a WaveTrack, with appropriate context from the project that will own the track.

Definition at line 1164 of file WaveTrack.h.

Constructor & Destructor Documentation

◆ WaveTrackFactory() [1/2]

WaveTrackFactory::WaveTrackFactory ( const ProjectRate rate,
const SampleBlockFactoryPtr pFactory 
)
inline

Definition at line 1173 of file WaveTrack.h.

1176 : mRate{ rate }
1177 , mpFactory(pFactory)
1178 {
1179 }
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:1224
const ProjectRate & mRate
Definition: WaveTrack.h:1223

◆ WaveTrackFactory() [2/2]

WaveTrackFactory::WaveTrackFactory ( const WaveTrackFactory )
delete

Member Function Documentation

◆ Create() [1/5]

std::shared_ptr< WaveTrack > WaveTrackFactory::Create ( )

Creates an unnamed empty WaveTrack with default sample format and default rate.

Returns
Orphaned WaveTrack

Definition at line 546 of file WaveTrack.cpp.

547{
549}
double GetRate() const
Definition: ProjectRate.cpp:53
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
Definition: WaveTrack.cpp:546
PROJECT_RATE_API sampleFormat SampleFormatChoice()

References QualitySettings::SampleFormatChoice().

Referenced by EffectBase::DoEffect(), ProjectAudioManager::DoRecord(), ImportRaw(), MixAndRender(), and ImportUtils::NewWaveTrack().

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

◆ Create() [2/5]

std::shared_ptr< WaveTrack > WaveTrackFactory::Create ( sampleFormat  format,
double  rate 
)

Creates an unnamed empty WaveTrack with custom sample format and custom rate.

Parameters
formatDesired sample format
rateDesired sample rate
Returns
Orphaned WaveTrack

Definition at line 551 of file WaveTrack.cpp.

552{
553 return std::make_shared<WaveTrack>(mpFactory, format, rate);
554}

References anonymous_namespace{ExportPCM.cpp}::format, and WaveTrack::mpFactory.

◆ Create() [3/5]

TrackListHolder WaveTrackFactory::Create ( size_t  nChannels)

Creates new nChannels tracks with project's default rate and format. If number of channels is exactly two then a single stereo track is created instead.

Definition at line 556 of file WaveTrack.cpp.

557{
559}

References QualitySettings::SampleFormatChoice().

Here is the call graph for this function:

◆ Create() [4/5]

TrackListHolder WaveTrackFactory::Create ( size_t  nChannels,
const WaveTrack proto 
)

Creates new nChannels tracks by creating empty copies of proto. If number of channels is exactly two then a single stereo track is created instead.

Definition at line 574 of file WaveTrack.cpp.

575{
576 auto channels = std::vector<std::shared_ptr<Track>>{};
577 std::generate_n(
578 std::back_inserter(channels),
579 nChannels,
580 [&]{ return proto.EmptyCopy(mpFactory, false); }
581 );
582 if(nChannels == 2)
583 return TrackList::Temporary(nullptr, channels[0], channels[1]);
584 return TrackList::Temporary(nullptr, channels);
585}
static TrackListHolder Temporary(AudacityProject *pProject, const Track::Holder &left={}, const Track::Holder &right={})
Definition: Track.cpp:1435
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}, bool keepLink=true) const
Definition: WaveTrack.cpp:1106

References WaveTrack::EmptyCopy(), WaveTrack::mpFactory, and TrackList::Temporary().

Here is the call graph for this function:

◆ Create() [5/5]

TrackListHolder WaveTrackFactory::Create ( size_t  nChannels,
sampleFormat  format,
double  rate 
)

Creates new nChannels tracks with specified format and rate and places them into TrackList. If number of channels is exactly two then a single stereo track is created instead.

Definition at line 561 of file WaveTrack.cpp.

562{
563 auto channels = std::vector<std::shared_ptr<Track>>{ };
564 std::generate_n(
565 std::back_inserter(channels),
566 nChannels,
567 [&] { return Create(format, rate); }
568 );
569 if(nChannels == 2)
570 return TrackList::Temporary(nullptr, channels[0], channels[1]);
571 return TrackList::Temporary(nullptr, channels);
572}

References anonymous_namespace{ExportPCM.cpp}::format, and TrackList::Temporary().

Here is the call graph for this function:

◆ Destroy()

void WaveTrackFactory::Destroy ( AudacityProject project)
static

Definition at line 4096 of file WaveTrack.cpp.

4097{
4098 project.AttachedObjects::Assign( key2, nullptr );
4099}
const auto project
static const AudacityProject::AttachedObjects::RegisteredFactory key2
Definition: WaveTrack.cpp:4075

References key2, and project.

Referenced by ProjectManager::OnCloseWindow().

Here is the caller graph for this function:

◆ Get() [1/2]

WaveTrackFactory & WaveTrackFactory::Get ( AudacityProject project)
static

◆ Get() [2/2]

const WaveTrackFactory & WaveTrackFactory::Get ( const AudacityProject project)
static

Definition at line 4084 of file WaveTrack.cpp.

4085{
4086 return Get( const_cast< AudacityProject & >( project ) );
4087}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:4079

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), and project.

Here is the call graph for this function:

◆ GetSampleBlockFactory()

const SampleBlockFactoryPtr & WaveTrackFactory::GetSampleBlockFactory ( ) const
inline

Definition at line 1183 of file WaveTrack.h.

1184 { return mpFactory; }

Referenced by ProjectFileIO::LoadProject().

Here is the caller graph for this function:

◆ operator=()

WaveTrackFactory & WaveTrackFactory::operator= ( const WaveTrackFactory )
delete

◆ Reset()

WaveTrackFactory & WaveTrackFactory::Reset ( AudacityProject project)
static

Definition at line 4089 of file WaveTrack.cpp.

4090{
4091 auto result = TrackFactoryFactory( project );
4092 project.AttachedObjects::Assign( key2, result );
4093 return *result;
4094}
static auto TrackFactoryFactory
Definition: WaveTrack.cpp:4069

References key2, project, and TrackFactoryFactory.

Referenced by ProjectManager::ResetProjectToEmpty().

Here is the caller graph for this function:

Member Data Documentation

◆ mpFactory

SampleBlockFactoryPtr WaveTrackFactory::mpFactory
private

Definition at line 1224 of file WaveTrack.h.

◆ mRate

const ProjectRate& WaveTrackFactory::mRate
private

Definition at line 1223 of file WaveTrack.h.


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