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

Holds project sample rate. More...

#include <ProjectRate.h>

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

Public Member Functions

 ProjectRate (AudacityProject &project)
 
 ProjectRate (const ProjectRate &) PROHIBITED
 
ProjectRateoperator= (const ProjectRate &) PROHIBITED
 
void SetRate (double rate)
 
double GetRate () const
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from Observer::Publisher< double >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static ProjectRateGet (AudacityProject &project)
 
static const ProjectRateGet (const AudacityProject &project)
 

Private Attributes

double mRate
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< double >
using message_type = double
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const double &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< double >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< double >
CallbackReturn Publish (const double &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Holds project sample rate.

Definition at line 21 of file ProjectRate.h.

Constructor & Destructor Documentation

◆ ProjectRate() [1/2]

ProjectRate::ProjectRate ( AudacityProject project)
explicit

Definition at line 38 of file ProjectRate.cpp.

39{
40 int intRate = 0;
41 bool wasDefined = QualitySettings::DefaultSampleRate.Read( &intRate );
42 mRate = intRate;
43 if ( !wasDefined ) {
44 // The default given above can vary with host/devices. So unless there is
45 // an entry for the default sample rate in audacity.cfg, Audacity can open
46 // with a rate which is different from the rate with which it closed.
47 // See bug 1879.
49 gPrefs->Flush();
50 }
51}
FileConfig * gPrefs
Definition: Prefs.cpp:71
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
double mRate
Definition: ProjectRate.h:37
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
PROJECT_RATE_API IntSetting DefaultSampleRate

References QualitySettings::DefaultSampleRate, FileConfig::Flush(), gPrefs, mRate, Setting< T >::Read(), and Setting< T >::Write().

Here is the call graph for this function:

◆ ProjectRate() [2/2]

ProjectRate::ProjectRate ( const ProjectRate )

Member Function Documentation

◆ Get() [1/2]

ProjectRate & ProjectRate::Get ( AudacityProject project)
static

Definition at line 28 of file ProjectRate.cpp.

29{
30 return project.AttachedObjects::Get< ProjectRate >( sKey );
31}
static const AudacityProject::AttachedObjects::RegisteredFactory sKey
Definition: ProjectRate.cpp:21
Holds project sample rate.
Definition: ProjectRate.h:24

References sKey.

Referenced by ProjectFileManager::AddImportedTracks(), ProjectSelectionManager::AS_GetRate(), ProjectSelectionManager::AS_SetRate(), BenchmarkDialog::BenchmarkDialog(), ContrastDialog::ContrastDialog(), DefaultPlayOptions(), DefaultSpeedPlayOptions(), LabelTrackView::DoEditLabels(), EffectUI::DoEffect(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), ExportCL::Export(), ExportFLAC::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportPCM::Export(), ExportWavPack::Export(), Get(), ProjectManager::GetEstimatedRecordingMinsLeftOnDisk(), anonymous_namespace{TimeTrack.cpp}::GetRate(), anonymous_namespace{SelectMenus.cpp}::GridMove(), ImportRaw(), ExportFFmpeg::InitCodecs(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewStereoTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewWaveTrack(), TrackActions::Handler::OnResample(), SelectUtilities::OnSetRegion(), TransportActions::Handler::OnTimerRecord(), SelectActions::Handler::OnZeroCrossing(), ProjectFileManager::OpenProjectFile(), TimeToolBar::Populate(), NyquistEffect::Process(), SnapManager::Reinit(), ProjectSelectionManager::SnapSelection(), ProjectSelectionManager::SSBL_GetRate(), and TimeToolBar::TimeToolBar().

Here is the caller graph for this function:

◆ Get() [2/2]

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

Definition at line 33 of file ProjectRate.cpp.

34{
35 return Get( const_cast< AudacityProject & >( project ) );
36}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28

References Get().

Here is the call graph for this function:

◆ GetRate()

double ProjectRate::GetRate ( ) const

◆ operator=()

ProjectRate & ProjectRate::operator= ( const ProjectRate )

◆ SetRate()

void ProjectRate::SetRate ( double  rate)

Definition at line 58 of file ProjectRate.cpp.

59{
60 if (rate != mRate) {
61 mRate = rate;
62 Publish(rate);
63 }
64}
CallbackReturn Publish(const double &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References mRate, and Observer::Publisher< double >::Publish().

Referenced by ProjectFileManager::AddImportedTracks(), and ProjectSelectionManager::AS_SetRate().

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

Member Data Documentation

◆ mRate

double ProjectRate::mRate
private

Definition at line 37 of file ProjectRate.h.

Referenced by GetRate(), ProjectRate(), and SetRate().


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