Audacity  3.0.3
Functions | Variables
ProjectAudioManager.cpp File Reference
#include "ProjectAudioManager.h"
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/statusbr.h>
#include "AudioIO.h"
#include "BasicUI.h"
#include "CommonCommandFlags.h"
#include "LabelTrack.h"
#include "Menus.h"
#include "Meter.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 "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/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 999 of file ProjectAudioManager.cpp.

999  { static ReservedCommandFlag flag{
1000  [](const AudacityProject &project){
1001  auto &projectAudioManager = ProjectAudioManager::Get( project );
1002  bool canStop = projectAudioManager.CanStopAudioStream();
1003  return canStop;
1004  }
1005  }; 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 1008 of file ProjectAudioManager.cpp.

1009 {
1010  auto &projectAudioIO = ProjectAudioIO::Get( project );
1011  AudioIOStartStreamOptions options { &project,
1012  ProjectRate::Get( project ).GetRate() };
1013  options.captureMeter = projectAudioIO.GetCaptureMeter();
1014  options.playbackMeter = projectAudioIO.GetPlaybackMeter();
1015  auto timeTrack = *TrackList::Get( project ).Any<TimeTrack>().begin();
1016  options.envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
1017  options.listener = ProjectAudioManager::Get( project ).shared_from_this();
1018  return options;
1019 }

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

1023 {
1024  auto result = DefaultPlayOptions( project );
1025  auto gAudioIO = AudioIO::Get();
1026  auto PlayAtSpeedRate = gAudioIO->GetBestRate(
1027  false, //not capturing
1028  true, //is playing
1029  ProjectRate::Get( project ).GetRate() //suggested rate
1030  );
1031  result.rate = PlayAtSpeedRate;
1032  return result;
1033 }

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

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

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

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

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

PropertiesOfSelected::allSameRate
bool allSameRate
Definition: ProjectAudioManager.h:176
PropertiesOfSelected::numberOfSelected
int numberOfSelected
Definition: ProjectAudioManager.h:178
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:53
flag
static std::once_flag flag
Definition: WaveformView.cpp:1124
DefaultPlayOptions
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project)
Definition: ProjectAudioManager.cpp:1008
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:127
ReservedCommandFlag
Definition: CommandFlag.h:89
XO
#define XO(s)
Definition: Internat.h:31
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:22
PropertiesOfSelected
Definition: ProjectAudioManager.h:175
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:74
PausedFlag
const ReservedCommandFlag & PausedFlag()
Definition: CommonCommandFlags.cpp:318
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
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
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
ProjectAudioManager::StopIfPaused
void StopIfPaused()
Definition: ProjectAudioManager.cpp:1062
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:138
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
MenuManager::mStopIfWasPaused
bool mStopIfWasPaused
Definition: Menus.h:123
PropertiesOfSelected::rateOfSelected
int rateOfSelected
Definition: ProjectAudioManager.h:177
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24