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 "AudioIO.h"
#include "BasicUI.h"
#include "CommonCommandFlags.h"
#include "Menus.h"
#include "Meter.h"
#include "Mix.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectFileIO.h"
#include "ProjectHistory.h"
#include "ProjectRate.h"
#include "ProjectSettings.h"
#include "ProjectStatus.h"
#include "ProjectWindows.h"
#include "ScrubState.h"
#include "TrackPanelAx.h"
#include "UndoManager.h"
#include "ViewInfo.h"
#include "WaveTrack.h"
#include "toolbars/ToolManager.h"
#include "prefs/TracksPrefs.h"
#include "tracks/ui/Scrubbing.h"
#include "tracks/ui/TrackView.h"
#include "widgets/MeterPanelBase.h"
#include "widgets/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

 wxDEFINE_EVENT (EVT_RECORDING_DROPOUT, RecordingDropoutEvent)
 
static TranslatableString FormatRate (int rate)
 
const ReservedCommandFlagCanStopAudioStreamFlag ()
 
AudioIOStartStreamOptions DefaultPlayOptions (AudacityProject &project, bool newDefault)
 
AudioIOStartStreamOptions DefaultSpeedPlayOptions (AudacityProject &project)
 
PropertiesOfSelected GetPropertiesOfSelected (const AudacityProject &proj)
 

Variables

static AudacityProject::AttachedObjects::RegisteredFactory sProjectAudioManagerKey
 
static RegisteredMenuItemEnabler stopIfPaused
 

Function Documentation

◆ CanStopAudioStreamFlag()

const ReservedCommandFlag & CanStopAudioStreamFlag ( )

Definition at line 1150 of file ProjectAudioManager.cpp.

1150 { static ReservedCommandFlag flag{
1151 [](const AudacityProject &project){
1152 auto &projectAudioManager = ProjectAudioManager::Get( project );
1153 bool canStop = projectAudioManager.CanStopAudioStream();
1154 return canStop;
1155 }
1156 }; return flag; }
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:89
static ProjectAudioManager & Get(AudacityProject &project)

References flag, and ProjectAudioManager::Get().

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

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

◆ DefaultPlayOptions()

AudioIOStartStreamOptions DefaultPlayOptions ( AudacityProject project,
bool  newDefault 
)
Parameters
newDefault"new" default playback policy adjusts to changes of the looping region, "old" default plays once straight

Definition at line 1159 of file ProjectAudioManager.cpp.

1160{
1161 auto &projectAudioIO = ProjectAudioIO::Get( project );
1162 AudioIOStartStreamOptions options { project.shared_from_this(),
1163 ProjectRate::Get( project ).GetRate() };
1164 options.captureMeter = projectAudioIO.GetCaptureMeter();
1165 options.playbackMeter = projectAudioIO.GetPlaybackMeter();
1166 options.envelope = Mixer::WarpOptions::DefaultWarp::Call(TrackList::Get(project));
1167 options.listener = ProjectAudioManager::Get( project ).shared_from_this();
1168
1169 bool loopEnabled = ViewInfo::Get(project).playRegion.Active();
1170 options.loopEnabled = loopEnabled;
1171
1172 if (newDefault) {
1173 const double trackEndTime = TrackList::Get(project).GetEndTime();
1174 const double loopEndTime = ViewInfo::Get(project).playRegion.GetEnd();
1175 options.policyFactory = [&project, trackEndTime, loopEndTime](
1176 const AudioIOStartStreamOptions &options)
1177 -> std::unique_ptr<PlaybackPolicy>
1178 {
1179 return std::make_unique<NewDefaultPlaybackPolicy>( project,
1180 trackEndTime, loopEndTime,
1181 options.loopEnabled, options.variableSpeed);
1182 };
1183
1184 // Start play from left edge of selection
1185 options.pStartTime.emplace(ViewInfo::Get(project).selectedRegion.t0());
1186 }
1187
1188 return options;
1189}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
double GetEnd() const
Definition: ViewInfo.h:134
bool Active() const
Definition: ViewInfo.h:123
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
double GetEndTime() const
Definition: Track.cpp:1052
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
PlayRegion playRegion
Definition: ViewInfo.h:217
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

References PlayRegion::Active(), GlobalHook< DefaultWarp, const BoundedEnvelope *(const TrackList &) >::Call(), ProjectRate::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), PlayRegion::GetEnd(), TrackList::GetEndTime(), ProjectRate::GetRate(), and ViewInfo::playRegion.

