Audacity 3.2.0
Classes | Namespaces | Functions | Variables
ProjectAudioManager.cpp File Reference
#include "ProjectAudioManager.h"
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/statusbr.h>
#include <algorithm>
#include <numeric>
#include "AudioIO.h"
#include "BasicUI.h"
#include "CommandManager.h"
#include "CommonCommandFlags.h"
#include "DefaultPlaybackPolicy.h"
#include "Meter.h"
#include "Mix.h"
#include "PendingTracks.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectFileIO.h"
#include "ProjectHistory.h"
#include "ProjectRate.h"
#include "ProjectStatus.h"
#include "ProjectWindows.h"
#include "ScrubState.h"
#include "TrackFocus.h"
#include "prefs/TracksPrefs.h"
#include "TransportUtilities.h"
#include "UndoManager.h"
#include "ViewInfo.h"
#include "Viewport.h"
#include "WaveClip.h"
#include "WaveTrack.h"
#include "tracks/ui/Scrubbing.h"
#include "tracks/ui/ChannelView.h"
#include "widgets/MeterPanelBase.h"
#include "AudacityMessageBox.h"
Include dependency graph for ProjectAudioManager.cpp:

Go to the source code of this file.

Classes

class  anonymous_namespace{ProjectAudioManager.cpp}::CutPreviewPlaybackPolicy
 

Namespaces

namespace  anonymous_namespace{ProjectAudioManager.cpp}
 

Functions

static TranslatableString FormatRate (int rate)
 
const ReservedCommandFlagCanStopAudioStreamFlag ()
 
AudioIOStartStreamOptions DefaultSpeedPlayOptions (AudacityProject &project)
 
PropertiesOfSelected GetPropertiesOfSelected (const AudacityProject &proj)
 

Variables

static AudacityProject::AttachedObjects::RegisteredFactory sProjectAudioManagerKey
 
static ProjectAudioIO::DefaultOptions::Scope sScope
 Install an implementation in a library hook. More...
 
static RegisteredMenuItemEnabler stopIfPaused
 

Function Documentation

◆ CanStopAudioStreamFlag()

const ReservedCommandFlag & CanStopAudioStreamFlag ( )

Definition at line 1194 of file ProjectAudioManager.cpp.

1194 { static ReservedCommandFlag flag{
1195 [](const AudacityProject &project){
1196 auto &projectAudioManager = ProjectAudioManager::Get( project );
1197 bool canStop = projectAudioManager.CanStopAudioStream();
1198 return canStop;
1199 }
1200 }; return flag; }
const auto project
static std::once_flag flag
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 ProjectAudioManager & Get(AudacityProject &project)

References flag, ProjectAudioManager::Get(), and project.

Referenced by anonymous_namespace{SelectMenus.cpp}::CursorMenu(), ProjectAudioManager::DoRecord(), anonymous_namespace{TransportMenus.cpp}::ExtraTransportMenu(), anonymous_namespace{Scrubbing.cpp}::KeyboardScrubbingItems(), and anonymous_namespace{TransportMenus.cpp}::TransportMenu().

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

◆ DefaultSpeedPlayOptions()

AudioIOStartStreamOptions DefaultSpeedPlayOptions ( AudacityProject project)

Definition at line 1234 of file ProjectAudioManager.cpp.

1235{
1237 auto gAudioIO = AudioIO::Get();
1238 auto PlayAtSpeedRate = gAudioIO->GetBestRate(
1239 false, //not capturing
1240 true, //is playing
1241 ProjectRate::Get( project ).GetRate() //suggested rate
1242 );
1243 result.rate = PlayAtSpeedRate;
1244 return result;
1245}
static AudioIO * Get()
Definition: AudioIO.cpp:126
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate(const Track &track)
Definition: TimeTrack.cpp:182

References AudioIO::Get(), ProjectRate::Get(), ProjectAudioIO::GetDefaultOptions(), anonymous_namespace{TimeTrack.cpp}::GetRate(), and project.

Referenced by Scrubber::StartKeyboardScrubbing().

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

