Audacity  3.0.3
Classes | Typedefs | Enumerations | Functions | Variables
ProjectAudioManager.h File Reference
#include <memory>
#include <vector>
#include "AudioIOListener.h"
#include "ClientData.h"
#include <wx/event.h>
#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

class  ProjectAudioManager
 
struct  PropertiesOfSelected
 

Typedefs

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

Enumerations

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

Functions

AUDACITY_DLL_API AudioIOStartStreamOptions DefaultPlayOptions (AudacityProject &project, bool looped=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 29 of file ProjectAudioManager.h.

Enumeration Type Documentation

◆ PlayMode

enum PlayMode : int
strong
Enumerator
normalPlay 
oneSecondPlay 
loopedPlay 
cutPreviewPlay 

Definition at line 31 of file ProjectAudioManager.h.

31  : int {
32  normalPlay,
33  oneSecondPlay, // Disables auto-scrolling
34  loopedPlay, // Disables auto-scrolling
36 };

Function Documentation

◆ CanStopAudioStreamFlag()

AUDACITY_DLL_API const ReservedCommandFlag& CanStopAudioStreamFlag ( )

Definition at line 1153 of file ProjectAudioManager.cpp.

1153  { static ReservedCommandFlag flag{
1154  [](const AudacityProject &project){
1155  auto &projectAudioManager = ProjectAudioManager::Get( project );
1156  bool canStop = projectAudioManager.CanStopAudioStream();
1157  return canStop;
1158  }
1159  }; return flag; }

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  looped = false 
)

Definition at line 1162 of file ProjectAudioManager.cpp.

1163 {
1164  auto &projectAudioIO = ProjectAudioIO::Get( project );
1165  AudioIOStartStreamOptions options { project.shared_from_this(),
1166  ProjectRate::Get( project ).GetRate() };
1167  options.captureMeter = projectAudioIO.GetCaptureMeter();
1168  options.playbackMeter = projectAudioIO.GetPlaybackMeter();
1169  auto timeTrack = *TrackList::Get( project ).Any<TimeTrack>().begin();
1170  options.envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
1171  options.listener = ProjectAudioManager::Get( project ).shared_from_this();
1172 
1173  if (looped)
1174  options.policyFactory = []() -> std::unique_ptr<PlaybackPolicy> {
1175  return std::make_unique<LoopingPlaybackPolicy>(); };
1176  return options;
1177 }

References TrackList::Any(), ProjectRate::Get(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), TrackList::Get(), and ProjectRate::GetRate().

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(), Effect::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 1180 of file ProjectAudioManager.cpp.

1181 {
1182  auto result = DefaultPlayOptions( project );
1183  auto gAudioIO = AudioIO::Get();
1184  auto PlayAtSpeedRate = gAudioIO->GetBestRate(
1185  false, //not capturing
1186  true, //is playing
1187  ProjectRate::Get( project ).GetRate() //suggested rate
1188  );
1189  result.rate = PlayAtSpeedRate;
1190  return result;
1191 }

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 1311 of file ProjectAudioManager.cpp.

1312 {
1313  double rateOfSelection{ RATE_NOT_SELECTED };
1314 
1315  PropertiesOfSelected result;
1316  result.allSameRate = true;
1317 
1318  const auto selectedTracks{
1319  TrackList::Get(proj).Selected< const WaveTrack >() };
1320 
1321  for (const auto & track : selectedTracks)
1322  {
1323  if (rateOfSelection != RATE_NOT_SELECTED &&
1324  track->GetRate() != rateOfSelection)
1325  result.allSameRate = false;
1326  else if (rateOfSelection == RATE_NOT_SELECTED)
1327  rateOfSelection = track->GetRate();
1328  }
1329 
1330  result.numberOfSelected = selectedTracks.size();
1331  result.rateOfSelected = rateOfSelection;
1332 
1333  return result;
1334 }

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:

Variable Documentation

◆ RATE_NOT_SELECTED

constexpr int RATE_NOT_SELECTED { -1 }
constexpr
PropertiesOfSelected::allSameRate
bool allSameRate
Definition: ProjectAudioManager.h:170
PlayMode::cutPreviewPlay
@ cutPreviewPlay
PropertiesOfSelected::numberOfSelected
int numberOfSelected
Definition: ProjectAudioManager.h:172
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:55
flag
static std::once_flag flag
Definition: WaveformView.cpp:1119
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
ReservedCommandFlag
Definition: CommandFlag.h:89
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:22
PlayMode::normalPlay
@ normalPlay
PropertiesOfSelected
Definition: ProjectAudioManager.h:169
anonymous_namespace{TimeTrack.cpp}::GetRate
double GetRate()
Definition: TimeTrack.cpp:175
AudioIOStartStreamOptions
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:44
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
DefaultPlayOptions
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool looped)
Definition: ProjectAudioManager.cpp:1162
RATE_NOT_SELECTED
constexpr int RATE_NOT_SELECTED
Definition: ProjectAudioManager.h:21
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
PlayMode::oneSecondPlay
@ oneSecondPlay
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:141
PlayMode::loopedPlay
@ loopedPlay
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
PropertiesOfSelected::rateOfSelected
int rateOfSelected
Definition: ProjectAudioManager.h:171
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24