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 &)=delete
 
ProjectRateoperator= (const ProjectRate &)=delete
 
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}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
double mRate
Definition: ProjectRate.h:37
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
virtual bool Flush() noexcept=0
PROJECT_RATE_API IntSetting DefaultSampleRate

References QualitySettings::DefaultSampleRate, audacity::BasicSettings::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 )
delete

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
const auto project
Holds project sample rate.
Definition: ProjectRate.h:24

References project, and sKey.

Referenced by ExportCommand::Apply(), SetProjectCommand::Apply(), BenchmarkDialog::BenchmarkDialog(), DevicePrefs::Commit(), ContrastDialog::ContrastDialog(), ProjectAudioIO::DefaultOptionsFactory(), DefaultSpeedPlayOptions(), AudacityApplicationLogic::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoExport(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), audacity::cloud::audiocom::sync::MixdownUploader::ExportProject(), audacity::cloud::audiocom::ShareAudioDialog::ExportProject(), Get(), ProjectManager::GetEstimatedRecordingMinsLeftOnDisk(), anonymous_namespace{TimeTrack.cpp}::GetRate(), FormatterContext::GetSampleRate(), AUPImportFileHandle::Import(), ImportRaw(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewStereoTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewWaveTrack(), anonymous_namespace{TrackMenus.cpp}::OnResample(), anonymous_namespace{PluginMenus.cpp}::OnResetConfig(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), SelectActions::Handler::OnZeroCrossing(), anonymous_namespace{ParsedNumericConverterFormatter.cpp}::ParsedNumericConverterFormatter::ParsedNumericConverterFormatter(), DevicePrefs::Populate(), NyquistBase::Process(), WaveTrack::ProjectNyquistFrequency(), SnapManager::Reinit(), SelectionBar::SelectionBar(), and anonymous_namespace{TimeSnapFunctions.cpp}::SnapToSamples().

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:90
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28

References Get(), and project.

Here is the call graph for this function:

◆ GetRate()

double ProjectRate::GetRate ( ) const

◆ operator=()

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

◆ 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 SetProjectCommand::Apply(), AUPImportFileHandle::Import(), and anonymous_namespace{PluginMenus.cpp}::OnResetConfig().

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: