Audacity 3.2.0
Classes | Typedefs | Enumerations | Functions | Variables
ProjectAudioManager.h File Reference
#include <memory>
#include <vector>
#include "AudioIOListener.h"
#include "ClientData.h"
#include <wx/event.h>
#include <atomic>
#include "commands/CommandFlag.h"
Include dependency graph for ProjectAudioManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RecordingDropoutEvent
 Notification, posted on the project, after recording has stopped, when dropouts have been detected. More...
 
class  ProjectAudioManager
 
struct  PropertiesOfSelected
 

Typedefs

using WaveTrackArray = std::vector< std::shared_ptr< WaveTrack > >
 

Enumerations

enum class  PlayMode : int { normalPlay , oneSecondPlay , loopedPlay , cutPreviewPlay }
 

Functions

 wxDECLARE_EXPORTED_EVENT (AUDACITY_DLL_API, EVT_RECORDING_DROPOUT, RecordingDropoutEvent)
 
AUDACITY_DLL_API AudioIOStartStreamOptions DefaultPlayOptions (AudacityProject &project, bool newDefault=false)
 
AudioIOStartStreamOptions DefaultSpeedPlayOptions (AudacityProject &project)
 
AUDACITY_DLL_API PropertiesOfSelected GetPropertiesOfSelected (const AudacityProject &proj)
 
AUDACITY_DLL_API const ReservedCommandFlagCanStopAudioStreamFlag ()
 

Variables

constexpr int RATE_NOT_SELECTED { -1 }
 

Typedef Documentation

◆ WaveTrackArray

using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >

Definition at line 31 of file ProjectAudioManager.h.

Enumeration Type Documentation

◆ PlayMode

enum class PlayMode : int
strong
Enumerator
normalPlay 
oneSecondPlay 
loopedPlay 
cutPreviewPlay 

Definition at line 33 of file ProjectAudioManager.h.

33 : int {
35 oneSecondPlay, // Disables auto-scrolling
36 loopedPlay, // Possibly looped play (not always); disables auto-scrolling
38};
@ cutPreviewPlay

Function Documentation

◆ CanStopAudioStreamFlag()

AUDACITY_DLL_API 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()

AUDACITY_DLL_API AudioIOStartStreamOptions DefaultPlayOptions ( AudacityProject project,
bool  newDefault = false 
)
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:1030
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:468
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:

◆ GetPropertiesOfSelected()

AUDACITY_DLL_API 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:1446
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:

◆ wxDECLARE_EXPORTED_EVENT()

wxDECLARE_EXPORTED_EVENT ( AUDACITY_DLL_API  ,
EVT_RECORDING_DROPOUT  ,
RecordingDropoutEvent   
)

Variable Documentation

◆ RATE_NOT_SELECTED

constexpr int RATE_NOT_SELECTED { -1 }
constexpr