Audacity 3.2.0
Static Public Member Functions | List of all members
TransportUtilities Struct Reference

#include <TransportUtilities.h>

Static Public Member Functions

static void PlayCurrentRegionAndWait (const CommandContext &context, bool newDefault=false, bool cutpreview=false)
 
static void PlayPlayRegionAndWait (const CommandContext &context, const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode mode)
 
static void RecordAndWait (const CommandContext &context, bool altAppearance)
 
static void DoStartPlaying (const CommandContext &context, bool newDefault=false)
 
static bool DoStopPlaying (const CommandContext &context)
 

Detailed Description

Definition at line 22 of file TransportUtilities.h.

Member Function Documentation

◆ DoStartPlaying()

void TransportUtilities::DoStartPlaying ( const CommandContext context,
bool  newDefault = false 
)
static

Definition at line 194 of file TransportUtilities.cpp.

196{
197 auto &project = context.project;
198 auto gAudioIO = AudioIOBase::Get();
199 //play the front project
200 if (!gAudioIO->IsBusy()) {
201 //Otherwise, start playing (assuming audio I/O isn't busy)
202
203 // Will automatically set mLastPlayMode
204 PlayCurrentRegionAndWait(context, newDefault);
205 }
206}
const auto project
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
AudacityProject & project
static void PlayCurrentRegionAndWait(const CommandContext &context, bool newDefault=false, bool cutpreview=false)

References AudioIOBase::Get(), PlayCurrentRegionAndWait(), CommandContext::project, and project.

Referenced by anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), and anonymous_namespace{TransportMenus.cpp}::OnPlayOnceOrStop().

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

◆ DoStopPlaying()

bool TransportUtilities::DoStopPlaying ( const CommandContext context)
static

Definition at line 154 of file TransportUtilities.cpp.

