Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
ProjectTempoListener Class Referencefinal
Inheritance diagram for ProjectTempoListener:
[legend]
Collaboration diagram for ProjectTempoListener:
[legend]

Public Member Functions

 ProjectTempoListener (AudacityProject &project, TrackList &trackList)
 
void OnProjectTempoChange (double newTempo)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Private Attributes

AudacityProjectmProject
 
ViewInfomViewInfo
 
double mTempo { 0 }
 
TrackListmTrackList
 
Observer::Subscription mTrackListSubstription
 
Observer::Subscription mProjectTimeSignatureSubscription
 

Detailed Description

Definition at line 12 of file ProjectTempoListener.cpp.

Constructor & Destructor Documentation

◆ ProjectTempoListener()

ProjectTempoListener::ProjectTempoListener ( AudacityProject project,
TrackList trackList 
)

Definition at line 34 of file ProjectTempoListener.cpp.

36 : mProject { project }
39 , mTrackList { trackList }
41 [this](const TrackListEvent& event) {
43 {
44 const auto tempo = ProjectTimeSignature::Get(mProject).GetTempo();
45 if (const auto track = event.mpTrack.lock())
46 DoProjectTempoChange(*track, tempo);
47 }
48 }) }
49{
52 [this](const TimeSignatureChangedMessage& event) {
54 });
55 assert(mTrackList.empty()); // No need to call `OnProjectTempoChange` yet ...
56}
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
Observer::Subscription mProjectTimeSignatureSubscription
void OnProjectTempoChange(double newTempo)
AudacityProject & mProject
Observer::Subscription mTrackListSubstription
static ProjectTimeSignature & Get(AudacityProject &project)
bool empty() const
Definition: Track.cpp:758
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:803
const Type mType
Definition: Track.h:837
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:819

References TrackListEvent::ADDITION, DoProjectTempoChange(), ProjectTimeSignature::Get(), ProjectTimeSignature::GetTempo(), and mProject.

Here is the call graph for this function:

Member Function Documentation

◆ OnProjectTempoChange()

void ProjectTempoListener::OnProjectTempoChange ( double  newTempo)

Definition at line 58 of file ProjectTempoListener.cpp.

59{
60 for (auto track : mTrackList)
61 DoProjectTempoChange(*track, newTempo);
62
63 if(!mViewInfo.playRegion.Empty() && mTempo > 0 && newTempo > 0)
64 {
65 const auto tempoRate = mTempo / newTempo;
67 mViewInfo.playRegion.GetStart() * tempoRate,
68 mViewInfo.playRegion.GetEnd() * tempoRate
69 );
70 }
71 mTempo = newTempo;
72}
void DoProjectTempoChange(ChannelGroup &group, double newTempo)
Definition: TempoChange.cpp:41
double GetStart() const
Definition: ViewInfo.h:129
double GetEnd() const
Definition: ViewInfo.h:136
bool Empty() const
Definition: ViewInfo.h:128
void SetTimes(double start, double end)
Definition: ViewInfo.cpp:181
PlayRegion playRegion
Definition: ViewInfo.h:217

References DoProjectTempoChange(), PlayRegion::Empty(), PlayRegion::GetEnd(), PlayRegion::GetStart(), mTempo, mTrackList, mViewInfo, ViewInfo::playRegion, and PlayRegion::SetTimes().

Here is the call graph for this function:

Member Data Documentation

◆ mProject

AudacityProject& ProjectTempoListener::mProject
private

Definition at line 19 of file ProjectTempoListener.cpp.

Referenced by ProjectTempoListener().

◆ mProjectTimeSignatureSubscription

Observer::Subscription ProjectTempoListener::mProjectTimeSignatureSubscription
private

Definition at line 24 of file ProjectTempoListener.cpp.

◆ mTempo

double ProjectTempoListener::mTempo { 0 }
private

Definition at line 21 of file ProjectTempoListener.cpp.

Referenced by OnProjectTempoChange().

◆ mTrackList

TrackList& ProjectTempoListener::mTrackList
private

Definition at line 22 of file ProjectTempoListener.cpp.

Referenced by OnProjectTempoChange().

◆ mTrackListSubstription

Observer::Subscription ProjectTempoListener::mTrackListSubstription
private

Definition at line 23 of file ProjectTempoListener.cpp.

◆ mViewInfo

ViewInfo& ProjectTempoListener::mViewInfo
private

Definition at line 20 of file ProjectTempoListener.cpp.

Referenced by OnProjectTempoChange().


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