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 1277 of file WaveTrack.h.

Constructor & Destructor Documentation

◆ WaveTrackFactory() [1/2]

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

Definition at line 1286 of file WaveTrack.h.

1289 : mRate{ rate }
1290 , mpFactory(pFactory)
1291 {
1292 }
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:1337
const ProjectRate & mRate
Definition: WaveTrack.h:1336

◆ 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 761 of file WaveTrack.cpp.

762{
764}
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:761
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 766 of file WaveTrack.cpp.

767{
768 return std::make_shared<WaveTrack>(mpFactory, format, rate);
769}

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 771 of file WaveTrack.cpp.

772{
774}

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 789 of file WaveTrack.cpp.

790{
791 auto channels = std::vector<std::shared_ptr<Track>>{};
792 std::generate_n(
793 std::back_inserter(channels),
794 nChannels,
795 [&]{ return proto.EmptyCopy(mpFactory, false); }
796 );
797 if(nChannels == 2)
798 return TrackList::Temporary(nullptr, channels[0], channels[1]);
799 return TrackList::Temporary(nullptr, channels);
800}
static TrackListHolder Temporary(AudacityProject *pProject, const Track::Holder &left={}, const Track::Holder &right={})
Definition: Track.cpp:1418
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}, bool keepLink=true) const
Definition: WaveTrack.cpp:1366

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 776 of file WaveTrack.cpp.

777{
778 auto channels = std::vector<std::shared_ptr<Track>>{ };
779 std::generate_n(
780 std::back_inserter(channels),
781 nChannels,
782 [&] { return Create(format, rate); }
783 );
784 if(nChannels == 2)
785 return TrackList::Temporary(nullptr, channels[0], channels[1]);
786 return TrackList::Temporary(nullptr, channels);
787}

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 4533 of file WaveTrack.cpp.

4534{
4535 project.AttachedObjects::Assign( key2, nullptr );
4536}
const auto project
static const AudacityProject::AttachedObjects::RegisteredFactory key2
Definition: WaveTrack.cpp:4512

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 4521 of file WaveTrack.cpp.

4522{
4523 return Get( const_cast< AudacityProject & >( project ) );
4524}
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:4516

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 1296 of file WaveTrack.h.

1297 { 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 4526 of file WaveTrack.cpp.

4527{
4528 auto result = TrackFactoryFactory( project );
4529 project.AttachedObjects::Assign( key2, result );
4530 return *result;
4531}
static auto TrackFactoryFactory
Definition: WaveTrack.cpp:4506

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 1337 of file WaveTrack.h.

◆ mRate

const ProjectRate& WaveTrackFactory::mRate
private

Definition at line 1336 of file WaveTrack.h.


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