Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private 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...
 
WaveTrack::Holder Create (size_t nChannels)
 Creates a new track with project's default rate and format and the given number of channels. More...
 
TrackListHolder CreateMany (size_t nChannels)
 Creates tracks with project's default rate and format and the given number of channels. More...
 
WaveTrack::Holder Create (size_t nChannels, sampleFormat format, double rate)
 Creates a new track with specified format and rate and number of channels. More...
 
TrackListHolder CreateMany (size_t nChannels, sampleFormat format, double rate)
 Creates tracks with specified format and rate and number of channels. More...
 
WaveTrack::Holder Create (size_t nChannels, const WaveTrack &proto)
 Creates an empty copy of proto with the specified number of channels. 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 Member Functions

std::shared_ptr< WaveTrackDoCreate (size_t nChannels, sampleFormat format, double rate)
 

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

Constructor & Destructor Documentation

◆ WaveTrackFactory() [1/2]

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

Definition at line 877 of file WaveTrack.h.

880 : mRate{ rate }
881 , mpFactory(pFactory)
882 {
883 }
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:943
const ProjectRate & mRate
Definition: WaveTrack.h:942

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

394{
396}
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:393
PROJECT_RATE_API sampleFormat SampleFormatChoice()

References Create(), ProjectRate::GetRate(), mRate, and QualitySettings::SampleFormatChoice().

Referenced by Create(), EffectBase::DoEffect(), 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 413 of file WaveTrack.cpp.

414{
415 return DoCreate(1, format, rate);
416}
std::shared_ptr< WaveTrack > DoCreate(size_t nChannels, sampleFormat format, double rate)
Definition: WaveTrack.cpp:398

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

Here is the call graph for this function:

◆ Create() [3/5]

WaveTrack::Holder WaveTrackFactory::Create ( size_t  nChannels)

Creates a new track with project's default rate and format and the given number of channels.

Precondition
nChannels > 0
nChannels <= 2

Definition at line 418 of file WaveTrack.cpp.

419{
420 assert(nChannels > 0);
421 assert(nChannels <= 2);
423}

References Create(), ProjectRate::GetRate(), mRate, and QualitySettings::SampleFormatChoice().

Here is the call graph for this function:

◆ Create() [4/5]

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

Creates an empty copy of proto with the specified number of channels.

Definition at line 483 of file WaveTrack.cpp.

484{
485 return proto.EmptyCopy(nChannels, mpFactory);
486}
Holder EmptyCopy(size_t nChannels, const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:989

References WaveTrack::EmptyCopy(), and mpFactory.

Here is the call graph for this function:

◆ Create() [5/5]

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

Creates a new track with specified format and rate and number of channels.

Precondition
nChannels > 0
nChannels <= 2

Definition at line 464 of file WaveTrack.cpp.

465{
466 assert(nChannels > 0);
467 assert(nChannels <= 2);
468 return CreateMany(nChannels, format, rate)->DetachFirst()
469 ->SharedPointer<WaveTrack>();
470}
TrackListHolder CreateMany(size_t nChannels)
Creates tracks with project's default rate and format and the given number of channels.
Definition: WaveTrack.cpp:425
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

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

Here is the call graph for this function:

◆ CreateMany() [1/2]

TrackListHolder WaveTrackFactory::CreateMany ( size_t  nChannels)

Creates tracks with project's default rate and format and the given number of channels.

Definition at line 425 of file WaveTrack.cpp.

426{
427 return CreateMany(nChannels,
429}

References CreateMany(), ProjectRate::GetRate(), mRate, and QualitySettings::SampleFormatChoice().

Referenced by Create(), CreateMany(), ProjectAudioManager::DoRecord(), and ImportRaw().

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

◆ CreateMany() [2/2]

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

Creates tracks with specified format and rate and number of channels.

Definition at line 472 of file WaveTrack.cpp.

473{
474 // There are some cases where more than two channels are requested
475 if (nChannels == 2)
476 return TrackList::Temporary(nullptr, DoCreate(nChannels, format, rate));
477 auto result = TrackList::Temporary(nullptr);
478 while (nChannels--)
479 result->Add(DoCreate(1, format, rate));
480 return result;
481}
static TrackListHolder Temporary(AudacityProject *pProject, const Track::Holder &pTrack={})
Definition: Track.cpp:858

References DoCreate(), 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 3366 of file WaveTrack.cpp.

3367{
3368 project.AttachedObjects::Assign( key2, nullptr );
3369}
const auto project
static const AudacityProject::AttachedObjects::RegisteredFactory key2
Definition: WaveTrack.cpp:3345

References key2, and project.

Referenced by ProjectManager::OnCloseWindow().

Here is the caller graph for this function:

◆ DoCreate()

std::shared_ptr< WaveTrack > WaveTrackFactory::DoCreate ( size_t  nChannels,
sampleFormat  format,
double  rate 
)
private

Definition at line 398 of file WaveTrack.cpp.

400{
401 auto result = std::make_shared<WaveTrack>(
403 // Set the number of channels correctly before building all channel
404 // attachments
405 if (nChannels > 1)
406 result->CreateRight();
407 // Only after make_shared returns, can weak_from_this be used, which
408 // attached object factories may need
409 result->AttachedTrackObjects::BuildAll();
410 return result;
411}

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

Referenced by Create(), and CreateMany().

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

3355{
3356 return Get( const_cast< AudacityProject & >( project ) );
3357}
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:3349

References Get(), and project.

Here is the call graph for this function:

◆ GetSampleBlockFactory()

const SampleBlockFactoryPtr & WaveTrackFactory::GetSampleBlockFactory ( ) const
inline

Definition at line 887 of file WaveTrack.h.

888 { 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 3359 of file WaveTrack.cpp.

3360{
3361 auto result = TrackFactoryFactory( project );
3362 project.AttachedObjects::Assign( key2, result );
3363 return *result;
3364}
static auto TrackFactoryFactory
Definition: WaveTrack.cpp:3339

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

Referenced by Create(), and DoCreate().

◆ mRate

const ProjectRate& WaveTrackFactory::mRate
private

Definition at line 942 of file WaveTrack.h.

Referenced by Create(), and CreateMany().


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