Referenced by DefaultSpeedPlayOptions(), EffectUIHost::OnPlay(), TransportActions::Handler::OnPlayAfterSelectionEnd(), TransportActions::Handler::OnPlayAfterSelectionStart(), TransportActions::Handler::OnPlayBeforeAndAfterSelectionEnd(), TransportActions::Handler::OnPlayBeforeAndAfterSelectionStart(), TransportActions::Handler::OnPlayBeforeSelectionEnd(), TransportActions::Handler::OnPlayBeforeSelectionStart(), TransportActions::Handler::OnPlayOneSecond(), TransportActions::Handler::OnPlayToSelection(), ProjectAudioManager::OnRecord(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayCurrentRegion(), EffectBase::Preview(), MeterPanel::StartMonitoring(), and AdornedRulerPanel::StartQPPlay().

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

◆ DefaultSpeedPlayOptions()

AudioIOStartStreamOptions DefaultSpeedPlayOptions ( AudacityProject project)

Definition at line 1192 of file ProjectAudioManager.cpp.

1193{
1194 auto result = DefaultPlayOptions( project );
1195 auto gAudioIO = AudioIO::Get();
1196 auto PlayAtSpeedRate = gAudioIO->GetBestRate(
1197 false, //not capturing
1198 true, //is playing
1199 ProjectRate::Get( project ).GetRate() //suggested rate
1200 );
1201 result.rate = PlayAtSpeedRate;
1202 return result;
1203}
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
static AudioIO * Get()
Definition: AudioIO.cpp:133

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

Here is the call graph for this function:

◆ FormatRate()

static TranslatableString FormatRate ( int  rate)
static

Definition at line 78 of file ProjectAudioManager.cpp.

79{
80 if (rate > 0) {
81 return XO("Actual Rate: %d").Format( rate );
82 }
83 else
84 // clear the status field
85 return {};
86}
#define XO(s)
Definition: Internat.h:31

References XO.

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

Here is the caller graph for this function:

◆ GetPropertiesOfSelected()

PropertiesOfSelected GetPropertiesOfSelected ( const AudacityProject proj)

Definition at line 1323 of file ProjectAudioManager.cpp.

1324{
1325 double rateOfSelection{ RATE_NOT_SELECTED };
1326
1327 PropertiesOfSelected result;
1328 result.allSameRate = true;
1329
1330 const auto selectedTracks{
1331 TrackList::Get(proj).Selected< const WaveTrack >() };
1332
1333 for (const auto & track : selectedTracks)
1334 {
1335 if (rateOfSelection != RATE_NOT_SELECTED &&
1336 track->GetRate() != rateOfSelection)
1337 result.allSameRate = false;
1338 else if (rateOfSelection == RATE_NOT_SELECTED)
1339 rateOfSelection = track->GetRate();
1340 }
1341
1342 result.numberOfSelected = selectedTracks.size();
1343 result.rateOfSelected = rateOfSelection;
1344
1345 return result;
1346}
constexpr int RATE_NOT_SELECTED
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1454
A Track that contains audio waveform data.
Definition: WaveTrack.h:57

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

Referenced by ProjectAudioManager::OnRecord(), and TransportActions::Handler::OnTimerRecord().

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

◆ wxDEFINE_EVENT()

wxDEFINE_EVENT ( EVT_RECORDING_DROPOUT  ,
RecordingDropoutEvent   
)

Variable Documentation

◆ sProjectAudioManagerKey

Initial value:
{
[]( AudacityProject &project ) {
return std::make_shared< ProjectAudioManager >( project );
}
}

Definition at line 49 of file ProjectAudioManager.cpp.

Referenced by ProjectAudioManager::Get().

◆ stopIfPaused

RegisteredMenuItemEnabler stopIfPaused
static
Initial value:
{{
[]{ return PausedFlag(); },
[]{ return AudioIONotBusyFlag(); },
[]( const AudacityProject &project ){
return MenuManager::Get( project ).mStopIfWasPaused; },
[]( AudacityProject &project, CommandFlag ){
}
}}
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & PausedFlag()
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71
bool mStopIfWasPaused
Definition: Menus.h:125

Definition at line 1309 of file ProjectAudioManager.cpp.