155{
156 auto &project = context.project;
157 auto &projectAudioManager = ProjectAudioManager::Get(project);
158 auto gAudioIO = AudioIOBase::Get();
159 auto &toolbar = ControlToolBar::Get(project);
161
162 //If this project is playing, stop playing, make sure everything is unpaused.
163 if (gAudioIO->IsStreamActive(token)) {
164 toolbar.SetStop(); //Pushes stop down
165 projectAudioManager.Stop();
166 // Playing project was stopped. All done.
167 return true;
168 }
169
170 // This project isn't playing.
171 // If some other project is playing, stop playing it
172 if (gAudioIO->IsStreamActive()) {
173
174 //find out which project we need;
175 auto start = AllProjects{}.begin(), finish = AllProjects{}.end(),
176 iter = std::find_if(start, finish,
177 [&](const AllProjects::value_type &ptr) {
178 return gAudioIO->IsStreamActive(
180
181 //stop playing the other project
182 if (iter != finish) {
183 auto otherProject = *iter;
184 auto &otherToolbar = ControlToolBar::Get(*otherProject);
185 auto &otherProjectAudioManager =
186 ProjectAudioManager::Get(*otherProject);
187 otherToolbar.SetStop(); //Pushes stop down
188 otherProjectAudioManager.Stop();
189 }
190 }
191 return false;
192}
const_iterator end() const
Definition: Project.cpp:27
Container::value_type value_type
Definition: Project.h:57
const_iterator begin() const
Definition: Project.cpp:22
static ControlToolBar & Get(AudacityProject &project)
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectAudioManager & Get(AudacityProject &project)

References AllProjects::begin(), AllProjects::end(), AudioIOBase::Get(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), ControlToolBar::Get(), ProjectAudioIO::GetAudioIOToken(), CommandContext::project, and project.

Referenced by anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), anonymous_namespace{TransportMenus.cpp}::OnPlayDefaultOrStop(), and anonymous_namespace{TransportMenus.cpp}::OnPlayOnceOrStop().

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

◆ PlayCurrentRegionAndWait()

void TransportUtilities::PlayCurrentRegionAndWait ( const CommandContext context,
bool  newDefault = false,
bool  cutpreview = false 
)
static

Definition at line 28 of file TransportUtilities.cpp.

32{
33 auto &project = context.project;
34 auto &projectAudioManager = ProjectAudioManager::Get(project);
35
36 const auto &playRegion = ViewInfo::Get(project).playRegion;
37 double t0 = playRegion.GetStart();
38 double t1 = playRegion.GetEnd();
39
40 projectAudioManager.PlayCurrentRegion(newDefault, cutpreview);
41
42 if (project.mBatchMode > 0 && t0 != t1 && !newDefault) {
43 wxYieldIfNeeded();
44
45 /* i18n-hint: This title appears on a dialog that indicates the progress
46 in doing something.*/
47 ProgressDialog progress(XO("Progress"), XO("Playing"), pdlgHideCancelButton);
48 auto gAudioIO = AudioIO::Get();
49
50 while (projectAudioManager.Playing()) {
51 ProgressResult result = progress.Update(gAudioIO->GetStreamTime() - t0, t1 - t0);
52 if (result != ProgressResult::Success) {
53 projectAudioManager.Stop();
54 if (result != ProgressResult::Stopped) {
55 context.Error(wxT("Playing interrupted"));
56 }
57 break;
58 }
59
60 using namespace std::chrono;
61 std::this_thread::sleep_for(100ms);
62 wxYieldIfNeeded();
63 }
64
65 projectAudioManager.Stop();
66 wxYieldIfNeeded();
67 }
68}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
@ pdlgHideCancelButton
static AudioIO * Get()
Definition: AudioIO.cpp:126
virtual void Error(const wxString &message) const
double GetStart() const
Definition: ViewInfo.h:129
ProgressDialog Class.
PlayRegion playRegion
Definition: ViewInfo.h:217
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
ProgressResult
Definition: BasicUI.h:155

References CommandContext::Error(), AudioIO::Get(), ViewInfo::Get(), ProjectAudioManager::Get(), PlayRegion::GetStart(), pdlgHideCancelButton, ViewInfo::playRegion, CommandContext::project, project, BasicUI::Stopped, BasicUI::Success, ProgressDialog::Update(), wxT(), and XO().

Referenced by DoStartPlaying(), anonymous_namespace{TransportMenus.cpp}::OnPlayCutPreview(), and anonymous_namespace{TransportMenus.cpp}::OnPlayDefaultOrStop().

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

◆ PlayPlayRegionAndWait()

void TransportUtilities::PlayPlayRegionAndWait ( const CommandContext context,
const SelectedRegion selectedRegion,
const AudioIOStartStreamOptions options,
PlayMode  mode 
)
static

Definition at line 70 of file TransportUtilities.cpp.

75{
76 auto &project = context.project;
77 auto &projectAudioManager = ProjectAudioManager::Get(project);
78
79 double t0 = selectedRegion.t0();
80 double t1 = selectedRegion.t1();
81
82 projectAudioManager.PlayPlayRegion(selectedRegion, options, mode);
83
84 if (project.mBatchMode > 0) {
85 wxYieldIfNeeded();
86
87 /* i18n-hint: This title appears on a dialog that indicates the progress
88 in doing something.*/
89 ProgressDialog progress(XO("Progress"), XO("Playing"), pdlgHideCancelButton);
90 auto gAudioIO = AudioIO::Get();
91
92 while (projectAudioManager.Playing()) {
93 ProgressResult result = progress.Update(gAudioIO->GetStreamTime() - t0, t1 - t0);
94 if (result != ProgressResult::Success) {
95 projectAudioManager.Stop();
96 if (result != ProgressResult::Stopped) {
97 context.Error(wxT("Playing interrupted"));
98 }
99 break;
100 }
101
102 using namespace std::chrono;
103 std::this_thread::sleep_for(100ms);
104 wxYieldIfNeeded();
105 }
106
107 projectAudioManager.Stop();
108 wxYieldIfNeeded();
109 }
110}
double t1() const
double t0() const

References CommandContext::Error(), AudioIO::Get(), ProjectAudioManager::Get(), pdlgHideCancelButton, CommandContext::project, project, BasicUI::Stopped, BasicUI::Success, SelectedRegion::t0(), SelectedRegion::t1(), ProgressDialog::Update(), wxT(), and XO().

Referenced by anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayOneSecond(), and anonymous_namespace{TransportMenus.cpp}::OnPlayToSelection().

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

◆ RecordAndWait()

void TransportUtilities::RecordAndWait ( const CommandContext context,
bool  altAppearance 
)
static

Definition at line 112 of file TransportUtilities.cpp.

114{
115 auto &project = context.project;
116 auto &projectAudioManager = ProjectAudioManager::Get(project);
117
118 const auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
119 double t0 = selectedRegion.t0();
120 double t1 = selectedRegion.t1();
121
122 projectAudioManager.OnRecord(altAppearance);
123
124 if (project.mBatchMode > 0 && t1 != t0) {
125 wxYieldIfNeeded();
126
127 /* i18n-hint: This title appears on a dialog that indicates the progress
128 in doing something.*/
129 ProgressDialog progress(XO("Progress"), XO("Recording"), pdlgHideCancelButton);
130 auto gAudioIO = AudioIO::Get();
131
132 while (projectAudioManager.Recording()) {
133 ProgressResult result = progress.Update(gAudioIO->GetStreamTime() - t0, t1 - t0);
134 if (result != ProgressResult::Success) {
135 projectAudioManager.Stop();
136 if (result != ProgressResult::Stopped) {
137 context.Error(wxT("Recording interrupted"));
138 }
139 break;
140 }
141
142 using namespace std::chrono;
143 std::this_thread::sleep_for(100ms);
144 wxYieldIfNeeded();
145 }
146
147 projectAudioManager.Stop();
148 wxYieldIfNeeded();
149 }
150}
double t0() const
Definition: ViewInfo.h:35
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216

References CommandContext::Error(), AudioIO::Get(), ViewInfo::Get(), ProjectAudioManager::Get(), pdlgHideCancelButton, CommandContext::project, project, ViewInfo::selectedRegion, BasicUI::Stopped, BasicUI::Success, NotifyingSelectedRegion::t0(), ProgressDialog::Update(), wxT(), and XO().

Referenced by anonymous_namespace{TransportMenus.cpp}::OnRecord(), and anonymous_namespace{TransportMenus.cpp}::OnRecord2ndChoice().

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

The documentation for this struct was generated from the following files: