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

Constructor & Destructor Documentation

◆ WaveTrackFactory() [1/2]

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

Definition at line 878 of file WaveTrack.h.

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

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

392{
394}
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:391
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 411 of file WaveTrack.cpp.

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

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

417{
418 assert(nChannels > 0);
419 assert(nChannels <= 2);
421}

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

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

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

463{
464 assert(nChannels > 0);
465 assert(nChannels <= 2);
466 return CreateMany(nChannels, format, rate)->DetachFirst()
467 ->SharedPointer<WaveTrack>();
468}
TrackListHolder CreateMany(size_t nChannels)
Creates tracks with project's default rate and format and the given number of channels.
Definition: WaveTrack.cpp:423
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 423 of file WaveTrack.cpp.

424{
425 return CreateMany(nChannels,
427}

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

Referenced by Create(), CreateMany(), ProjectAudioManager::DoRecord(), FFmpegImportFileHandle::Import(), OggImportFileHandle::Import(), PCMImportFileHandle::Import(), WavPackImportFileHandle::Import(), 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 470 of file WaveTrack.cpp.

471{
472 // There are some cases where more than two channels are requested
473 if (nChannels == 2)
474 return TrackList::Temporary(nullptr, DoCreate(nChannels, format, rate));
475 auto result = TrackList::Temporary(nullptr);
476 while (nChannels--)
477 result->Add(DoCreate(1, format, rate));
478 return result;
479}
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 3393 of file WaveTrack.cpp.

3394{
3395 project.AttachedObjects::Assign( key2, nullptr );
3396}
const auto project
static const AudacityProject::AttachedObjects::RegisteredFactory key2
Definition: WaveTrack.cpp:3372

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

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

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

3382{
3383 return Get( const_cast< AudacityProject & >( project ) );
3384}
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:3376

References Get(), and project.

Here is the call graph for this function:

◆ GetSampleBlockFactory()

const SampleBlockFactoryPtr & WaveTrackFactory::GetSampleBlockFactory ( ) const
inline

Definition at line 888 of file WaveTrack.h.

889 { 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 3386 of file WaveTrack.cpp.

3387{
3388 auto result = TrackFactoryFactory( project );
3389 project.AttachedObjects::Assign( key2, result );
3390 return *result;
3391}
static auto TrackFactoryFactory
Definition: WaveTrack.cpp:3366

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

Referenced by Create(), and DoCreate().

◆ mRate

const ProjectRate& WaveTrackFactory::mRate
private

Definition at line 943 of file WaveTrack.h.

Referenced by Create(), and CreateMany().


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