◆ FormatRate()

static TranslatableString FormatRate ( int  rate)
static

Definition at line 80 of file ProjectAudioManager.cpp.

81{
82 if (rate > 0) {
83 return XO("Actual Rate: %d").Format( rate );
84 }
85 else
86 // clear the status field
87 return {};
88}
XO("Cut/Copy/Paste")

References XO().

Referenced by ProjectAudioManager::OnAudioIORate(), and ProjectAudioManager::StatusWidthFunction().

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

◆ GetPropertiesOfSelected()

PropertiesOfSelected GetPropertiesOfSelected ( const AudacityProject proj)

Definition at line 1337 of file ProjectAudioManager.cpp.

1338{
1339 double rateOfSelection{ RATE_NOT_SELECTED };
1340
1341 PropertiesOfSelected result;
1342 result.allSameRate = true;
1343
1344 const auto selectedTracks{
1345 TrackList::Get(proj).Selected<const WaveTrack>() };
1346
1347 for (const auto & track : selectedTracks) {
1348 if (rateOfSelection != RATE_NOT_SELECTED &&
1349 track->GetRate() != rateOfSelection)
1350 result.allSameRate = false;
1351 else if (rateOfSelection == RATE_NOT_SELECTED)
1352 rateOfSelection = track->GetRate();
1353 }
1354
1355 result.anySelected = !selectedTracks.empty();
1356 result.rateOfSelected = rateOfSelection;
1357
1358 return result;
1359}
constexpr int RATE_NOT_SELECTED
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:967
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

References PropertiesOfSelected::allSameRate, PropertiesOfSelected::anySelected, TrackList::Get(), RATE_NOT_SELECTED, PropertiesOfSelected::rateOfSelected, and TrackList::Selected().

Referenced by anonymous_namespace{TransportMenus.cpp}::OnPunchAndRoll(), ProjectAudioManager::OnRecord(), and anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord().

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

Variable Documentation

◆ sProjectAudioManagerKey

Initial value:
{
return std::make_shared< ProjectAudioManager >( project );
}
}

Definition at line 51 of file ProjectAudioManager.cpp.

Referenced by ProjectAudioManager::Get().

◆ sScope

Initial value:
{
auto options = ProjectAudioIO::DefaultOptionsFactory(project, newDefault);
options.listener = ProjectAudioManager::Get(project).shared_from_this();
bool loopEnabled = ViewInfo::Get(project).playRegion.Active();
options.loopEnabled = loopEnabled;
if (newDefault) {
const double trackEndTime = TrackList::Get(project).GetEndTime();
const double loopEndTime = ViewInfo::Get(project).playRegion.GetEnd();
options.policyFactory = [&project, trackEndTime, loopEndTime](
const AudioIOStartStreamOptions &options)
-> std::unique_ptr<PlaybackPolicy>
{
return std::make_unique<DefaultPlaybackPolicy>( project,
trackEndTime, loopEndTime, options.pStartTime,
options.loopEnabled, options.variableSpeed);
};
options.pStartTime.emplace(ViewInfo::Get(project).selectedRegion.t0());
}
return options;
} }
double GetEnd() const
Definition: ViewInfo.h:135
bool Active() const
Definition: ViewInfo.h:124
static AudioIOStartStreamOptions DefaultOptionsFactory(AudacityProject &project, bool newDefaults)
Default factory function ignores the second argument.
double GetEndTime() const
Return the greatest end time of the tracks, or 0 when no tracks.
Definition: Track.cpp:784
PlayRegion playRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:44

Install an implementation in a library hook.

Definition at line 1203 of file ProjectAudioManager.cpp.

◆ stopIfPaused

RegisteredMenuItemEnabler stopIfPaused
static
Initial value:
{{
[]{ return PausedFlag(); },
[]{ return AudioIONotBusyFlag(); },
[]( const AudacityProject &project ){
}
}}
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:30
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & PausedFlag()
static CommandManager & Get(AudacityProject &project)

Definition at line 1323 of file ProjectAudioManager.cpp.