Audacity  3.0.3
Functions | Variables
ProjectAudioManager.cpp File Reference
#include "ProjectAudioManager.h"
#include <wx/frame.h>
#include <wx/statusbr.h>
#include "AudioIO.h"
#include "CommonCommandFlags.h"
#include "LabelTrack.h"
#include "Menus.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectFileIO.h"
#include "ProjectHistory.h"
#include "ProjectSettings.h"
#include "ProjectStatus.h"
#include "TimeTrack.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/ErrorDialog.h"
#include "widgets/MeterPanelBase.h"
#include "widgets/Warning.h"
#include "widgets/AudacityMessageBox.h"
Include dependency graph for ProjectAudioManager.cpp:

Go to the source code of this file.

Functions

static TranslatableString FormatRate (int rate)
 
const ReservedCommandFlagCanStopAudioStreamFlag ()
 
AudioIOStartStreamOptions DefaultPlayOptions (AudacityProject &project)
 
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 994 of file ProjectAudioManager.cpp.

994  { static ReservedCommandFlag flag{
995  [](const AudacityProject &project){
996  auto &projectAudioManager = ProjectAudioManager::Get( project );
997  bool canStop = projectAudioManager.CanStopAudioStream();
998  return canStop;
999  }
1000  }; 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()

AudioIOStartStreamOptions DefaultPlayOptions ( AudacityProject project)

Definition at line 1003 of file ProjectAudioManager.cpp.

1004 {
1005  auto &projectAudioIO = ProjectAudioIO::Get( project );
1006  AudioIOStartStreamOptions options { &project,
1007  ProjectSettings::Get( project ).GetRate() };
1008  options.captureMeter = projectAudioIO.GetCaptureMeter();
1009  options.playbackMeter = projectAudioIO.GetPlaybackMeter();
1010  auto timeTrack = *TrackList::Get( project ).Any<TimeTrack>().begin();
1011  options.envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
1012  options.listener = ProjectAudioManager::Get( project ).shared_from_this();
1013  return options;
1014 }

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

Referenced by 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 1017 of file ProjectAudioManager.cpp.

1018 {
1019  auto &projectAudioIO = ProjectAudioIO::Get( project );
1020  auto gAudioIO = AudioIO::Get();
1021  auto PlayAtSpeedRate = gAudioIO->GetBestRate(
1022  false, //not capturing
1023  true, //is playing
1024  ProjectSettings::Get( project ).GetRate() //suggested rate
1025  );
1026  AudioIOStartStreamOptions options{ &project, PlayAtSpeedRate };
1027  options.captureMeter = projectAudioIO.GetCaptureMeter();
1028  options.playbackMeter = projectAudioIO.GetPlaybackMeter();
1029  auto timeTrack = *TrackList::Get( project ).Any<TimeTrack>().begin();
1030  options.envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
1031  options.listener = ProjectAudioManager::Get( project ).shared_from_this();
1032  return options;
1033 }

References TrackList::Any(), AudioIO::Get(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), ProjectSettings::Get(), and TrackList::Get().

Here is the call graph for this function:

◆ FormatRate()

static TranslatableString FormatRate ( int  rate)
static

Definition at line 74 of file ProjectAudioManager.cpp.

75 {
76  if (rate > 0) {
77  return XO("Actual Rate: %d").Format( rate );
78  }
79  else
80  // clear the status field
81  return {};
82 }

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

1157 {
1158  double rateOfSelection{ RATE_NOT_SELECTED };
1159 
1160  PropertiesOfSelected result;
1161  result.allSameRate = true;
1162 
1163  const auto selectedTracks{
1164  TrackList::Get(proj).Selected< const WaveTrack >() };
1165 
1166  for (const auto & track : selectedTracks)
1167  {
1168  if (rateOfSelection != RATE_NOT_SELECTED &&
1169  track->GetRate() != rateOfSelection)
1170  result.allSameRate = false;
1171  else if (rateOfSelection == RATE_NOT_SELECTED)
1172  rateOfSelection = track->GetRate();
1173  }
1174 
1175  result.numberOfSelected = selectedTracks.size();
1176  result.rateOfSelected = rateOfSelection;
1177 
1178  return result;
1179 }

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

◆ sProjectAudioManagerKey

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

Definition at line 45 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 ){
}
}}

Definition at line 1142 of file ProjectAudioManager.cpp.

PropertiesOfSelected::allSameRate
bool allSameRate
Definition: ProjectAudioManager.h:171
PropertiesOfSelected::numberOfSelected
int numberOfSelected
Definition: ProjectAudioManager.h:173
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:51
flag
static std::once_flag flag
Definition: WaveformView.cpp:1113
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:127
ReservedCommandFlag
Definition: CommandFlag.h:89
XO
#define XO(s)
Definition: Internat.h:32
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:39
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:23
PropertiesOfSelected
Definition: ProjectAudioManager.h:170
AudioIOStartStreamOptions
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:76
PausedFlag
const ReservedCommandFlag & PausedFlag()
Definition: CommonCommandFlags.cpp:332
RATE_NOT_SELECTED
constexpr int RATE_NOT_SELECTED
Definition: ProjectAudioManager.h:20
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
ProjectSettings::GetRate
double GetRate() const
Definition: ProjectSettings.cpp:166
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
ProjectAudioManager::StopIfPaused
void StopIfPaused()
Definition: ProjectAudioManager.cpp:1065
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1354
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:505
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1371
MenuManager::mStopIfWasPaused
bool mStopIfWasPaused
Definition: Menus.h:124
PropertiesOfSelected::rateOfSelected
int rateOfSelected
Definition: ProjectAudioManager.h:172
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24